Skip to content

Commit

Permalink
Changed Iron Flask recipe to require forge created unfinished flask
Browse files Browse the repository at this point in the history
Added broken items and recipes to repair
  • Loading branch information
Gaelmare committed Jan 13, 2020
1 parent a4695ec commit 35ff513
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 19 deletions.
12 changes: 11 additions & 1 deletion src/main/java/org/labellum/mc/waterflasks/Waterflasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
along with WaterFlasks. If not, see <https://www.gnu.org/licenses/>.
*/

import net.dries007.tfc.api.recipes.anvil.AnvilRecipe;
import net.dries007.tfc.api.recipes.knapping.KnappingRecipe;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -96,13 +97,22 @@ public static void registerItems(ModelRegistryEvent event) {
}

/**
* Register Knapping Recipes
* Register Knapping Recipe
*/
@SubscribeEvent
public static void onRegisterKnappingRecipeEvent(RegistryEvent.Register<KnappingRecipe> event) {
ModRecipes.registerKnapping(event);
}

/**
* Register Anvil Recipe
*/
@SubscribeEvent
public static void onRegisterAnvilRecipeEvent(RegistryEvent.Register<AnvilRecipe> event) {
ModRecipes.registerAnvil(event);
}


@SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent event)
{
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/org/labellum/mc/waterflasks/item/ItemFlask.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.dries007.tfc.api.capability.size.IItemSize;
import net.dries007.tfc.api.capability.size.Size;
import net.dries007.tfc.api.capability.size.Weight;
import net.dries007.tfc.client.TFCSounds;
import net.dries007.tfc.objects.fluids.FluidsTFC;
import net.dries007.tfc.objects.fluids.properties.DrinkableProperty;
import net.dries007.tfc.objects.fluids.properties.FluidWrapper;
Expand Down Expand Up @@ -245,7 +246,24 @@ public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World worldIn, Entity
DrinkableProperty drinkable = FluidsTFC.getWrapper(fluidConsumed.getFluid()).get(DrinkableProperty.DRINKABLE);
if (drinkable != null) {
drinkable.onDrink((EntityPlayer) entityLiving);
stack.damageItem(1,entityLiving);
if (stack.getItemDamage() == stack.getMaxDamage()) {
ResourceLocation name = stack.getItem().getRegistryName();
//break item, play sound
worldIn.playSound(null, entityLiving.getPosition(), TFCSounds.CERAMIC_BREAK, SoundCategory.PLAYERS, 1.0f, 1.0f);
if (name.toString().contains("leather"))
{
ItemHandlerHelper.giveItemToPlayer((EntityPlayer) entityLiving, new ItemStack(ModItems.brokenLeatherFlask));
}
else
{
ItemHandlerHelper.giveItemToPlayer((EntityPlayer) entityLiving, new ItemStack(ModItems.brokenIronFlask));
}
stack.shrink(1); //race condition here, seems to only sometimes work?
}
else
{
stack.damageItem(1, entityLiving);
}
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/org/labellum/mc/waterflasks/item/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
package org.labellum.mc.waterflasks.item;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.registries.IForgeRegistry;

import static net.dries007.tfc.objects.CreativeTabsTFC.*;
import org.labellum.mc.waterflasks.ConfigFlasks;

public class ModItems {

public static ItemBase leatherSide = new ItemBase("leather_side").setCreativeTab(CreativeTabs.MATERIALS);
public static ItemBase bladder = new ItemBase("bladder").setCreativeTab(CreativeTabs.MATERIALS);
public static ItemBase leatherSide = new ItemBase("leather_side").setCreativeTab(CT_MISC);
public static ItemBase bladder = new ItemBase("bladder").setCreativeTab(CT_MISC);
public static ItemLeatherFlask leatherFlask = new ItemLeatherFlask();
public static ItemBase unfinishedFlask = new ItemBase("unfinished_iron_flask").setCreativeTab(CT_METAL);
public static ItemBase brokenLeatherFlask = new ItemBase("broken_leather_flask").setCreativeTab(CT_MISC);
public static ItemBase brokenIronFlask = new ItemBase("broken_iron_flask").setCreativeTab(CT_METAL);
public static ItemIronFlask ironFlask = new ItemIronFlask();

public static void register(IForgeRegistry<Item> registry) {
registry.registerAll(
leatherSide,
bladder,
leatherFlask
leatherFlask,
brokenLeatherFlask
);
if (ConfigFlasks.GENERAL.enableIron) {
registry.register(unfinishedFlask);
registry.register(ironFlask);
registry.register(brokenIronFlask);
}
}

public static void registerModels() {
leatherFlask.registerItemModel();
leatherSide.registerItemModel();
bladder.registerItemModel();
brokenLeatherFlask.registerItemModel();
if (ConfigFlasks.GENERAL.enableIron) {
unfinishedFlask.registerItemModel();
ironFlask.registerItemModel();
brokenIronFlask.registerItemModel();
}
}
}
35 changes: 26 additions & 9 deletions src/main/java/org/labellum/mc/waterflasks/recipe/ModRecipes.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
package org.labellum.mc.waterflasks.recipe;

import net.dries007.tfc.api.recipes.anvil.AnvilRecipe;
import net.dries007.tfc.api.recipes.knapping.KnappingRecipe;
import net.dries007.tfc.api.recipes.knapping.KnappingRecipeSimple;
import net.dries007.tfc.api.recipes.knapping.KnappingType;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;

import net.dries007.tfc.api.types.Metal;
import net.dries007.tfc.objects.inventory.ingredient.IIngredient;
import net.dries007.tfc.objects.items.metal.ItemMetal;
import org.labellum.mc.waterflasks.item.ModItems;

import static net.dries007.tfc.api.types.Metal.ItemType.SHEET;
import static net.dries007.tfc.util.forge.ForgeRule.*;
import static net.dries007.tfc.util.skills.SmithingSkill.Type.GENERAL;
import static org.labellum.mc.waterflasks.Waterflasks.MOD_ID;

public class ModRecipes {

public static void registerKnapping(RegistryEvent.Register<KnappingRecipe> event) {
event.getRegistry().registerAll(
new KnappingRecipeSimple(KnappingType.LEATHER, true, new ItemStack(ModItems.leatherSide),
"X X X", "XXXXX", "XXXXX", "XXXXX", " XXX ").setRegistryName("leather_side")
" XX ", " XXX ", "XXXXX", " XXX ", " X ").setRegistryName("leather_side")
);
}
/*
XX
XXX
XXXXX
XXX
X
*/

public static void registerAnvil(RegistryEvent.Register<AnvilRecipe> event) {
event.getRegistry().registerAll(
new AnvilRecipe(new ResourceLocation(MOD_ID,"unfinished_iron_flask"), IIngredient.of(new ItemStack(ItemMetal.get(Metal.WROUGHT_IRON,SHEET))),
new ItemStack(ModItems.unfinishedFlask), Metal.WROUGHT_IRON.getTier(), GENERAL, PUNCH_LAST, BEND_SECOND_LAST, BEND_THIRD_LAST)
);
}
}
/*
X X X
XXXXX
XXXXX
XXXXX
XXX
*/
4 changes: 4 additions & 0 deletions src/main/resources/assets/waterflasks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ item.waterflasks.leather_side.name=Leather Flask side
#Leather
item.waterflasks.filled_leather_flask.name=%s Leather Flask
item.waterflasks.leather_flask.name=Empty Leather Flask
item.waterflasks.broken_leather_flask.name=Broken Leather Flask

#Iron
item.waterflasks.filled_iron_flask.name=%s Iron Flask
item.waterflasks.iron_flask.name=Empty Iron Flask
item.waterflasks.unfinished_iron_flask.name=Unfinished Iron Flask
item.waterflasks.broken_iron_flask.name=Broken Iron Flask

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "waterflasks:items/broken_iron_flask"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "waterflasks:items/broken_leather_flask"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "waterflasks:items/unfinished_iron_flask"
}
}
8 changes: 4 additions & 4 deletions src/main/resources/assets/waterflasks/recipes/iron_flask.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"type": "tfc:damage_item_shaped",
"pattern": [
"ISK",
"LBL",
"CSI"
" SK",
"CBC",
"LIL"
],
"key": {
"I": {
"item": "tfc:metal/pick_head/wrought_iron"
"item": "waterflasks:unfinished_iron_flask"
},
"K": {
"type": "forge:ore_dict",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type": "tfc:damage_item_shaped",
"pattern": [
"FB",
"CK"
],
"key": {
"F": {
"item": "waterflasks:broken_iron_flask",
"data": 32767
},
"K": {
"type": "forge:ore_dict",
"ore": "knife",
"data": "*"
},
"C": {
"item": "tfc:crop/product/burlap_cloth"
},
"B": {
"item": "waterflasks:bladder"
}
},
"result": {
"item": "waterflasks:iron_flask",
"data": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"FB"
],
"key": {
"F": {
"item": "waterflasks:broken_leather_flask",
"data": 32767
},
"B": {
"item": "waterflasks:bladder"
}
},
"result": {
"item": "waterflasks:leather_flask",
"data": 0
}
}

0 comments on commit 35ff513

Please sign in to comment.