From d4cd0aaf7ee7591a5b8ba438effef53648240487 Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 11 Nov 2015 00:09:17 -0800 Subject: [PATCH] Fix #960, Use itemDamage for wood items instead of NBT --- api/forestry | 2 +- .../arboriculture/WoodItemAccess.java | 7 +- .../arboriculture/blocks/BlockArbFence.java | 6 +- .../arboriculture/blocks/BlockArbStairs.java | 6 +- .../arboriculture/blocks/BlockSlab.java | 7 +- .../arboriculture/blocks/BlockWood.java | 6 +- .../arboriculture/items/ItemBlockWood.java | 59 ++++++++- .../arboriculture/render/RenderFenceItem.java | 3 +- .../arboriculture/render/RenderLogItem.java | 2 +- .../arboriculture/render/RenderPlankItem.java | 2 +- .../arboriculture/render/RenderSlabItem.java | 2 +- .../arboriculture/render/RenderStairItem.java | 2 +- .../arboriculture/tiles/TileWood.java | 20 ++- .../forestry/core/recipes/RecipeUtil.java | 53 +------- .../core/recipes/ShapedRecipeCustom.java | 19 +-- .../core/recipes/ShapelessRecipeCustom.java | 36 +----- .../recipes/nei/INBTMatchingCachedRecipe.java | 21 ---- .../recipes/nei/NEIHandlerShapedCustom.java | 12 +- .../nei/NEIHandlerShapelessCustom.java | 12 +- .../forestry/core/recipes/nei/NEIUtils.java | 46 ------- .../factory/recipes/FabricatorRecipe.java | 10 +- .../recipes/nei/NEIHandlerFabricator.java | 42 +------ .../recipes/nei/NEIHandlerFermenter.java | 9 +- .../factory/tiles/TileFabricator.java | 3 +- .../forestry/plugins/PluginArboriculture.java | 116 ++++++++++++------ .../java/forestry/plugins/PluginFarming.java | 25 ++-- 26 files changed, 185 insertions(+), 343 deletions(-) delete mode 100644 src/main/java/forestry/core/recipes/nei/INBTMatchingCachedRecipe.java diff --git a/api/forestry b/api/forestry index 0920e3c45..d10d230b1 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit 0920e3c45f58c40bb1f57fe5945181a9f549aebf +Subproject commit d10d230b1a3a6ec51aea622695743557f7a84442 diff --git a/src/main/java/forestry/arboriculture/WoodItemAccess.java b/src/main/java/forestry/arboriculture/WoodItemAccess.java index d54b43da5..fd9ef7135 100644 --- a/src/main/java/forestry/arboriculture/WoodItemAccess.java +++ b/src/main/java/forestry/arboriculture/WoodItemAccess.java @@ -14,10 +14,10 @@ import java.util.EnumMap; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import forestry.api.arboriculture.EnumWoodType; import forestry.api.arboriculture.IWoodItemAccess; +import forestry.arboriculture.items.ItemBlockWood; public class WoodItemAccess implements IWoodItemAccess { private static final EnumMap logs = new EnumMap<>(EnumWoodType.class); @@ -32,11 +32,8 @@ public class WoodItemAccess implements IWoodItemAccess { private static final EnumMap stairsFireproof = new EnumMap<>(EnumWoodType.class); private static ItemStack getStack(EnumWoodType woodType, Block block) { - NBTTagCompound woodNBT = new NBTTagCompound(); - woodType.saveToCompound(woodNBT); - ItemStack itemStack = new ItemStack(block); - itemStack.setTagCompound(woodNBT); + ItemBlockWood.saveToItemStack(woodType, itemStack); return itemStack; } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockArbFence.java b/src/main/java/forestry/arboriculture/blocks/BlockArbFence.java index d9710bd7a..cfd3e2ac0 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockArbFence.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockArbFence.java @@ -24,7 +24,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; @@ -124,10 +123,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity /* PROPERTIES */ @Override public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - ItemStack itemStack = new ItemStack(this); - NBTTagCompound nbt = TileWood.getTagCompound(world, x, y, z); - itemStack.setTagCompound(nbt); - return itemStack; + return TileWood.getPickBlock(this, world, x, y, z); } /* DROP HANDLING */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockArbStairs.java b/src/main/java/forestry/arboriculture/blocks/BlockArbStairs.java index f29c60399..8d259872d 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockArbStairs.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockArbStairs.java @@ -22,7 +22,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; @@ -92,10 +91,7 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - ItemStack itemStack = super.getPickBlock(target, world, x, y, z); - NBTTagCompound stairsNBT = TileWood.getTagCompound(world, x, y, z); - itemStack.setTagCompound(stairsNBT); - return itemStack; + return TileWood.getPickBlock(this, world, x, y, z); } /* ICONS */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockSlab.java b/src/main/java/forestry/arboriculture/blocks/BlockSlab.java index e578a0859..f93e86c57 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockSlab.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockSlab.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.particle.EffectRenderer; @@ -24,7 +23,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; @@ -121,10 +119,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp /* PROPERTIES */ @Override public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - ItemStack itemStack = new ItemStack(this); - NBTTagCompound nbt = TileWood.getTagCompound(world, x, y, z); - itemStack.setTagCompound(nbt); - return itemStack; + return TileWood.getPickBlock(this, world, x, y, z); } /* DROP HANDLING */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockWood.java b/src/main/java/forestry/arboriculture/blocks/BlockWood.java index 6b12fe9c9..baf06bb37 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockWood.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockWood.java @@ -19,7 +19,6 @@ import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; @@ -78,10 +77,7 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW @Override public final ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - ItemStack itemStack = new ItemStack(this); - NBTTagCompound nbt = TileWood.getTagCompound(world, x, y, z); - itemStack.setTagCompound(nbt); - return itemStack; + return TileWood.getPickBlock(this, world, x, y, z); } /* DROP HANDLING */ diff --git a/src/main/java/forestry/arboriculture/items/ItemBlockWood.java b/src/main/java/forestry/arboriculture/items/ItemBlockWood.java index 47cc919c4..f9d002712 100644 --- a/src/main/java/forestry/arboriculture/items/ItemBlockWood.java +++ b/src/main/java/forestry/arboriculture/items/ItemBlockWood.java @@ -13,8 +13,10 @@ package forestry.arboriculture.items; import javax.annotation.Nullable; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -32,13 +34,14 @@ import forestry.core.items.ItemBlockForestry; import forestry.core.utils.StringUtil; public class ItemBlockWood extends ItemBlockForestry { + private static final String LEGACY_WOOD_TYPE_KEY = "WoodType"; public ItemBlockWood(Block block) { super(block); } public static boolean placeWood(ItemStack stack, @Nullable EntityPlayer player, World world, int x, int y, int z, int metadata) { - EnumWoodType woodType = EnumWoodType.getFromCompound(stack.getTagCompound()); + EnumWoodType woodType = getWoodType(stack); Block block = Block.getBlockFromItem(stack.getItem()); boolean placed = world.setBlock(x, y, z, block, metadata, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); @@ -66,6 +69,56 @@ public class ItemBlockWood extends ItemBlockForestry { return true; } + public static void saveToItemStack(EnumWoodType woodType, ItemStack itemStack) { + itemStack.setItemDamage(woodType.ordinal()); + } + + public static EnumWoodType getWoodType(ItemStack stack) { + EnumWoodType woodType = convertLegacyWood(stack); + if (woodType == null) { + int typeOrdinal = stack.getItemDamage(); + woodType = getFromOrdinal(typeOrdinal); + } + + return woodType; + } + + // legacy handling of wood that has wood type saved to NBT + private static EnumWoodType convertLegacyWood(ItemStack itemStack) { + if (!itemStack.hasTagCompound()) { + return null; + } + + NBTTagCompound compound = itemStack.getTagCompound(); + if (!compound.hasKey(LEGACY_WOOD_TYPE_KEY)) { + return null; + } + + int typeOrdinal = compound.getInteger(LEGACY_WOOD_TYPE_KEY); + EnumWoodType woodType = getFromOrdinal(typeOrdinal); + if (woodType != null) { + compound.removeTag(LEGACY_WOOD_TYPE_KEY); + if (compound.hasNoTags()) { + itemStack.setTagCompound(null); + } + saveToItemStack(woodType, itemStack); + } + return woodType; + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int p_77663_4_, boolean p_77663_5_) { + super.onUpdate(stack, world, player, p_77663_4_, p_77663_5_); + convertLegacyWood(stack); + } + + private static EnumWoodType getFromOrdinal(int ordinal) { + if (ordinal >= 0 && ordinal < EnumWoodType.VALUES.length) { + return EnumWoodType.VALUES[ordinal]; + } + return null; + } + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { return placeWood(stack, player, world, x, y, z, metadata); @@ -78,7 +131,7 @@ public class ItemBlockWood extends ItemBlockForestry { return super.getItemStackDisplayName(itemstack); } - EnumWoodType woodType = EnumWoodType.getFromCompound(itemstack.getTagCompound()); + EnumWoodType woodType = getWoodType(itemstack); if (woodType == null) { return super.getItemStackDisplayName(itemstack); } @@ -107,7 +160,7 @@ public class ItemBlockWood extends ItemBlockForestry { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int pass) { - EnumWoodType woodType = EnumWoodType.getFromCompound(stack.getTagCompound()); + EnumWoodType woodType = getWoodType(stack); if (woodType == null) { return super.getIcon(stack, pass); } diff --git a/src/main/java/forestry/arboriculture/render/RenderFenceItem.java b/src/main/java/forestry/arboriculture/render/RenderFenceItem.java index cf8342431..4580ba399 100644 --- a/src/main/java/forestry/arboriculture/render/RenderFenceItem.java +++ b/src/main/java/forestry/arboriculture/render/RenderFenceItem.java @@ -21,6 +21,7 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import forestry.api.arboriculture.EnumWoodType; +import forestry.arboriculture.items.ItemBlockWood; public class RenderFenceItem implements IItemRenderer { @Override @@ -61,7 +62,7 @@ public class RenderFenceItem implements IItemRenderer { private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z) { Tessellator tess = Tessellator.instance; - EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound()); + EnumWoodType woodType = ItemBlockWood.getWoodType(itemStack); IIcon plankIcon = IconProviderWood.getPlankIcon(woodType); Block block = Block.getBlockFromItem(itemStack.getItem()); diff --git a/src/main/java/forestry/arboriculture/render/RenderLogItem.java b/src/main/java/forestry/arboriculture/render/RenderLogItem.java index 9389cbd66..fce837ab3 100644 --- a/src/main/java/forestry/arboriculture/render/RenderLogItem.java +++ b/src/main/java/forestry/arboriculture/render/RenderLogItem.java @@ -68,7 +68,7 @@ public class RenderLogItem implements IItemRenderer { return; } - EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound()); + EnumWoodType woodType = ItemBlockWood.getWoodType(itemStack); IIcon barkIcon = IconProviderWood.getBarkIcon(woodType); IIcon heartIcon = IconProviderWood.getHeartIcon(woodType); diff --git a/src/main/java/forestry/arboriculture/render/RenderPlankItem.java b/src/main/java/forestry/arboriculture/render/RenderPlankItem.java index 606ca1384..bd54dfaf2 100644 --- a/src/main/java/forestry/arboriculture/render/RenderPlankItem.java +++ b/src/main/java/forestry/arboriculture/render/RenderPlankItem.java @@ -68,7 +68,7 @@ public class RenderPlankItem implements IItemRenderer { return; } - EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound()); + EnumWoodType woodType = ItemBlockWood.getWoodType(itemStack); IIcon plankIcon = IconProviderWood.getPlankIcon(woodType); if (plankIcon == null) { diff --git a/src/main/java/forestry/arboriculture/render/RenderSlabItem.java b/src/main/java/forestry/arboriculture/render/RenderSlabItem.java index 1881a7614..083604f59 100644 --- a/src/main/java/forestry/arboriculture/render/RenderSlabItem.java +++ b/src/main/java/forestry/arboriculture/render/RenderSlabItem.java @@ -58,7 +58,7 @@ public class RenderSlabItem implements IItemRenderer { return; } - EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound()); + EnumWoodType woodType = ItemBlockWood.getWoodType(itemStack); IIcon plankIcon = IconProviderWood.getPlankIcon(woodType); if (plankIcon == null) { diff --git a/src/main/java/forestry/arboriculture/render/RenderStairItem.java b/src/main/java/forestry/arboriculture/render/RenderStairItem.java index 1bcd70334..fc79cd737 100644 --- a/src/main/java/forestry/arboriculture/render/RenderStairItem.java +++ b/src/main/java/forestry/arboriculture/render/RenderStairItem.java @@ -70,7 +70,7 @@ public class RenderStairItem implements IItemRenderer { return; } - EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound()); + EnumWoodType woodType = ItemBlockWood.getWoodType(itemStack); IIcon texture = IconProviderWood.getPlankIcon(woodType); for (int i = 0; i < 2; ++i) { diff --git a/src/main/java/forestry/arboriculture/tiles/TileWood.java b/src/main/java/forestry/arboriculture/tiles/TileWood.java index a1864093b..9205803c7 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileWood.java +++ b/src/main/java/forestry/arboriculture/tiles/TileWood.java @@ -23,6 +23,7 @@ import net.minecraft.world.World; import forestry.api.arboriculture.EnumWoodType; import forestry.arboriculture.IWoodTyped; +import forestry.arboriculture.items.ItemBlockWood; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; @@ -85,15 +86,16 @@ public class TileWood extends TileEntity implements IStreamable { } } - public static NBTTagCompound getTagCompound(IBlockAccess world, int x, int y, int z) { + public static ItemStack getPickBlock(Block block, IBlockAccess world, int x, int y, int z) { TileWood wood = getWoodTile(world, x, y, z); - NBTTagCompound nbttagcompound = new NBTTagCompound(); if (wood == null) { - return nbttagcompound; + return null; } EnumWoodType woodType = wood.getWoodType(); - woodType.saveToCompound(nbttagcompound); - return nbttagcompound; + + ItemStack itemStack = new ItemStack(block); + ItemBlockWood.saveToItemStack(woodType, itemStack); + return itemStack; } public static TileWood getWoodTile(IBlockAccess world, int x, int y, int z) { @@ -103,12 +105,8 @@ public class TileWood extends TileEntity implements IStreamable { public static ArrayList getDrops(T block, World world, int x, int y, int z) { ArrayList drops = new ArrayList<>(); - TileWood wood = getWoodTile(world, x, y, z); - if (wood != null) { - ItemStack stack = new ItemStack(block); - NBTTagCompound compound = new NBTTagCompound(); - wood.getWoodType().saveToCompound(compound); - stack.setTagCompound(compound); + ItemStack stack = getPickBlock(block, world, x, y, z); + if (stack != null) { drops.add(stack); } diff --git a/src/main/java/forestry/core/recipes/RecipeUtil.java b/src/main/java/forestry/core/recipes/RecipeUtil.java index d6c03df4a..8563bc04b 100644 --- a/src/main/java/forestry/core/recipes/RecipeUtil.java +++ b/src/main/java/forestry/core/recipes/RecipeUtil.java @@ -21,7 +21,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; @@ -37,7 +36,6 @@ import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; import forestry.core.fluids.Fluids; import forestry.core.gui.ContainerDummy; -import forestry.core.inventory.InventoryPlain; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; @@ -79,26 +77,6 @@ public abstract class RecipeUtil { return oreDictNames; } - public static NBTTagCompound getCraftingNbt(IInventory inventoryCrafting) { - NBTTagCompound craftingNbt = null; - for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) { - ItemStack stackInSlot = inventoryCrafting.getStackInSlot(i); - if (stackInSlot == null || !stackInSlot.hasTagCompound()) { - continue; - } - - NBTTagCompound tagCompound = stackInSlot.getTagCompound(); - // if there are multiple NBT they must all match - if (craftingNbt != null && !craftingNbt.equals(tagCompound)) { - return null; - } else { - craftingNbt = tagCompound; - } - } - - return craftingNbt; - } - public static Object[] getCraftingRecipeAsArray(IDescriptiveRecipe recipe) { try { @@ -263,41 +241,12 @@ public abstract class RecipeUtil { GameRegistry.addSmelting(res, prod, xp); } - public static ItemStack getCraftingResult(IDescriptiveRecipe recipe, IInventory inventoryCrafting) { - return getCraftingResult(recipe.getRecipeOutput(), recipe.preserveNBT(), inventoryCrafting); - } - - public static ItemStack getCraftingResult(ItemStack result, boolean preserveNBT, IInventory inventoryCrafting) { - result = result.copy(); - - if (preserveNBT) { - NBTTagCompound craftingNbt = getCraftingNbt(inventoryCrafting); - if (craftingNbt == null) { - return null; - } - - result.setTagCompound(craftingNbt); - } - - return result; - } - public static boolean matches(IDescriptiveRecipe recipe, IInventory inventoryCrafting) { ItemStack[][] resources = getResources(inventoryCrafting); Object[] recipeIngredients = recipe.getIngredients(); int width = recipe.getWidth(); int height = recipe.getHeight(); - if (!matches(recipeIngredients, width, height, resources)) { - return false; - } - - if (recipe.preserveNBT()) { - if (getCraftingNbt(inventoryCrafting) == null) { - return false; - } - } - - return true; + return matches(recipeIngredients, width, height, resources); } private static ItemStack[][] getResources(IInventory inventoryCrafting) { diff --git a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java index 78d011b3a..16895b918 100644 --- a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java @@ -34,8 +34,6 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { private final Object[] ingredients; private final ItemStack product; - private boolean preserveNBT = false; - public ShapedRecipeCustom(int width, int height, Object[] ingredients, ItemStack product) { this.width = width; this.height = height; @@ -43,16 +41,6 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { this.product = product; } - public ShapedRecipeCustom setPreserveNBT() { - this.preserveNBT = true; - return this; - } - - @Override - public boolean preserveNBT() { - return preserveNBT; - } - @Override public int getWidth() { return width; @@ -73,6 +61,11 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { return ingredients; } + @Override + public boolean preserveNBT() { + return false; + } + @Override public boolean matches(InventoryCrafting inventoryCrafting, World world) { return RecipeUtil.matches(this, inventoryCrafting); @@ -86,7 +79,7 @@ public class ShapedRecipeCustom implements IDescriptiveRecipe { @Override public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - return RecipeUtil.getCraftingResult(this, inventoryCrafting); + return getRecipeOutput().copy(); } @Override diff --git a/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java index e77a16b33..d9d892277 100644 --- a/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapelessRecipeCustom.java @@ -8,7 +8,6 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; @@ -31,22 +30,12 @@ public class ShapelessRecipeCustom implements IRecipe { private final List ingredients; private final ItemStack product; - private boolean preservesNbt = false; private ShapelessRecipeCustom(ItemStack product, ItemStack... ingredients) { this.ingredients = Arrays.asList(ingredients); this.product = product; } - public ShapelessRecipeCustom setPreserveNBT() { - this.preservesNbt = true; - return this; - } - - public boolean preservesNbt() { - return preservesNbt; - } - @Override public boolean matches(InventoryCrafting inventoryCrafting, World world) { ArrayList arraylist = new ArrayList<>(this.ingredients); @@ -73,33 +62,12 @@ public class ShapelessRecipeCustom implements IRecipe { } } - if (!arraylist.isEmpty()) { - return false; - } - - if (preservesNbt) { - if (RecipeUtil.getCraftingNbt(inventoryCrafting) == null) { - return false; - } - } - - return true; + return arraylist.isEmpty(); } @Override public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - ItemStack result = product.copy(); - - if (preservesNbt) { - NBTTagCompound craftingNbt = RecipeUtil.getCraftingNbt(inventoryCrafting); - if (craftingNbt == null) { - return null; - } - - result.setTagCompound(craftingNbt); - } - - return result; + return product.copy(); } @Override diff --git a/src/main/java/forestry/core/recipes/nei/INBTMatchingCachedRecipe.java b/src/main/java/forestry/core/recipes/nei/INBTMatchingCachedRecipe.java deleted file mode 100644 index 436d5a0a1..000000000 --- a/src/main/java/forestry/core/recipes/nei/INBTMatchingCachedRecipe.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.recipes.nei; - -import codechicken.nei.PositionedStack; - -public interface INBTMatchingCachedRecipe { - Iterable getIngredients(); - - boolean preservesNBT(); - - PositionedStack getResult(); -} diff --git a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java index 57e9c2702..cd89bc484 100644 --- a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java +++ b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapedCustom.java @@ -23,9 +23,7 @@ import codechicken.nei.PositionedStack; public class NEIHandlerShapedCustom extends RecipeHandlerBase { - public class CachedShapedCustomRecipe extends CachedBaseRecipe implements INBTMatchingCachedRecipe { - private final boolean preservesNbt; - + public class CachedShapedCustomRecipe extends CachedBaseRecipe { public List inputs = new ArrayList<>(); public PositionedStack output; @@ -37,7 +35,6 @@ public class NEIHandlerShapedCustom extends RecipeHandlerBase { ItemStack output = recipe.getRecipeOutput(); this.output = new PositionedStack(output, 119, 24); } - this.preservesNbt = recipe.preserveNBT(); } public void setIngredients(int width, int height, Object[] items) { @@ -68,11 +65,6 @@ public class NEIHandlerShapedCustom extends RecipeHandlerBase { return this.getCycledIngredients(NEIHandlerShapedCustom.this.cycleticks / 20, this.inputs); } - @Override - public boolean preservesNBT() { - return preservesNbt; - } - @Override public PositionedStack getResult() { return this.output; @@ -85,7 +77,6 @@ public class NEIHandlerShapedCustom extends RecipeHandlerBase { for (Object recipe : CraftingManager.getInstance().getRecipeList()) { if (recipe instanceof ShapedRecipeCustom && NEIServerUtils.areStacksSameTypeCrafting(((ShapedRecipeCustom) recipe).getRecipeOutput(), result)) { CachedShapedCustomRecipe crecipe = new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe); - NEIUtils.setResultPermutationNBT(crecipe, result); this.arecipes.add(crecipe); } } @@ -97,7 +88,6 @@ public class NEIHandlerShapedCustom extends RecipeHandlerBase { if (recipe instanceof ShapedRecipeCustom) { CachedShapedCustomRecipe crecipe = new CachedShapedCustomRecipe((ShapedRecipeCustom) recipe); if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingredient)) { - NEIUtils.setIngredientPermutationNBT(crecipe, ingredient); this.arecipes.add(crecipe); } } diff --git a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java index 20b777b19..3d7268735 100644 --- a/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java +++ b/src/main/java/forestry/core/recipes/nei/NEIHandlerShapelessCustom.java @@ -24,9 +24,7 @@ import codechicken.nei.PositionedStack; public class NEIHandlerShapelessCustom extends RecipeHandlerBase { private static final int[][] OUTPUTS = new int[][]{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}}; - public class CachedShapelessCustomRecipe extends CachedBaseRecipe implements INBTMatchingCachedRecipe { - private final boolean preservesNbt; - + public class CachedShapelessCustomRecipe extends CachedBaseRecipe { public List inputs = new ArrayList<>(); public PositionedStack output; @@ -38,7 +36,6 @@ public class NEIHandlerShapelessCustom extends RecipeHandlerBase { ItemStack output = recipe.getRecipeOutput(); this.output = new PositionedStack(output, 119, 24); } - this.preservesNbt = recipe.preservesNbt(); } public void setIngredients(List items) { @@ -59,11 +56,6 @@ public class NEIHandlerShapelessCustom extends RecipeHandlerBase { return this.getCycledIngredients(NEIHandlerShapelessCustom.this.cycleticks / 20, this.inputs); } - @Override - public boolean preservesNBT() { - return preservesNbt; - } - @Override public PositionedStack getResult() { return this.output; @@ -76,7 +68,6 @@ public class NEIHandlerShapelessCustom extends RecipeHandlerBase { for (Object recipe : CraftingManager.getInstance().getRecipeList()) { if (recipe instanceof ShapelessRecipeCustom && NEIServerUtils.areStacksSameTypeCrafting(((ShapelessRecipeCustom) recipe).getRecipeOutput(), result)) { CachedShapelessCustomRecipe crecipe = new CachedShapelessCustomRecipe((ShapelessRecipeCustom) recipe); - NEIUtils.setResultPermutationNBT(crecipe, result); this.arecipes.add(crecipe); } } @@ -88,7 +79,6 @@ public class NEIHandlerShapelessCustom extends RecipeHandlerBase { if (recipe instanceof ShapelessRecipeCustom) { CachedShapelessCustomRecipe crecipe = new CachedShapelessCustomRecipe((ShapelessRecipeCustom) recipe); if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingredient)) { - NEIUtils.setIngredientPermutationNBT(crecipe, ingredient); this.arecipes.add(crecipe); } } diff --git a/src/main/java/forestry/core/recipes/nei/NEIUtils.java b/src/main/java/forestry/core/recipes/nei/NEIUtils.java index 5fe6208b5..881f81f09 100644 --- a/src/main/java/forestry/core/recipes/nei/NEIUtils.java +++ b/src/main/java/forestry/core/recipes/nei/NEIUtils.java @@ -17,7 +17,6 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.Fluid; @@ -26,9 +25,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidContainerItem; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; - public class NEIUtils { public static String translate(String unlocalized) { @@ -78,46 +74,4 @@ public class NEIUtils { } return fluidStack1.getFluid() == fluidStack2.getFluid(); } - - public static void setIngredientPermutationNBT(INBTMatchingCachedRecipe recipe, ItemStack ingredient) { - Iterable ingredients = recipe.getIngredients(); - for (PositionedStack stack : ingredients) { - for (int i = 0; i < stack.items.length; i++) { - if (NEIServerUtils.areStacksSameTypeCrafting(ingredient, stack.items[i])) { - stack.item = stack.items[i]; - stack.item.setItemDamage(ingredient.getItemDamage()); - - if (ingredient.hasTagCompound()) { - NBTTagCompound ingredientNbt = (NBTTagCompound) ingredient.getTagCompound().copy(); - stack.item.setTagCompound(ingredientNbt); - if (recipe.preservesNBT()) { - recipe.getResult().item.setTagCompound(ingredientNbt); - } - } - - stack.items = new ItemStack[]{stack.item}; - stack.setPermutationToRender(0); - break; - } - } - } - } - - public static void setResultPermutationNBT(INBTMatchingCachedRecipe recipe, ItemStack result) { - PositionedStack recipeResult = recipe.getResult(); - if (recipe.preservesNBT()) { - NBTTagCompound resultNbt = result.getTagCompound(); - recipeResult.item.setTagCompound((NBTTagCompound) resultNbt.copy()); - Iterable ingredients = recipe.getIngredients(); - for (PositionedStack stack : ingredients) { - if (stack.item.hasTagCompound()) { - stack.item.setTagCompound((NBTTagCompound) resultNbt.copy()); - } - - stack.items = new ItemStack[]{stack.item}; - stack.setPermutationToRender(0); - } - } - } - } diff --git a/src/main/java/forestry/factory/recipes/FabricatorRecipe.java b/src/main/java/forestry/factory/recipes/FabricatorRecipe.java index 2a2dafddc..898938e3c 100644 --- a/src/main/java/forestry/factory/recipes/FabricatorRecipe.java +++ b/src/main/java/forestry/factory/recipes/FabricatorRecipe.java @@ -65,7 +65,7 @@ public class FabricatorRecipe implements IFabricatorRecipe { @Override public boolean preservesNbt() { - return internal.preserveNBT(); + return false; } @Override @@ -81,17 +81,11 @@ public class FabricatorRecipe implements IFabricatorRecipe { @Override public ItemStack getCraftingResult(IInventory craftingInventory) { - return RecipeUtil.getCraftingResult(internal, craftingInventory); + return internal.getRecipeOutput().copy(); } @Override public ItemStack getRecipeOutput() { return internal.getRecipeOutput(); } - - public FabricatorRecipe setPreserveNBT() { - internal.setPreserveNBT(); - return this; - } - } diff --git a/src/main/java/forestry/factory/recipes/nei/NEIHandlerFabricator.java b/src/main/java/forestry/factory/recipes/nei/NEIHandlerFabricator.java index b58b8b9f2..0c2e5c877 100644 --- a/src/main/java/forestry/factory/recipes/nei/NEIHandlerFabricator.java +++ b/src/main/java/forestry/factory/recipes/nei/NEIHandlerFabricator.java @@ -16,11 +16,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -30,7 +28,6 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.recipes.IFabricatorRecipe; import forestry.api.recipes.IFabricatorSmeltingRecipe; import forestry.api.recipes.RecipeManagers; -import forestry.core.recipes.nei.INBTMatchingCachedRecipe; import forestry.core.recipes.nei.NEIUtils; import forestry.core.recipes.nei.PositionedFluidTank; import forestry.core.recipes.nei.RecipeHandlerBase; @@ -43,17 +40,13 @@ import codechicken.nei.recipe.GuiRecipe; public class NEIHandlerFabricator extends RecipeHandlerBase { - public class CachedFabricatorRecipe extends CachedBaseRecipe implements INBTMatchingCachedRecipe { - - private final boolean preservesNbt; - + public class CachedFabricatorRecipe extends CachedBaseRecipe { public List smeltingInput = new ArrayList<>(); public PositionedFluidTank tank; public List inputs = new ArrayList<>(); public PositionedStack output; public CachedFabricatorRecipe(IFabricatorRecipe recipe, boolean genPerms) { - this.preservesNbt = recipe.preservesNbt(); if (recipe.getLiquid() != null) { this.tank = new PositionedFluidTank(recipe.getLiquid(), 2000, new Rectangle(21, 37, 16, 16)); List smeltingInput = new ArrayList<>(); @@ -106,35 +99,6 @@ public class NEIHandlerFabricator extends RecipeHandlerBase { } } - @Override - public List getCycledIngredients(int cycle, List ingredients) { - if (preservesNbt) { - // cycle ingredients and output together - Random random = new Random(cycle); - cycle = Math.abs(random.nextInt()); - NBTTagCompound nbt = null; - for (PositionedStack ingredient : ingredients) { - ingredient.setPermutationToRender(cycle % ingredient.items.length); - if (ingredient.item.hasTagCompound()) { - nbt = ingredient.item.getTagCompound(); - } - } - output.setPermutationToRender(cycle % output.items.length); - if (nbt != null) { - output.item.setTagCompound((NBTTagCompound) nbt.copy()); - } - } else { - return super.getCycledIngredients(cycle, ingredients); - } - - return ingredients; - } - - @Override - public boolean preservesNBT() { - return preservesNbt; - } - @Override public PositionedStack getResult() { return this.output; @@ -210,7 +174,6 @@ public class NEIHandlerFabricator extends RecipeHandlerBase { for (IFabricatorRecipe recipe : RecipeManagers.fabricatorManager.recipes()) { if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getRecipeOutput(), result)) { CachedFabricatorRecipe crecipe = new CachedFabricatorRecipe(recipe, true); - NEIUtils.setResultPermutationNBT(crecipe, result); this.arecipes.add(crecipe); } } @@ -223,7 +186,6 @@ public class NEIHandlerFabricator extends RecipeHandlerBase { CachedFabricatorRecipe crecipe = new CachedFabricatorRecipe(recipe); if (crecipe.inputs != null && crecipe.contains(crecipe.inputs, ingred) || crecipe.smeltingInput != null && crecipe.contains(crecipe.smeltingInput, ingred)) { crecipe.generatePermutations(); - NEIUtils.setIngredientPermutationNBT(crecipe, ingred); crecipe.setIngredientPermutation(crecipe.smeltingInput, ingred); this.arecipes.add(crecipe); } @@ -246,7 +208,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase { if (new Rectangle(20, 9, 18, 18).contains(relMouse)) { for (IFabricatorSmeltingRecipe smelting : FabricatorSmeltingRecipeManager.recipes) { if (NEIServerUtils.areStacksSameTypeCrafting(smelting.getResource(), itemStack) && smelting.getProduct() != null) { - currenttip.add(EnumChatFormatting.GRAY.toString() + NEIUtils.translate("handler.forestry.fabricator.worth") + " " + smelting.getProduct().amount + " mB"); + currenttip.add(EnumChatFormatting.GRAY + NEIUtils.translate("handler.forestry.fabricator.worth") + " " + smelting.getProduct().amount + " mB"); } } } diff --git a/src/main/java/forestry/factory/recipes/nei/NEIHandlerFermenter.java b/src/main/java/forestry/factory/recipes/nei/NEIHandlerFermenter.java index ed244a521..9c93073a9 100644 --- a/src/main/java/forestry/factory/recipes/nei/NEIHandlerFermenter.java +++ b/src/main/java/forestry/factory/recipes/nei/NEIHandlerFermenter.java @@ -28,7 +28,6 @@ import forestry.api.recipes.IFermenterRecipe; import forestry.api.recipes.IVariableFermentable; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; -import forestry.core.recipes.nei.INBTMatchingCachedRecipe; import forestry.core.recipes.nei.NEIUtils; import forestry.core.recipes.nei.PositionedFluidTank; import forestry.core.recipes.nei.RecipeHandlerBase; @@ -49,7 +48,7 @@ public class NEIHandlerFermenter extends RecipeHandlerBase { API.setGuiOffset(guiClass, 5, 15); } - public class CachedFermenterRecipe extends CachedBaseRecipe implements INBTMatchingCachedRecipe { + public class CachedFermenterRecipe extends CachedBaseRecipe { public List tanks = new ArrayList<>(); public PositionedStack resource; @@ -87,11 +86,6 @@ public class NEIHandlerFermenter extends RecipeHandlerBase { return this.getCycledIngredients(NEIHandlerFermenter.this.cycleticks / 40, this.inputItems); } - @Override - public boolean preservesNBT() { - return false; - } - @Override public PositionedStack getResult() { return null; @@ -183,7 +177,6 @@ public class NEIHandlerFermenter extends RecipeHandlerBase { for (ItemStack stack : NEIUtils.getItemVariations(recipe.getResource())) { if (stack.hasTagCompound() && NEIServerUtils.areStacksSameType(stack, ingred) || !stack.hasTagCompound() && NEIServerUtils.areStacksSameTypeCrafting(stack, ingred)) { CachedFermenterRecipe crecipe = new CachedFermenterRecipe(recipe, stack, true); - NEIUtils.setIngredientPermutationNBT(crecipe, ingred); this.arecipes.add(crecipe); } } diff --git a/src/main/java/forestry/factory/tiles/TileFabricator.java b/src/main/java/forestry/factory/tiles/TileFabricator.java index af6388ad4..8e1d72125 100644 --- a/src/main/java/forestry/factory/tiles/TileFabricator.java +++ b/src/main/java/forestry/factory/tiles/TileFabricator.java @@ -42,7 +42,6 @@ import forestry.core.items.ICraftingPlan; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.GuiId; -import forestry.core.recipes.RecipeUtil; import forestry.core.tiles.ICrafter; import forestry.core.tiles.ILiquidTankTile; import forestry.core.tiles.TilePowered; @@ -195,7 +194,7 @@ public class TileFabricator extends TilePowered implements ICrafter, ILiquidTank return null; } - return RecipeUtil.getCraftingResult(myRecipe.getRecipeOutput(), myRecipe.preservesNbt(), craftingInventory); + return myRecipe.getRecipeOutput().copy(); } /* ICrafter */ diff --git a/src/main/java/forestry/plugins/PluginArboriculture.java b/src/main/java/forestry/plugins/PluginArboriculture.java index 644608752..af8baa944 100644 --- a/src/main/java/forestry/plugins/PluginArboriculture.java +++ b/src/main/java/forestry/plugins/PluginArboriculture.java @@ -277,35 +277,92 @@ public class PluginArboriculture extends ForestryPlugin { RecipeUtil.addSmelting(ForestryBlock.logs.getWildcard(), new ItemStack(Items.coal, 1, 1), 0.15F); - ShapelessRecipeCustom.buildRecipe(ForestryBlock.planks.getItemStack(4), ForestryBlock.logs.getWildcard()).setPreserveNBT(); - ShapelessRecipeCustom.buildRecipe(ForestryBlock.planksFireproof.getItemStack(4), ForestryBlock.logsFireproof.getWildcard()).setPreserveNBT(); + for (EnumWoodType woodType : EnumWoodType.VALUES) { - // Fabricator recipes - if (PluginManager.Module.FACTORY.isEnabled() && PluginManager.Module.APICULTURE.isEnabled()) { + ItemStack planks = TreeManager.woodItemAccess.getPlanks(woodType, false); + ItemStack logs = TreeManager.woodItemAccess.getLog(woodType, false); + ItemStack slabs = TreeManager.woodItemAccess.getSlab(woodType, false); + ItemStack fences = TreeManager.woodItemAccess.getFence(woodType, false); + ItemStack stairs = TreeManager.woodItemAccess.getStairs(woodType, false); - // Fireproof log recipe - RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), ForestryBlock.logsFireproof.getItemStack(), new Object[]{ - " # ", + ItemStack fireproofPlanks = TreeManager.woodItemAccess.getPlanks(woodType, true); + ItemStack fireproofLogs = TreeManager.woodItemAccess.getLog(woodType, true); + ItemStack fireproofSlabs = TreeManager.woodItemAccess.getSlab(woodType, true); + ItemStack fireproofFences = TreeManager.woodItemAccess.getFence(woodType, true); + ItemStack fireproofStairs = TreeManager.woodItemAccess.getStairs(woodType, true); + + planks.stackSize = 4; + logs.stackSize = 1; + ShapelessRecipeCustom.buildRecipe(planks.copy(), logs.copy()); + + fireproofPlanks.stackSize = 4; + fireproofLogs.stackSize = 1; + ShapelessRecipeCustom.buildRecipe(fireproofPlanks.copy(), fireproofLogs.copy()); + + slabs.stackSize = 6; + planks.stackSize = 1; + ShapedRecipeCustom.buildPriorityRecipe(slabs.copy(), + "###", + '#', planks.copy()); + + fireproofSlabs.stackSize = 6; + fireproofPlanks.stackSize = 1; + ShapedRecipeCustom.buildPriorityRecipe(fireproofSlabs.copy(), + "###", + '#', fireproofPlanks.copy()); + + fences.stackSize = 3; + planks.stackSize = 1; + ShapedRecipeCustom.buildRecipe(fences.copy(), "#X#", - " # ", - '#', ForestryItem.refractoryWax, - 'X', ForestryBlock.logs.getWildcard()}).setPreserveNBT()); - - // Fireproof plank recipe - RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), ForestryBlock.planksFireproof.getItemStack(5), new Object[]{ - "X#X", "#X#", - "X#X", - '#', ForestryItem.refractoryWax, - 'X', ForestryBlock.planks.getWildcard()}).setPreserveNBT()); + '#', planks.copy(), 'X', "stickWood"); + + fireproofFences.stackSize = 3; + fireproofPlanks.stackSize = 1; + ShapedRecipeCustom.buildRecipe(fireproofFences.copy(), + "#X#", + "#X#", + '#', fireproofPlanks.copy(), 'X', "stickWood"); + + stairs.stackSize = 4; + planks.stackSize = 1; + ShapedRecipeCustom.buildPriorityRecipe(stairs.copy(), + "# ", + "## ", + "###", + '#', planks.copy()); + + fireproofStairs.stackSize = 4; + fireproofPlanks.stackSize = 1; + ShapedRecipeCustom.buildPriorityRecipe(fireproofStairs.copy(), + "# ", + "## ", + "###", + '#', fireproofPlanks.copy()); + + // Fabricator recipes + if (PluginManager.Module.FACTORY.isEnabled() && PluginManager.Module.APICULTURE.isEnabled()) { + logs.stackSize = 1; + fireproofLogs.stackSize = 1; + RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), fireproofLogs.copy(), new Object[]{ + " # ", + "#X#", + " # ", + '#', ForestryItem.refractoryWax, + 'X', logs.copy()})); + + planks.stackSize = 1; + fireproofPlanks.stackSize = 5; + RecipeManagers.fabricatorManager.addRecipe(new FabricatorRecipe(null, Fluids.GLASS.getFluid(500), fireproofPlanks.copy(), new Object[]{ + "X#X", + "#X#", + "X#X", + '#', ForestryItem.refractoryWax, + 'X', planks.copy()})); + } } - ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.slabs.getItemStack(6), "###", '#', ForestryBlock.planks.getWildcard()).setPreserveNBT(); - ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.slabsFireproof.getItemStack(6), "###", '#', ForestryBlock.planksFireproof.getWildcard()).setPreserveNBT(); - - ShapedRecipeCustom.buildRecipe(ForestryBlock.fences.getItemStack(3), "#X#", "#X#", '#', ForestryBlock.planks.getWildcard(), 'X', "stickWood").setPreserveNBT(); - ShapedRecipeCustom.buildRecipe(ForestryBlock.fencesFireproof.getItemStack(3), "#X#", "#X#", '#', ForestryBlock.planksFireproof.getWildcard(), 'X', "stickWood").setPreserveNBT(); - if (PluginManager.Module.FACTORY.isEnabled()) { // Treealyzer RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR", @@ -329,19 +386,6 @@ public class PluginArboriculture extends ForestryPlugin { RecipeUtil.addFermenterRecipes(ForestryItem.sapling.getItemStack(), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); } - // Stairs - ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.stairs.getItemStack(4), - "# ", - "## ", - "###", - '#', ForestryBlock.planks.getWildcard()).setPreserveNBT(); - - ShapedRecipeCustom.buildPriorityRecipe(ForestryBlock.stairsFireproof.getItemStack(4), - "# ", - "## ", - "###", - '#', ForestryBlock.planksFireproof.getWildcard()).setPreserveNBT(); - // Grafter RecipeUtil.addRecipe(ForestryItem.grafter.getItemStack(), " B", diff --git a/src/main/java/forestry/plugins/PluginFarming.java b/src/main/java/forestry/plugins/PluginFarming.java index 09279ea19..cc519ee17 100644 --- a/src/main/java/forestry/plugins/PluginFarming.java +++ b/src/main/java/forestry/plugins/PluginFarming.java @@ -292,29 +292,24 @@ public class PluginFarming extends ForestryPlugin { protected void registerRecipes() { ItemStack basic = ForestryBlock.farm.getItemStack(1, 0); + ItemStack gearbox = ForestryBlock.farm.getItemStack(1, 2); + ItemStack hatch = ForestryBlock.farm.getItemStack(1, 3); + ItemStack valve = ForestryBlock.farm.getItemStack(1, 4); + ItemStack control = ForestryBlock.farm.getItemStack(1, 5); + for (EnumFarmBlockTexture block : EnumFarmBlockTexture.values()) { NBTTagCompound compound = new NBTTagCompound(); block.saveToCompound(compound); basic.setTagCompound((NBTTagCompound) compound.copy()); ShapedRecipeCustom.buildRecipe(basic.copy(), "I#I", "WCW", '#', block.getBase(), 'W', "slabWood", 'C', ForestryItem.tubes.getItemStack(1, 1), 'I', "ingotCopper"); + + ShapedRecipeCustom.buildRecipe(gearbox, " # ", "TTT", '#', basic, 'T', "gearTin"); + ShapedRecipeCustom.buildRecipe(hatch, " # ", "TDT", '#', basic, 'T', "gearTin", 'D', Blocks.trapdoor); + ShapedRecipeCustom.buildRecipe(valve, " # ", "XTX", '#', basic, 'T', "gearTin", 'X', "blockGlass"); + ShapedRecipeCustom.buildRecipe(control, " # ", "XTX", '#', basic, 'T', ForestryItem.tubes.getItemStack(1, 4), 'X', "dustRedstone"); } - // use wildcard (null) NBT for the basic ingredient so that any basic type can be used - ItemStack basicWildcard = ForestryBlock.farm.getItemStack(1, 0); - - ItemStack gearbox = ForestryBlock.farm.getItemStack(1, 2); - ShapedRecipeCustom.buildRecipe(gearbox, " # ", "TTT", '#', basicWildcard, 'T', "gearTin").setPreserveNBT(); - - ItemStack hatch = ForestryBlock.farm.getItemStack(1, 3); - ShapedRecipeCustom.buildRecipe(hatch, " # ", "TDT", '#', basicWildcard, 'T', "gearTin", 'D', Blocks.trapdoor).setPreserveNBT(); - - ItemStack valve = ForestryBlock.farm.getItemStack(1, 4); - ShapedRecipeCustom.buildRecipe(valve, " # ", "XTX", '#', basicWildcard, 'T', "gearTin", 'X', "blockGlass").setPreserveNBT(); - - ItemStack control = ForestryBlock.farm.getItemStack(1, 5); - ShapedRecipeCustom.buildRecipe(control, " # ", "XTX", '#', basicWildcard, 'T', ForestryItem.tubes.getItemStack(1, 4), 'X', "dustRedstone").setPreserveNBT(); - // Circuits ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual");