From ecb81a7017696c1b8d6ff561a6e06980b44cfd2d Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Sat, 10 Mar 2018 00:07:19 -0800 Subject: [PATCH] A bit more altar cleanup --- .../WayofTime/bloodmagic/altar/AltarTier.java | 168 ++++++++++-------- .../WayofTime/bloodmagic/altar/AltarUtil.java | 8 +- .../bloodmagic/altar/BloodAltar.java | 8 - .../bloodmagic/block/BlockAltar.java | 9 +- .../client/render/block/RenderAltar.java | 13 +- .../java/WayofTime/bloodmagic/util/Utils.java | 10 +- 6 files changed, 108 insertions(+), 108 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/altar/AltarTier.java b/src/main/java/WayofTime/bloodmagic/altar/AltarTier.java index df88e59c..d940e6ab 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/AltarTier.java +++ b/src/main/java/WayofTime/bloodmagic/altar/AltarTier.java @@ -1,138 +1,148 @@ package WayofTime.bloodmagic.altar; +import com.google.common.collect.Lists; import net.minecraft.util.math.BlockPos; -import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; -//@formatter:off public enum AltarTier { - ONE(), TWO() { + ONE() { @Override - public void buildComponents() { - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE)); - altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE)); - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE)); - altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE)); + public void buildComponents(Consumer components) { + // Nada + } + }, TWO() { + @Override + public void buildComponents(Consumer components) { + components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE)); + components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE)); + components.accept(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE)); + components.accept(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE)); } }, THREE() { @Override - public void buildComponents() { - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-3, -1, -3))); - altarComponents.add(new AltarComponent(new BlockPos(-3, 0, -3))); - altarComponents.add(new AltarComponent(new BlockPos(3, -1, -3))); - altarComponents.add(new AltarComponent(new BlockPos(3, 0, -3))); - altarComponents.add(new AltarComponent(new BlockPos(-3, -1, 3))); - altarComponents.add(new AltarComponent(new BlockPos(-3, 0, 3))); - altarComponents.add(new AltarComponent(new BlockPos(3, -1, 3))); - altarComponents.add(new AltarComponent(new BlockPos(3, 0, 3))); - altarComponents.add(new AltarComponent(new BlockPos(-3, 1, -3), ComponentType.GLOWSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(3, 1, -3), ComponentType.GLOWSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), ComponentType.GLOWSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), ComponentType.GLOWSTONE)); + public void buildComponents(Consumer components) { + // Doesn't pull from tier 2 because upgrades slots are different + components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-3, -1, -3))); + components.accept(new AltarComponent(new BlockPos(-3, 0, -3))); + components.accept(new AltarComponent(new BlockPos(3, -1, -3))); + components.accept(new AltarComponent(new BlockPos(3, 0, -3))); + components.accept(new AltarComponent(new BlockPos(-3, -1, 3))); + components.accept(new AltarComponent(new BlockPos(-3, 0, 3))); + components.accept(new AltarComponent(new BlockPos(3, -1, 3))); + components.accept(new AltarComponent(new BlockPos(3, 0, 3))); + components.accept(new AltarComponent(new BlockPos(-3, 1, -3), ComponentType.GLOWSTONE)); + components.accept(new AltarComponent(new BlockPos(3, 1, -3), ComponentType.GLOWSTONE)); + components.accept(new AltarComponent(new BlockPos(-3, 1, 3), ComponentType.GLOWSTONE)); + components.accept(new AltarComponent(new BlockPos(3, 1, 3), ComponentType.GLOWSTONE)); for (int i = -2; i <= 2; i++) { - altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -2, -3), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -2, 3), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -2, -3), ComponentType.BLOODRUNE).setUpgradeSlot()); } } }, FOUR() { @Override - public void buildComponents() { - altarComponents.addAll(THREE.getAltarComponents()); + public void buildComponents(Consumer components) { + THREE.getAltarComponents().forEach(components); for (int i = -3; i <= 3; i++) { - altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -3, 5), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -3, -5), ComponentType.BLOODRUNE).setUpgradeSlot()); } for (int i = -2; i <= 1; i++) { - altarComponents.add(new AltarComponent(new BlockPos(5, i, 5))); - altarComponents.add(new AltarComponent(new BlockPos(5, i, -5))); - altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5))); - altarComponents.add(new AltarComponent(new BlockPos(-5, i, 5))); + components.accept(new AltarComponent(new BlockPos(5, i, 5))); + components.accept(new AltarComponent(new BlockPos(5, i, -5))); + components.accept(new AltarComponent(new BlockPos(-5, i, -5))); + components.accept(new AltarComponent(new BlockPos(-5, i, 5))); } - altarComponents.add(new AltarComponent(new BlockPos(5, 2, 5), ComponentType.BLOODSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(5, 2, -5), ComponentType.BLOODSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(-5, 2, -5), ComponentType.BLOODSTONE)); - altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), ComponentType.BLOODSTONE)); + components.accept(new AltarComponent(new BlockPos(5, 2, 5), ComponentType.BLOODSTONE)); + components.accept(new AltarComponent(new BlockPos(5, 2, -5), ComponentType.BLOODSTONE)); + components.accept(new AltarComponent(new BlockPos(-5, 2, -5), ComponentType.BLOODSTONE)); + components.accept(new AltarComponent(new BlockPos(-5, 2, 5), ComponentType.BLOODSTONE)); } }, FIVE() { @Override - public void buildComponents() { - altarComponents.addAll(FOUR.getAltarComponents()); - altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), ComponentType.BEACON)); - altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), ComponentType.BEACON)); - altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), ComponentType.BEACON)); - altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), ComponentType.BEACON)); + public void buildComponents(Consumer components) { + FOUR.getAltarComponents().forEach(components); + components.accept(new AltarComponent(new BlockPos(-8, -3, 8), ComponentType.BEACON)); + components.accept(new AltarComponent(new BlockPos(-8, -3, -8), ComponentType.BEACON)); + components.accept(new AltarComponent(new BlockPos(8, -3, -8), ComponentType.BEACON)); + components.accept(new AltarComponent(new BlockPos(8, -3, 8), ComponentType.BEACON)); for (int i = -6; i <= 6; i++) { - altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -4, -8), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -4, 8), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -4, -8), ComponentType.BLOODRUNE).setUpgradeSlot()); } } }, SIX() { @Override - public void buildComponents() { - altarComponents.addAll(FIVE.getAltarComponents()); + public void buildComponents(Consumer components) { + FIVE.getAltarComponents().forEach(components); for (int i = -4; i <= 2; i++) { - altarComponents.add(new AltarComponent(new BlockPos(11, i, 11))); - altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11))); - altarComponents.add(new AltarComponent(new BlockPos(11, i, -11))); - altarComponents.add(new AltarComponent(new BlockPos(-11, i, 11))); + components.accept(new AltarComponent(new BlockPos(11, i, 11))); + components.accept(new AltarComponent(new BlockPos(-11, i, -11))); + components.accept(new AltarComponent(new BlockPos(11, i, -11))); + components.accept(new AltarComponent(new BlockPos(-11, i, 11))); } - altarComponents.add(new AltarComponent(new BlockPos(11, 3, 11), ComponentType.CRYSTAL)); - altarComponents.add(new AltarComponent(new BlockPos(-11, 3, -11), ComponentType.CRYSTAL)); - altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), ComponentType.CRYSTAL)); - altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), ComponentType.CRYSTAL)); + components.accept(new AltarComponent(new BlockPos(11, 3, 11), ComponentType.CRYSTAL)); + components.accept(new AltarComponent(new BlockPos(-11, 3, -11), ComponentType.CRYSTAL)); + components.accept(new AltarComponent(new BlockPos(11, 3, -11), ComponentType.CRYSTAL)); + components.accept(new AltarComponent(new BlockPos(-11, 3, 11), ComponentType.CRYSTAL)); for (int i = -9; i <= 9; i++) { - altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), ComponentType.BLOODRUNE).setUpgradeSlot()); - altarComponents.add(new AltarComponent(new BlockPos(i, -5, -11), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(-11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -5, 11), ComponentType.BLOODRUNE).setUpgradeSlot()); + components.accept(new AltarComponent(new BlockPos(i, -5, -11), ComponentType.BLOODRUNE).setUpgradeSlot()); } } -//@formatter:on }; public static final int MAXTIERS = values().length; - ArrayList altarComponents = new ArrayList<>(); + private List altarComponents; - public void buildComponents() { + AltarTier() { + this.altarComponents = Lists.newArrayList(); + buildComponents(altarComponents::add); } + public abstract void buildComponents(Consumer components); + public int toInt() { return ordinal() + 1; } - public ArrayList getAltarComponents() { + public List getAltarComponents() { return altarComponents; } } diff --git a/src/main/java/WayofTime/bloodmagic/altar/AltarUtil.java b/src/main/java/WayofTime/bloodmagic/altar/AltarUtil.java index 845f9051..7519c870 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/AltarUtil.java +++ b/src/main/java/WayofTime/bloodmagic/altar/AltarUtil.java @@ -25,7 +25,13 @@ public class AltarUtil { AltarTier lastCheck = AltarTier.ONE; for (AltarTier tier : AltarTier.values()) { for (AltarComponent component : tier.getAltarComponents()) { - IBlockState worldState = world.getBlockState(pos.add(component.getOffset())); + BlockPos componentPos = pos.add(component.getOffset()); + IBlockState worldState = world.getBlockState(componentPos); + + if (worldState.getBlock() instanceof IAltarComponent) + if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent()) + continue; + if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR && !worldState.getMaterial().isLiquid()) continue; diff --git a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java index 39ccbf9c..0cb9b8f7 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java @@ -31,14 +31,6 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.items.ItemHandlerHelper; public class BloodAltar implements IFluidHandler { - static { - AltarTier.ONE.buildComponents(); - AltarTier.TWO.buildComponents(); - AltarTier.THREE.buildComponents(); - AltarTier.FOUR.buildComponents(); - AltarTier.FIVE.buildComponents(); - AltarTier.SIX.buildComponents(); - } public boolean isActive; protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); diff --git a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java index 2312acab..39fe58e1 100644 --- a/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java +++ b/src/main/java/WayofTime/bloodmagic/block/BlockAltar.java @@ -117,7 +117,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl if (altar == null || player.isSneaking()) return false; - ItemStack playerItem = player.inventory.getCurrentItem(); + ItemStack playerItem = player.getHeldItem(hand); if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) { playerItem.getItem().onItemRightClick(world, player, hand); @@ -136,11 +136,8 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl @Override public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { TileEntity tile = world.getTileEntity(blockPos); - if (tile instanceof TileAltar) { - TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos); - if (tileAltar != null) - tileAltar.dropItems(); - } + if (tile instanceof TileAltar) + ((TileAltar) tile).dropItems(); super.breakBlock(world, blockPos, blockState); } diff --git a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java index 0246341a..2dba9db8 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/block/RenderAltar.java @@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; @@ -22,10 +21,8 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; public class RenderAltar extends TileEntitySpecialRenderer { - public static Minecraft mc = Minecraft.getMinecraft(); - public static ResourceLocation resource = new ResourceLocation("bloodmagic", "textures/blocks/lifeEssenceStill.png"); - public static float minHeight = 0.499f; - public static float maxHeight = 0.745f; + private static final float MIN_HEIGHT = 0.499f; + private static final float MAX_HEIGHT = 0.745f; @Override public void render(TileAltar tileAltar, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { @@ -50,7 +47,7 @@ public class RenderAltar extends TileEntitySpecialRenderer { Fluid fluid = BlockLifeEssence.getLifeEssence(); FluidStack fluidStack = new FluidStack(fluid, 1000); - GlStateManager.translate(0.5, minHeight + (fluidLevel) * (maxHeight - minHeight), 0.5); + GlStateManager.translate(0.5, MIN_HEIGHT + (fluidLevel) * (MAX_HEIGHT - MIN_HEIGHT), 0.5); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder wr = tessellator.getBuffer(); @@ -81,7 +78,7 @@ public class RenderAltar extends TileEntitySpecialRenderer { } private void renderItem(ItemStack stack) { - RenderItem itemRenderer = mc.getRenderItem(); + RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem(); if (!stack.isEmpty()) { GlStateManager.translate(0.5, 1, 0.5); GlStateManager.pushMatrix(); @@ -103,7 +100,7 @@ public class RenderAltar extends TileEntitySpecialRenderer { } private void renderHologram(TileAltar altar, AltarTier tier, float partialTicks) { - EntityPlayerSP player = mc.player; + EntityPlayerSP player = Minecraft.getMinecraft().player; World world = player.world; if (tier == AltarTier.ONE) diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index 052977db..33fbff01 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -270,17 +270,15 @@ public class Utils { * otherwise */ public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) { - if (tile.getStackInSlot(slot).isEmpty() && !player.getHeldItemMainhand().isEmpty()) { + ItemStack slotStack = tile.getStackInSlot(slot); + if (slotStack.isEmpty() && !player.getHeldItemMainhand().isEmpty()) { ItemStack input = player.getHeldItemMainhand().copy(); input.setCount(1); player.getHeldItemMainhand().shrink(1); tile.setInventorySlotContents(slot, input); return true; - } else if (!tile.getStackInSlot(slot).isEmpty() && player.getHeldItemMainhand().isEmpty()) { - if (!tile.getWorld().isRemote) { - EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(slot)); - tile.getWorld().spawnEntity(invItem); - } + } else if (!slotStack.isEmpty() && player.getHeldItemMainhand().isEmpty()) { + ItemHandlerHelper.giveItemToPlayer(player, slotStack); tile.clear(); return false; }