A bit more altar cleanup

This commit is contained in:
Nicholas Ignoffo 2018-03-10 00:07:19 -08:00
parent e2d2ecb3ba
commit ecb81a7017
6 changed files with 108 additions and 108 deletions

View file

@ -1,138 +1,148 @@
package WayofTime.bloodmagic.altar; package WayofTime.bloodmagic.altar;
import com.google.common.collect.Lists;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import java.util.ArrayList; import java.util.List;
import java.util.function.Consumer;
//@formatter:off
public enum AltarTier { public enum AltarTier {
ONE(), TWO() { ONE() {
@Override @Override
public void buildComponents() { public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE)); // Nada
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); }
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE)); }, TWO() {
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); @Override
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE)); components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE));
altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE)); 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() { THREE() {
@Override @Override
public void buildComponents() { public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); // Doesn't pull from tier 2 because upgrades slots are different
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-3, -1, -3))); components.accept(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-3, 0, -3))); components.accept(new AltarComponent(new BlockPos(-3, -1, -3)));
altarComponents.add(new AltarComponent(new BlockPos(3, -1, -3))); components.accept(new AltarComponent(new BlockPos(-3, 0, -3)));
altarComponents.add(new AltarComponent(new BlockPos(3, 0, -3))); components.accept(new AltarComponent(new BlockPos(3, -1, -3)));
altarComponents.add(new AltarComponent(new BlockPos(-3, -1, 3))); components.accept(new AltarComponent(new BlockPos(3, 0, -3)));
altarComponents.add(new AltarComponent(new BlockPos(-3, 0, 3))); components.accept(new AltarComponent(new BlockPos(-3, -1, 3)));
altarComponents.add(new AltarComponent(new BlockPos(3, -1, 3))); components.accept(new AltarComponent(new BlockPos(-3, 0, 3)));
altarComponents.add(new AltarComponent(new BlockPos(3, 0, 3))); components.accept(new AltarComponent(new BlockPos(3, -1, 3)));
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, -3), ComponentType.GLOWSTONE)); components.accept(new AltarComponent(new BlockPos(3, 0, 3)));
altarComponents.add(new AltarComponent(new BlockPos(3, 1, -3), ComponentType.GLOWSTONE)); components.accept(new AltarComponent(new BlockPos(-3, 1, -3), ComponentType.GLOWSTONE));
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), ComponentType.GLOWSTONE)); components.accept(new AltarComponent(new BlockPos(3, 1, -3), ComponentType.GLOWSTONE));
altarComponents.add(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++) { for (int i = -2; i <= 2; i++) {
altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(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(i, -2, -3), ComponentType.BLOODRUNE).setUpgradeSlot());
} }
} }
}, },
FOUR() { FOUR() {
@Override @Override
public void buildComponents() { public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.addAll(THREE.getAltarComponents()); THREE.getAltarComponents().forEach(components);
for (int i = -3; i <= 3; i++) { for (int i = -3; i <= 3; i++) {
altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(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(i, -3, -5), ComponentType.BLOODRUNE).setUpgradeSlot());
} }
for (int i = -2; i <= 1; i++) { for (int i = -2; i <= 1; i++) {
altarComponents.add(new AltarComponent(new BlockPos(5, i, 5))); components.accept(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)));
altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5))); components.accept(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)));
} }
altarComponents.add(new AltarComponent(new BlockPos(5, 2, 5), ComponentType.BLOODSTONE)); components.accept(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));
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, -5), ComponentType.BLOODSTONE)); components.accept(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));
} }
}, },
FIVE() { FIVE() {
@Override @Override
public void buildComponents() { public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.addAll(FOUR.getAltarComponents()); FOUR.getAltarComponents().forEach(components);
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), ComponentType.BEACON)); components.accept(new AltarComponent(new BlockPos(-8, -3, 8), ComponentType.BEACON));
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), ComponentType.BEACON)); components.accept(new AltarComponent(new BlockPos(-8, -3, -8), ComponentType.BEACON));
altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), ComponentType.BEACON)); components.accept(new AltarComponent(new BlockPos(8, -3, -8), ComponentType.BEACON));
altarComponents.add(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++) { for (int i = -6; i <= 6; i++) {
altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(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(i, -4, -8), ComponentType.BLOODRUNE).setUpgradeSlot());
} }
} }
}, },
SIX() { SIX() {
@Override @Override
public void buildComponents() { public void buildComponents(Consumer<AltarComponent> components) {
altarComponents.addAll(FIVE.getAltarComponents()); FIVE.getAltarComponents().forEach(components);
for (int i = -4; i <= 2; i++) { for (int i = -4; i <= 2; i++) {
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11))); components.accept(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)));
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11))); components.accept(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)));
} }
altarComponents.add(new AltarComponent(new BlockPos(11, 3, 11), ComponentType.CRYSTAL)); components.accept(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));
altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), ComponentType.CRYSTAL)); components.accept(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));
for (int i = -9; i <= 9; i++) { for (int i = -9; i <= 9; i++) {
altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(new AltarComponent(new BlockPos(-11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot());
altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), ComponentType.BLOODRUNE).setUpgradeSlot()); components.accept(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(i, -5, -11), ComponentType.BLOODRUNE).setUpgradeSlot());
} }
} }
//@formatter:on
}; };
public static final int MAXTIERS = values().length; public static final int MAXTIERS = values().length;
ArrayList<AltarComponent> altarComponents = new ArrayList<>(); private List<AltarComponent> altarComponents;
public void buildComponents() { AltarTier() {
this.altarComponents = Lists.newArrayList();
buildComponents(altarComponents::add);
} }
public abstract void buildComponents(Consumer<AltarComponent> components);
public int toInt() { public int toInt() {
return ordinal() + 1; return ordinal() + 1;
} }
public ArrayList<AltarComponent> getAltarComponents() { public List<AltarComponent> getAltarComponents() {
return altarComponents; return altarComponents;
} }
} }

