From 416738e991e454a13e03002402cf1162b4089318 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 27 Aug 2018 10:30:27 -1000 Subject: [PATCH 1/2] Resize and reorient Tiny Potatoes held as equipment by other Tiny Potatoes (#2722) Also adjusts the placement of any blocks on the top side of the potato such that they rest flatly on the potato's head. --- .../render/tile/RenderTileTinyPotato.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java index 4b2c544f8..fda13ce44 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java @@ -41,6 +41,7 @@ import vazkii.botania.client.model.ModelTinyPotato; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileTinyPotato; import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.block.ItemBlockTinyPotato; import vazkii.botania.common.item.equipment.bauble.ItemBaubleCosmetic; import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; @@ -173,44 +174,61 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer Date: Mon, 27 Aug 2018 22:30:47 +0200 Subject: [PATCH 2/2] Fix Alfheim portal storing items not used in recipes (#2721) * Fix #2403 (Alfheim portal storing items not used in recipes) Possibly mitigates #2669, as recipe checks are a bit simplified to not create stack copies posting capability events and the portal will not check items with no uses more than once. * Don't teleport bread, Bord. --- .../botania/api/recipe/RecipeElvenTrade.java | 6 +--- .../common/block/tile/TileAlfPortal.java | 30 ++++++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java index e5ebdbfc7..3c65b8262 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -44,11 +44,7 @@ public class RecipeElvenTrade { List validStacks = OreDictionary.getOres((String) input); boolean found = false; for(ItemStack ostack : validStacks) { - ItemStack cstack = ostack.copy(); - if(cstack.getItemDamage() == Short.MAX_VALUE) - cstack.setItemDamage(stack.getItemDamage()); - - if(stack.isItemEqual(cstack)) { + if(OreDictionary.itemMatches(ostack, stack, false)) { if(!stacksToRemove.contains(stack)) stacksToRemove.add(stack); oredictIndex = j; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java index 6fe7fa41c..187e75cfa 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java @@ -14,6 +14,7 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -21,6 +22,7 @@ import net.minecraft.util.ITickable; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.oredict.OreDictionary; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.multiblock.Multiblock; @@ -74,6 +76,7 @@ public class TileAlfPortal extends TileMod implements ITickable { public int ticksOpen = 0; private int ticksSinceLastItem = 0; private boolean closeNow = false; + private boolean explode = false; private static final Function CONVERTER_X_Z = input -> new BlockPos(input.getZ(), input.getY(), input.getX()); @@ -141,7 +144,8 @@ public class TileAlfPortal extends TileMod implements ITickable { if (consume) { item.setDead(); - addItem(stack); + if (validateItemUsage(stack)) + addItem(stack); ticksSinceLastItem = 0; } } @@ -162,9 +166,33 @@ public class TileAlfPortal extends TileMod implements ITickable { for(int i = 0; i < 36; i++) blockParticle(state); world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.ALFPORTAL_STATE, newState), 1 | 2); + } else if(explode) { + world.createExplosion(null, pos.getX() + .5, pos.getY() + 2.0, pos.getZ() + .5, 3f, true); + explode = false; } } + private boolean validateItemUsage(ItemStack inputStack) { + for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { + for(Object o : recipe.getInputs()) { + if(o instanceof String) { + for(ItemStack target : OreDictionary.getOres((String) o)) { + if(OreDictionary.itemMatches(target, inputStack, false)) + return true; + } + } else if(o instanceof ItemStack) { + ItemStack target = (ItemStack) o; + if(inputStack.getItem() == target.getItem() && inputStack.getItemDamage() == target.getItemDamage()) + return true; + } + } + } + if(inputStack.getItem() == Items.BREAD) //Don't teleport bread. (See also: #2403) + explode = true; + + return false; + } + private void blockParticle(AlfPortalState state) { int i = world.rand.nextInt(AIR_POSITIONS.length); double[] pos = new double[] {