From 1c08afde7ea0fd4e35b372abf6370817ddadf68a Mon Sep 17 00:00:00 2001 From: Henry Mao Date: Sat, 26 Jan 2013 21:40:57 +0800 Subject: [PATCH] Better Crate Controls --- .../assemblyline/common/block/BlockCrate.java | 78 ++++--------------- .../common/block/TileEntityCrate.java | 16 +--- 2 files changed, 16 insertions(+), 78 deletions(-) diff --git a/src/minecraft/assemblyline/common/block/BlockCrate.java b/src/minecraft/assemblyline/common/block/BlockCrate.java index 962adecc..925858e9 100644 --- a/src/minecraft/assemblyline/common/block/BlockCrate.java +++ b/src/minecraft/assemblyline/common/block/BlockCrate.java @@ -42,53 +42,29 @@ public class BlockCrate extends BlockMachine if (side == ForgeDirection.UP.ordinal()) { - if (tileEntity != null) - { - if (tileEntity instanceof IFilterable) - { - ItemStack containingStack = ((IFilterable) tileEntity).getFilter(); - - if (containingStack != null) - { - if (!world.isRemote) - { - EntityItem dropStack = new EntityItem(world, player.posX, player.posY, player.posZ, containingStack); - dropStack.delayBeforeCanPickup = 0; - world.spawnEntityInWorld(dropStack); - } - - ((IFilterable) tileEntity).setFilter(null); - return true; - } - else - { - if (player.getCurrentEquippedItem() != null) - { - if (player.getCurrentEquippedItem().getItem() instanceof ItemImprinter) - { - ((IFilterable) tileEntity).setFilter(player.getCurrentEquippedItem()); - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - return true; - } - } - } - - } - } + this.insertCurrentItem(tileEntity, player); } - - if (side > 1 && hitY > 0.7) + else if (side == ForgeDirection.DOWN.ordinal()) { - return this.insertAllItems(tileEntity, player); + this.ejectItems(tileEntity, player, 64); } else { - return this.insertCurrentItem(tileEntity, player); + if (hitY > 0.5) + { + this.insertCurrentItem(tileEntity, player); + // return this.insertAllItems(tileEntity, player); + } + else + { + this.ejectItems(tileEntity, player, 64); + // return this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT); + } } } - return false; + return true; } @Override @@ -238,32 +214,6 @@ public class BlockCrate extends BlockMachine return itemStack; } - /** - * Drops the crate as a block that stores items within it. - */ - @Override - public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) - { - if (world.getBlockTileEntity(x, y, z) != null) - { - TileEntityCrate tileEntity = (TileEntityCrate) world.getBlockTileEntity(x, y, z); - - if (player.getCurrentEquippedItem() == null) - { - /** - * Eject all items if clicked on the top 30% of the block. - */ - if (side > 1 && hitY > 0.7) - { - return this.ejectItems(tileEntity, player, TileEntityCrate.MAX_LIMIT); - } - else if (side != ForgeDirection.UP.ordinal()) { return this.ejectItems(tileEntity, player, 64); } - } - } - - return false; - } - @Override public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) { diff --git a/src/minecraft/assemblyline/common/block/TileEntityCrate.java b/src/minecraft/assemblyline/common/block/TileEntityCrate.java index d9a5d88f..22d79a04 100644 --- a/src/minecraft/assemblyline/common/block/TileEntityCrate.java +++ b/src/minecraft/assemblyline/common/block/TileEntityCrate.java @@ -1,6 +1,7 @@ package assemblyline.common.block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -8,7 +9,6 @@ import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.ISidedInventory; import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.tile.TileEntityAdvanced; @@ -19,7 +19,7 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; -public class TileEntityCrate extends TileEntityAdvanced implements ISidedInventory, IPacketReceiver +public class TileEntityCrate extends TileEntityAdvanced implements IInventory, IPacketReceiver { public static final int MAX_LIMIT = 2880; private ItemStack[] containingItems = new ItemStack[1]; @@ -244,16 +244,4 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento { return "Crate"; } - - @Override - public int getStartInventorySide(ForgeDirection side) - { - return 0; - } - - @Override - public int getSizeInventorySide(ForgeDirection side) - { - return 1; - } }