View file

@ -25,7 +25,13 @@ public class AltarUtil {
AltarTier lastCheck = AltarTier.ONE; AltarTier lastCheck = AltarTier.ONE;
for (AltarTier tier : AltarTier.values()) { for (AltarTier tier : AltarTier.values()) {
for (AltarComponent component : tier.getAltarComponents()) { 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()) if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR && !worldState.getMaterial().isLiquid())
continue; continue;

View file

@ -31,14 +31,6 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
public class BloodAltar implements IFluidHandler { 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; public boolean isActive;
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0); protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);

View file

@ -117,7 +117,7 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl
if (altar == null || player.isSneaking()) if (altar == null || player.isSneaking())
return false; return false;
ItemStack playerItem = player.inventory.getCurrentItem(); ItemStack playerItem = player.getHeldItem(hand);
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) { if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
playerItem.getItem().onItemRightClick(world, player, hand); playerItem.getItem().onItemRightClick(world, player, hand);
@ -136,11 +136,8 @@ public class BlockAltar extends Block implements IVariantProvider, IDocumentedBl
@Override @Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) { public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
TileEntity tile = world.getTileEntity(blockPos); TileEntity tile = world.getTileEntity(blockPos);
if (tile instanceof TileAltar) { if (tile instanceof TileAltar)
TileAltar tileAltar = (TileAltar) world.getTileEntity(blockPos); ((TileAltar) tile).dropItems();
if (tileAltar != null)
tileAltar.dropItems();
}
super.breakBlock(world, blockPos, blockState); super.breakBlock(world, blockPos, blockState);
} }

View file

@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
@ -22,10 +21,8 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class RenderAltar extends TileEntitySpecialRenderer<TileAltar> { public class RenderAltar extends TileEntitySpecialRenderer<TileAltar> {
public static Minecraft mc = Minecraft.getMinecraft(); private static final float MIN_HEIGHT = 0.499f;
public static ResourceLocation resource = new ResourceLocation("bloodmagic", "textures/blocks/lifeEssenceStill.png"); private static final float MAX_HEIGHT = 0.745f;
public static float minHeight = 0.499f;
public static float maxHeight = 0.745f;
@Override @Override
public void render(TileAltar tileAltar, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { 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<TileAltar> {
Fluid fluid = BlockLifeEssence.getLifeEssence(); Fluid fluid = BlockLifeEssence.getLifeEssence();
FluidStack fluidStack = new FluidStack(fluid, 1000); 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(); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder wr = tessellator.getBuffer(); BufferBuilder wr = tessellator.getBuffer();
@ -81,7 +78,7 @@ public class RenderAltar extends TileEntitySpecialRenderer<TileAltar> {
} }
private void renderItem(ItemStack stack) { private void renderItem(ItemStack stack) {
RenderItem itemRenderer = mc.getRenderItem(); RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
GlStateManager.translate(0.5, 1, 0.5); GlStateManager.translate(0.5, 1, 0.5);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
@ -103,7 +100,7 @@ public class RenderAltar extends TileEntitySpecialRenderer<TileAltar> {
} }
private void renderHologram(TileAltar altar, AltarTier tier, float partialTicks) { private void renderHologram(TileAltar altar, AltarTier tier, float partialTicks) {
EntityPlayerSP player = mc.player; EntityPlayerSP player = Minecraft.getMinecraft().player;
World world = player.world; World world = player.world;
if (tier == AltarTier.ONE) if (tier == AltarTier.ONE)

View file

@ -270,17 +270,15 @@ public class Utils {
* otherwise * otherwise
*/ */
public static boolean insertItemToTile(TileInventory tile, EntityPlayer player, int slot) { 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(); ItemStack input = player.getHeldItemMainhand().copy();
input.setCount(1); input.setCount(1);
player.getHeldItemMainhand().shrink(1); player.getHeldItemMainhand().shrink(1);
tile.setInventorySlotContents(slot, input); tile.setInventorySlotContents(slot, input);
return true; return true;
} else if (!tile.getStackInSlot(slot).isEmpty() && player.getHeldItemMainhand().isEmpty()) { } else if (!slotStack.isEmpty() && player.getHeldItemMainhand().isEmpty()) {
if (!tile.getWorld().isRemote) { ItemHandlerHelper.giveItemToPlayer(player, slotStack);
EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(slot));
tile.getWorld().spawnEntity(invItem);
}
tile.clear(); tile.clear();
return false; return false;
} }