Better Crate Controls

This commit is contained in:
Henry Mao 2013-01-26 21:40:57 +08:00
parent 1c783715a0
commit 1c08afde7e
2 changed files with 16 additions and 78 deletions

View file

@ -42,53 +42,29 @@ public class BlockCrate extends BlockMachine
if (side == ForgeDirection.UP.ordinal()) if (side == ForgeDirection.UP.ordinal())
{ {
if (tileEntity != null) this.insertCurrentItem(tileEntity, player);
{
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;
}
}
}
}
}
} }
else if (side == ForgeDirection.DOWN.ordinal())
if (side > 1 && hitY > 0.7)
{ {
return this.insertAllItems(tileEntity, player); this.ejectItems(tileEntity, player, 64);
} }
else 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 @Override
@ -238,32 +214,6 @@ public class BlockCrate extends BlockMachine
return itemStack; 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 @Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ) public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{ {

View file

@ -1,6 +1,7 @@
package assemblyline.common.block; package assemblyline.common.block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; 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.Packet;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import universalelectricity.prefab.tile.TileEntityAdvanced; 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.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; 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; public static final int MAX_LIMIT = 2880;
private ItemStack[] containingItems = new ItemStack[1]; private ItemStack[] containingItems = new ItemStack[1];
@ -244,16 +244,4 @@ public class TileEntityCrate extends TileEntityAdvanced implements ISidedInvento
{ {
return "Crate"; return "Crate";
} }
@Override
public int getStartInventorySide(ForgeDirection side)
{
return 0;
}
@Override
public int getSizeInventorySide(ForgeDirection side)
{
return 1;
}
} }