The Great Wall of Pink (purely aesthetic changes, no logic altered)
This commit is contained in:
parent
895cf66788
commit
138274e1e9
|
|
@ -36,308 +36,242 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockIronChest extends BlockContainer {
|
public class BlockIronChest extends BlockContainer {
|
||||||
|
private Random random = new Random();
|
||||||
|
|
||||||
private Random random;
|
public BlockIronChest() {
|
||||||
|
super(Material.iron);
|
||||||
|
setBlockName("IronChest");
|
||||||
|
setHardness(3.0F);
|
||||||
|
setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
||||||
|
setCreativeTab(CreativeTabs.tabDecorations);
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
/**
|
||||||
private IIcon[][] icons;
|
* Overridden by {@link #createTileEntity(World, int)}
|
||||||
|
*/
|
||||||
public BlockIronChest()
|
@Override
|
||||||
{
|
public TileEntity createNewTileEntity(World w, int i) {
|
||||||
super(Material.iron);
|
return null;
|
||||||
setBlockName("IronChest");
|
}
|
||||||
setHardness(3.0F);
|
|
||||||
setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
|
||||||
random = new Random();
|
|
||||||
setCreativeTab(CreativeTabs.tabDecorations);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overridden by {@link #createTileEntity(World, int)}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World w, int i)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
return 22;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World world, int metadata)
|
|
||||||
{
|
|
||||||
return IronChestType.makeEntity(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public IIcon getIcon(int i, int j)
|
|
||||||
{
|
|
||||||
if (j < IronChestType.values().length)
|
|
||||||
{
|
|
||||||
IronChestType type = IronChestType.values()[j];
|
|
||||||
return type.getIcon(i);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
|
||||||
{
|
|
||||||
ArrayList<ItemStack> items = Lists.newArrayList();
|
|
||||||
ItemStack stack = new ItemStack(this,1,metadata);
|
|
||||||
IronChestType.values()[IronChestType.validateMeta(metadata)].adornItemDrop(stack);
|
|
||||||
items.add(stack);
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3)
|
|
||||||
{
|
|
||||||
if (world.isRemote)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IInventory iinventory = chestInventory(world, i, j, k);
|
|
||||||
|
|
||||||
if (iinventory != null && world.getTileEntity(i, j, k) instanceof TileEntityIronChest)
|
|
||||||
player.openGui(IronChest.instance, ((TileEntityIronChest) world.getTileEntity(i, j, k)).getType().ordinal(), world, i, j, k);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IInventory chestInventory(World world, int i, int j, int k)
|
|
||||||
{
|
|
||||||
TileEntity object = (TileEntityIronChest)world.getTileEntity(i, j, k);
|
|
||||||
|
|
||||||
if (object == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (world.isSideSolid(i, j + 1, k, DOWN))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (isOcelotOnChest(world, i, j, k))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (world.getBlock(i - 1, j, k) == this && (world.isSideSolid(i - 1, j + 1, k, DOWN) || isOcelotOnChest(world, i - 1, j, k)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (world.getBlock(i + 1, j, k) == this && (world.isSideSolid(i + 1, j + 1, k, DOWN) || isOcelotOnChest(world, i + 1, j, k)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (world.getBlock(i, j, k - 1) == this && (world.isSideSolid(i, j + 1, k - 1, DOWN) || isOcelotOnChest(world, i, j, k - 1)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else if (world.getBlock(i, j, k + 1) == this && (world.isSideSolid(i, j + 1, k + 1, DOWN) || isOcelotOnChest(world, i, j, k + 1)))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (IInventory)object;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isOcelotOnChest(World world, int i, int j, int k)
|
|
||||||
{
|
|
||||||
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().getAABB((double)i, (double)(j + 1), (double)k, (double)(i + 1), (double)(j + 2), (double)(k + 1))).iterator();
|
|
||||||
EntityOcelot entityocelot1;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (!iterator.hasNext())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
EntityOcelot entityocelot = (EntityOcelot)iterator.next();
|
|
||||||
entityocelot1 = (EntityOcelot)entityocelot;
|
|
||||||
}
|
|
||||||
while (!entityocelot1.isSitting());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(World world, int i, int j, int k)
|
public boolean isOpaqueCube() {
|
||||||
{
|
return false;
|
||||||
super.onBlockAdded(world, i, j, k);
|
}
|
||||||
world.markBlockForUpdate(i, j, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack)
|
public boolean renderAsNormalBlock() {
|
||||||
{
|
return false;
|
||||||
byte chestFacing = 0;
|
}
|
||||||
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
|
|
||||||
if (facing == 0)
|
|
||||||
{
|
|
||||||
chestFacing = 2;
|
|
||||||
}
|
|
||||||
if (facing == 1)
|
|
||||||
{
|
|
||||||
chestFacing = 5;
|
|
||||||
}
|
|
||||||
if (facing == 2)
|
|
||||||
{
|
|
||||||
chestFacing = 3;
|
|
||||||
}
|
|
||||||
if (facing == 3)
|
|
||||||
{
|
|
||||||
chestFacing = 4;
|
|
||||||
}
|
|
||||||
TileEntity te = world.getTileEntity(i, j, k);
|
|
||||||
if (te != null && te instanceof TileEntityIronChest)
|
|
||||||
{
|
|
||||||
TileEntityIronChest teic = (TileEntityIronChest) te;
|
|
||||||
teic.wasPlaced(entityliving, itemStack);
|
|
||||||
teic.setFacing(chestFacing);
|
|
||||||
world.markBlockForUpdate(i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(int i)
|
public int getRenderType() {
|
||||||
{
|
return 22;
|
||||||
return i;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, int i, int j, int k, Block i1, int i2)
|
public TileEntity createTileEntity(World world, int metadata) {
|
||||||
{
|
return IronChestType.makeEntity(metadata);
|
||||||
TileEntityIronChest tileentitychest = (TileEntityIronChest) world.getTileEntity(i, j, k);
|
}
|
||||||
if (tileentitychest != null)
|
|
||||||
{
|
|
||||||
tileentitychest.removeAdornments();
|
|
||||||
dropContent(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord);
|
|
||||||
}
|
|
||||||
super.breakBlock(world, i, j, k, i1, i2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dropContent(int newSize, IInventory chest, World world, int xCoord, int yCoord, int zCoord)
|
@Override
|
||||||
{
|
@SideOnly(Side.CLIENT)
|
||||||
for (int l = newSize; l < chest.getSizeInventory(); l++)
|
public IIcon getIcon(int i, int j) {
|
||||||
{
|
if (j < IronChestType.values().length) {
|
||||||
ItemStack itemstack = chest.getStackInSlot(l);
|
IronChestType type = IronChestType.values()[j];
|
||||||
if (itemstack == null)
|
return type.getIcon(i);
|
||||||
{
|
}
|
||||||
continue;
|
return null;
|
||||||
}
|
}
|
||||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
while (itemstack.stackSize > 0)
|
|
||||||
{
|
|
||||||
int i1 = random.nextInt(21) + 10;
|
|
||||||
if (i1 > itemstack.stackSize)
|
|
||||||
{
|
|
||||||
i1 = itemstack.stackSize;
|
|
||||||
}
|
|
||||||
itemstack.stackSize -= i1;
|
|
||||||
EntityItem entityitem = new EntityItem(world, (float) xCoord + f, (float) yCoord + (newSize > 0 ? 1 : 0) + f1, (float) zCoord + f2,
|
|
||||||
new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage()));
|
|
||||||
float f3 = 0.05F;
|
|
||||||
entityitem.motionX = (float) random.nextGaussian() * f3;
|
|
||||||
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
|
|
||||||
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
|
||||||
if (itemstack.hasTagCompound())
|
|
||||||
{
|
|
||||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
|
||||||
}
|
|
||||||
world.spawnEntityInWorld(entityitem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
ArrayList<ItemStack> items = Lists.newArrayList();
|
||||||
{
|
ItemStack stack = new ItemStack(this, 1, metadata);
|
||||||
for (IronChestType type : IronChestType.values())
|
IronChestType.values()[IronChestType.validateMeta(metadata)].adornItemDrop(stack);
|
||||||
{
|
items.add(stack);
|
||||||
if (type.isValidForCreativeMode())
|
return items;
|
||||||
{
|
}
|
||||||
par3List.add(new ItemStack(this, 1, type.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) {
|
||||||
{
|
if (world.isRemote)
|
||||||
TileEntity te = world.getTileEntity(x, y, z);
|
return true;
|
||||||
if (te instanceof TileEntityIronChest)
|
else {
|
||||||
{
|
IInventory iinventory = chestInventory(world, i, j, k);
|
||||||
TileEntityIronChest teic = (TileEntityIronChest) te;
|
|
||||||
if (teic.getType().isExplosionResistant())
|
|
||||||
{
|
|
||||||
return 10000f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (iinventory != null)
|
||||||
|
player.openGui(IronChest.instance, ((TileEntityIronChest) world.getTileEntity(i, j, k)).getType().ordinal(), world, i, j, k);
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
|
}
|
||||||
{
|
}
|
||||||
return Container.calcRedstoneFromInventory((TileEntityIronChest) par1World.getTileEntity(par2, par3, par4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public IInventory chestInventory(World world, int i, int j, int k) {
|
||||||
|
TileEntity object = (TileEntityIronChest) world.getTileEntity(i, j, k);
|
||||||
|
|
||||||
@Override
|
if (object == null) {
|
||||||
@SideOnly(Side.CLIENT)
|
return null;
|
||||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
} else if (world.isSideSolid(i, j + 1, k, DOWN)) {
|
||||||
{
|
return null;
|
||||||
for (IronChestType typ: IronChestType.values())
|
} else if (isOcelotOnChest(world, i, j, k)) {
|
||||||
{
|
return null;
|
||||||
typ.makeIcons(par1IconRegister);
|
} else if (world.getBlock(i - 1, j, k) == this && (world.isSideSolid(i - 1, j + 1, k, DOWN) || isOcelotOnChest(world, i - 1, j, k))) {
|
||||||
}
|
return null;
|
||||||
}
|
} else if (world.getBlock(i + 1, j, k) == this && (world.isSideSolid(i + 1, j + 1, k, DOWN) || isOcelotOnChest(world, i + 1, j, k))) {
|
||||||
|
return null;
|
||||||
|
} else if (world.getBlock(i, j, k - 1) == this && (world.isSideSolid(i, j + 1, k - 1, DOWN) || isOcelotOnChest(world, i, j, k - 1))) {
|
||||||
|
return null;
|
||||||
|
} else if (world.getBlock(i, j, k + 1) == this && (world.isSideSolid(i, j + 1, k + 1, DOWN) || isOcelotOnChest(world, i, j, k + 1))) {
|
||||||
|
return null;
|
||||||
|
} else
|
||||||
|
return (IInventory) object;
|
||||||
|
}
|
||||||
|
|
||||||
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
|
private static boolean isOcelotOnChest(World world, int i, int j, int k) {
|
||||||
|
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().getAABB((double) i, (double) (j + 1), (double) k, (double) (i + 1), (double) (j + 2), (double) (k + 1))).iterator();
|
||||||
@Override
|
EntityOcelot entityocelot1;
|
||||||
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
|
|
||||||
{
|
|
||||||
return validRotationAxes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
do {
|
||||||
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis)
|
if (!iterator.hasNext())
|
||||||
{
|
return false;
|
||||||
if (worldObj.isRemote)
|
|
||||||
{
|
EntityOcelot entityocelot = (EntityOcelot) iterator.next();
|
||||||
return false;
|
entityocelot1 = (EntityOcelot) entityocelot;
|
||||||
}
|
} while (!entityocelot1.isSitting());
|
||||||
if (axis == UP || axis == DOWN)
|
|
||||||
{
|
return true;
|
||||||
TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
}
|
||||||
if (tileEntity instanceof TileEntityIronChest) {
|
|
||||||
TileEntityIronChest icte = (TileEntityIronChest) tileEntity;
|
@Override
|
||||||
icte.rotateAround(axis);
|
public void onBlockAdded(World world, int i, int j, int k) {
|
||||||
}
|
super.onBlockAdded(world, i, j, k);
|
||||||
return true;
|
world.markBlockForUpdate(i, j, k);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
}
|
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) {
|
||||||
|
byte chestFacing = 0;
|
||||||
|
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
|
||||||
|
if (facing == 0) {
|
||||||
|
chestFacing = 2;
|
||||||
|
}
|
||||||
|
if (facing == 1) {
|
||||||
|
chestFacing = 5;
|
||||||
|
}
|
||||||
|
if (facing == 2) {
|
||||||
|
chestFacing = 3;
|
||||||
|
}
|
||||||
|
if (facing == 3) {
|
||||||
|
chestFacing = 4;
|
||||||
|
}
|
||||||
|
TileEntity te = world.getTileEntity(i, j, k);
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest teic = (TileEntityIronChest) te;
|
||||||
|
teic.wasPlaced(entityliving, itemStack);
|
||||||
|
teic.setFacing(chestFacing);
|
||||||
|
world.markBlockForUpdate(i, j, k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int damageDropped(int i) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, int i, int j, int k, Block b, int l) {
|
||||||
|
TileEntityIronChest te = (TileEntityIronChest) world.getTileEntity(i, j, k);
|
||||||
|
if (te != null) {
|
||||||
|
te.removeAdornments();
|
||||||
|
dropContent(0, te, world, te.xCoord, te.yCoord, te.zCoord);
|
||||||
|
}
|
||||||
|
super.breakBlock(world, i, j, k, b, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dropContent(int newSize, IInventory chest, World world, int xCoord, int yCoord, int zCoord) {
|
||||||
|
for (int l = newSize; l < chest.getSizeInventory(); l++) {
|
||||||
|
ItemStack itemstack = chest.getStackInSlot(l);
|
||||||
|
if (itemstack == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
while (itemstack.stackSize > 0) {
|
||||||
|
int i1 = random.nextInt(21) + 10;
|
||||||
|
if (i1 > itemstack.stackSize) {
|
||||||
|
i1 = itemstack.stackSize;
|
||||||
|
}
|
||||||
|
itemstack.stackSize -= i1;
|
||||||
|
EntityItem entityitem = new EntityItem(world, (float) xCoord + f, (float) yCoord + (newSize > 0 ? 1 : 0) + f1, (float) zCoord + f2, new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage()));
|
||||||
|
float f3 = 0.05F;
|
||||||
|
entityitem.motionX = (float) random.nextGaussian() * f3;
|
||||||
|
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
|
||||||
|
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
||||||
|
if (itemstack.hasTagCompound()) {
|
||||||
|
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
|
}
|
||||||
|
world.spawnEntityInWorld(entityitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||||
|
for (IronChestType type : IronChestType.values()) {
|
||||||
|
if (type.isValidForCreativeMode()) {
|
||||||
|
par3List.add(new ItemStack(this, 1, type.ordinal()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
if (te instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest teic = (TileEntityIronChest) te;
|
||||||
|
if (teic.getType().isExplosionResistant()) {
|
||||||
|
return 10000F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getExplosionResistance(par1Entity, world, x, y, z, explosionX, explosionY, explosionZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComparatorInputOverride(World world, int i, int j, int k, int l) {
|
||||||
|
return Container.calcRedstoneFromInventory((TileEntityIronChest) world.getTileEntity(i, j, k));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||||
|
for (IronChestType typ : IronChestType.values()) {
|
||||||
|
typ.makeIcons(par1IconRegister);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ForgeDirection[] getValidRotations(World world, int x, int y, int z) {
|
||||||
|
return validRotationAxes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) {
|
||||||
|
if (worldObj.isRemote) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (axis == UP || axis == DOWN) {
|
||||||
|
TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
||||||
|
if (tileEntity instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest icte = (TileEntityIronChest) tileEntity;
|
||||||
|
icte.rotateAround(axis);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,79 +10,64 @@ import static cpw.mods.ironchest.IronChestType.SILVER;
|
||||||
import static cpw.mods.ironchest.IronChestType.WOOD;
|
import static cpw.mods.ironchest.IronChestType.WOOD;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
public enum ChestChangerType {
|
public enum ChestChangerType {
|
||||||
IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),
|
IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),
|
||||||
GOLDDIAMOND(GOLD, DIAMOND, "goldDiamondUpgrade", "Gold to Diamond Chest Upgrade", "GGG", "msm", "GGG"),
|
GOLDDIAMOND(GOLD, DIAMOND, "goldDiamondUpgrade", "Gold to Diamond Chest Upgrade", "GGG", "msm", "GGG"),
|
||||||
COPPERSILVER(COPPER, SILVER, "copperSilverUpgrade", "Copper to Silver Chest Upgrade", "mmm", "msm", "mmm"),
|
COPPERSILVER(COPPER, SILVER, "copperSilverUpgrade", "Copper to Silver Chest Upgrade", "mmm", "msm", "mmm"),
|
||||||
SILVERGOLD(SILVER, GOLD, "silverGoldUpgrade", "Silver to Gold Chest Upgrade", "mGm", "GsG", "mGm"),
|
SILVERGOLD(SILVER, GOLD, "silverGoldUpgrade", "Silver to Gold Chest Upgrade", "mGm", "GsG", "mGm"),
|
||||||
COPPERIRON(COPPER, IRON, "copperIronUpgrade", "Copper to Iron Chest Upgrade", "mGm", "GsG", "mGm"),
|
COPPERIRON(COPPER, IRON, "copperIronUpgrade", "Copper to Iron Chest Upgrade", "mGm", "GsG", "mGm"),
|
||||||
DIAMONDCRYSTAL(DIAMOND, CRYSTAL, "diamondCrystalUpgrade", "Diamond to Crystal Chest Upgrade", "GGG", "GOG", "GGG"),
|
DIAMONDCRYSTAL(DIAMOND, CRYSTAL, "diamondCrystalUpgrade", "Diamond to Crystal Chest Upgrade", "GGG", "GOG", "GGG"),
|
||||||
WOODIRON(WOOD, IRON, "woodIronUpgrade", "Normal chest to Iron Chest Upgrade", "mmm", "msm", "mmm"),
|
WOODIRON(WOOD, IRON, "woodIronUpgrade", "Normal chest to Iron Chest Upgrade", "mmm", "msm", "mmm"),
|
||||||
WOODCOPPER(WOOD, COPPER, "woodCopperUpgrade", "Normal chest to Copper Chest Upgrade", "mmm", "msm", "mmm"),
|
WOODCOPPER(WOOD, COPPER, "woodCopperUpgrade", "Normal chest to Copper Chest Upgrade", "mmm", "msm", "mmm"),
|
||||||
DIAMONDOBSIDIAN(DIAMOND, OBSIDIAN, "diamondObsidianUpgrade", "Diamond to Obsidian Chest Upgrade", "mmm", "mGm", "mmm");
|
DIAMONDOBSIDIAN(DIAMOND, OBSIDIAN, "diamondObsidianUpgrade", "Diamond to Obsidian Chest Upgrade", "mmm", "mGm", "mmm");
|
||||||
|
|
||||||
private IronChestType source;
|
private IronChestType source, target;
|
||||||
private IronChestType target;
|
public String itemName, descriptiveName, recipe[];
|
||||||
public String itemName;
|
private ItemChestChanger item;
|
||||||
public String descriptiveName;
|
|
||||||
private ItemChestChanger item;
|
|
||||||
private String[] recipe;
|
|
||||||
|
|
||||||
private ChestChangerType(IronChestType source, IronChestType target, String itemName, String descriptiveName, String... recipe)
|
private ChestChangerType(IronChestType source, IronChestType target, String itemName, String descriptiveName, String... recipe) {
|
||||||
{
|
this.source = source;
|
||||||
this.source = source;
|
this.target = target;
|
||||||
this.target = target;
|
this.itemName = itemName;
|
||||||
this.itemName = itemName;
|
this.descriptiveName = descriptiveName;
|
||||||
this.descriptiveName = descriptiveName;
|
this.recipe = recipe;
|
||||||
this.recipe = recipe;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canUpgrade(IronChestType from)
|
public boolean canUpgrade(IronChestType from) {
|
||||||
{
|
return from == this.source;
|
||||||
return from == this.source;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getTarget()
|
public int getTarget() {
|
||||||
{
|
return this.target.ordinal();
|
||||||
return this.target.ordinal();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ItemChestChanger buildItem()
|
public ItemChestChanger buildItem() {
|
||||||
{
|
item = new ItemChestChanger(this);
|
||||||
item = new ItemChestChanger(this);
|
GameRegistry.registerItem(item, itemName);
|
||||||
GameRegistry.registerItem(item, itemName);
|
return item;
|
||||||
return item;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void addRecipes()
|
public void addRecipes() {
|
||||||
{
|
for (String sourceMat : source.getMatList()) {
|
||||||
for (String sourceMat : source.getMatList())
|
for (String targetMat : target.getMatList()) {
|
||||||
{
|
Object targetMaterial = IronChestType.translateOreName(targetMat);
|
||||||
for (String targetMat : target.getMatList())
|
Object sourceMaterial = IronChestType.translateOreName(sourceMat);
|
||||||
{
|
IronChestType.addRecipe(new ItemStack(item), recipe, 'm', targetMaterial, 's', sourceMaterial, 'G', Blocks.glass, 'O', Blocks.obsidian);
|
||||||
Object targetMaterial = IronChestType.translateOreName(targetMat);
|
}
|
||||||
Object sourceMaterial = IronChestType.translateOreName(sourceMat);
|
}
|
||||||
IronChestType.addRecipe(new ItemStack(item), recipe, 'm', targetMaterial, 's', sourceMaterial, 'G', Blocks.glass, 'O', Blocks.obsidian);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void buildItems()
|
public static void buildItems() {
|
||||||
{
|
for (ChestChangerType type : values()) {
|
||||||
for (ChestChangerType type : values())
|
type.buildItem();
|
||||||
{
|
}
|
||||||
type.buildItem();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void generateRecipes()
|
public static void generateRecipes() {
|
||||||
{
|
for (ChestChangerType item : values()) {
|
||||||
for (ChestChangerType item : values())
|
item.addRecipes();
|
||||||
{
|
}
|
||||||
item.addRecipes();
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,40 +6,27 @@ import net.minecraft.world.World;
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
|
||||||
public class CommonProxy implements IGuiHandler {
|
public class CommonProxy implements IGuiHandler {
|
||||||
public void registerRenderInformation()
|
public void registerRenderInformation() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public void registerTileEntitySpecialRenderer(IronChestType typ) {}
|
||||||
|
|
||||||
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
@Override
|
||||||
{
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) {
|
||||||
|
TileEntity te = world.getTileEntity(X, Y, Z);
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest icte = (TileEntityIronChest) te;
|
||||||
|
return new ContainerIronChest(player.inventory, icte, icte.getType(), 0, 0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public World getClientWorld() {
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
return null;
|
||||||
{
|
}
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z)
|
|
||||||
{
|
|
||||||
TileEntity te = world.getTileEntity(X, Y, Z);
|
|
||||||
if (te != null && te instanceof TileEntityIronChest)
|
|
||||||
{
|
|
||||||
TileEntityIronChest icte = (TileEntityIronChest) te;
|
|
||||||
return new ContainerIronChest(player.inventory, icte, icte.getType(), 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public World getClientWorld()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,115 +1,86 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
|
import invtweaks.api.container.ChestContainer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import invtweaks.api.container.ChestContainer;
|
|
||||||
|
|
||||||
@ChestContainer(isLargeChest = true)
|
@ChestContainer(isLargeChest = true)
|
||||||
public class ContainerIronChest extends Container {
|
public class ContainerIronChest extends Container {
|
||||||
private IronChestType type;
|
private IronChestType type;
|
||||||
private EntityPlayer player;
|
private EntityPlayer player;
|
||||||
private IInventory chest;
|
private IInventory chest;
|
||||||
|
|
||||||
public ContainerIronChest(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
|
public ContainerIronChest(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize) {
|
||||||
{
|
chest = chestInventory;
|
||||||
chest = chestInventory;
|
player = ((InventoryPlayer) playerInventory).player;
|
||||||
player = ((InventoryPlayer) playerInventory).player;
|
this.type = type;
|
||||||
this.type = type;
|
chestInventory.openInventory();
|
||||||
chestInventory.openInventory();
|
layoutContainer(playerInventory, chestInventory, type, xSize, ySize);
|
||||||
layoutContainer(playerInventory, chestInventory, type, xSize, ySize);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player)
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
{
|
return chest.isUseableByPlayer(player);
|
||||||
return chest.isUseableByPlayer(player);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer p, int i)
|
public ItemStack transferStackInSlot(EntityPlayer p, int i) {
|
||||||
{
|
ItemStack itemstack = null;
|
||||||
ItemStack itemstack = null;
|
Slot slot = (Slot) inventorySlots.get(i);
|
||||||
Slot slot = (Slot) inventorySlots.get(i);
|
if (slot != null && slot.getHasStack()) {
|
||||||
if (slot != null && slot.getHasStack())
|
ItemStack itemstack1 = slot.getStack();
|
||||||
{
|
itemstack = itemstack1.copy();
|
||||||
ItemStack itemstack1 = slot.getStack();
|
if (i < type.size) {
|
||||||
itemstack = itemstack1.copy();
|
if (!mergeItemStack(itemstack1, type.size, inventorySlots.size(), true)) {
|
||||||
if (i < type.size)
|
return null;
|
||||||
{
|
}
|
||||||
if (!mergeItemStack(itemstack1, type.size, inventorySlots.size(), true))
|
} else if (!type.acceptsStack(itemstack1)) {
|
||||||
{
|
return null;
|
||||||
return null;
|
} else if (!mergeItemStack(itemstack1, 0, type.size, false)) {
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
else if (!type.acceptsStack(itemstack1))
|
if (itemstack1.stackSize == 0) {
|
||||||
{
|
slot.putStack(null);
|
||||||
return null;
|
} else {
|
||||||
}
|
slot.onSlotChanged();
|
||||||
else if (!mergeItemStack(itemstack1, 0, type.size, false))
|
}
|
||||||
{
|
}
|
||||||
return null;
|
return itemstack;
|
||||||
}
|
}
|
||||||
if (itemstack1.stackSize == 0)
|
|
||||||
{
|
|
||||||
slot.putStack(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slot.onSlotChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return itemstack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContainerClosed(EntityPlayer entityplayer)
|
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||||
{
|
super.onContainerClosed(entityplayer);
|
||||||
super.onContainerClosed(entityplayer);
|
chest.closeInventory();
|
||||||
chest.closeInventory();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
|
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize) {
|
||||||
{
|
if (type == IronChestType.DIRTCHEST9000) {
|
||||||
if (type == IronChestType.DIRTCHEST9000) {
|
addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
|
||||||
addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
|
} else
|
||||||
} else {
|
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
|
||||||
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
|
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
|
||||||
{
|
addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
|
||||||
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
|
|
||||||
{
|
|
||||||
addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int leftCol = (xSize - 162) / 2 + 1;
|
int leftCol = (xSize - 162) / 2 + 1;
|
||||||
for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++)
|
for (int playerInvRow = 0; playerInvRow < 3; playerInvRow++)
|
||||||
{
|
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
||||||
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
|
||||||
{
|
|
||||||
addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18
|
|
||||||
- 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
|
||||||
|
addSlotToContainer(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24));
|
||||||
|
}
|
||||||
|
|
||||||
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
|
public EntityPlayer getPlayer() {
|
||||||
{
|
return player;
|
||||||
addSlotToContainer(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityPlayer getPlayer()
|
@ChestContainer.RowSizeCallback
|
||||||
{
|
public int getNumColumns() {
|
||||||
return player;
|
return type.getRowLength();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@ChestContainer.RowSizeCallback
|
|
||||||
public int getNumColumns() {
|
|
||||||
return type.getRowLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,32 +11,32 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[7.0,);required-after:FML@[5.0.5,)")
|
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[7.0,);required-after:FML@[5.0.5,)")
|
||||||
public class IronChest {
|
public class IronChest {
|
||||||
public static BlockIronChest ironChestBlock;
|
public static BlockIronChest ironChestBlock;
|
||||||
|
|
||||||
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
|
||||||
public static CommonProxy proxy;
|
|
||||||
|
|
||||||
@Instance("IronChest")
|
|
||||||
public static IronChest instance;
|
|
||||||
|
|
||||||
@EventHandler
|
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
|
||||||
public void load(FMLInitializationEvent e)
|
public static CommonProxy proxy;
|
||||||
{
|
|
||||||
ChestChangerType.buildItems();
|
@Instance("IronChest")
|
||||||
|
public static IronChest instance;
|
||||||
ironChestBlock = new BlockIronChest();
|
|
||||||
GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");
|
@EventHandler
|
||||||
|
public void load(FMLInitializationEvent e) {
|
||||||
PacketHandler.INSTANCE.ordinal();
|
ChestChangerType.buildItems();
|
||||||
for (IronChestType typ : IronChestType.values())
|
|
||||||
{
|
ironChestBlock = new BlockIronChest();
|
||||||
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest."+typ.name(), typ.name());
|
GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");
|
||||||
proxy.registerTileEntitySpecialRenderer(typ);
|
|
||||||
}
|
for (IronChestType typ : IronChestType.values()) {
|
||||||
IronChestType.registerBlocksAndRecipes(ironChestBlock);
|
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name());
|
||||||
ChestChangerType.generateRecipes();
|
proxy.registerTileEntitySpecialRenderer(typ);
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
}
|
||||||
proxy.registerRenderInformation();
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
IronChestType.registerBlocksAndRecipes(ironChestBlock);
|
||||||
}
|
ChestChangerType.generateRecipes();
|
||||||
}
|
|
||||||
|
PacketHandler.INSTANCE.ordinal();
|
||||||
|
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||||
|
proxy.registerRenderInformation();
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ package cpw.mods.ironchest;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
|
@ -18,238 +19,179 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public enum IronChestType {
|
public enum IronChestType {
|
||||||
IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
|
IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
|
||||||
GOLD(81, 9, true, "Gold Chest", "goldchest.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, "mmmmPmmmm", "mGmG4GmGm"),
|
GOLD(81, 9, true, "Gold Chest", "goldchest.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, "mmmmPmmmm", "mGmG4GmGm"),
|
||||||
DIAMOND(108, 12, true, "Diamond Chest", "diamondchest.png", 2, Arrays.asList("gemDiamond"), TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"),
|
DIAMOND(108, 12, true, "Diamond Chest", "diamondchest.png", 2, Arrays.asList("gemDiamond"), TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"),
|
||||||
COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
|
COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
|
||||||
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
|
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
|
||||||
CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
|
CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
|
||||||
OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"),
|
OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"),
|
||||||
DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png",7,Arrays.asList("dirt"), TileEntityDirtChest.class,Item.getItemFromBlock(Blocks.dirt),"mmmmCmmmm"),
|
DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png", 7, Arrays.asList("dirt"), TileEntityDirtChest.class, Item.getItemFromBlock(Blocks.dirt), "mmmmCmmmm"),
|
||||||
WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null);
|
WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null);
|
||||||
int size;
|
|
||||||
private int rowLength;
|
|
||||||
public String friendlyName;
|
|
||||||
private boolean tieredChest;
|
|
||||||
private String modelTexture;
|
|
||||||
private int textureRow;
|
|
||||||
public Class<? extends TileEntityIronChest> clazz;
|
|
||||||
private String[] recipes;
|
|
||||||
private ArrayList<String> matList;
|
|
||||||
private Item itemFilter;
|
|
||||||
|
|
||||||
IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List<String> mats,
|
public int size, rowLength, textureRow;
|
||||||
Class<? extends TileEntityIronChest> clazz, String... recipes)
|
public String friendlyName, modelTexture, recipes[];
|
||||||
{
|
private boolean tieredChest;
|
||||||
this(size, rowLength, tieredChest, friendlyName, modelTexture, textureRow, mats, clazz, (Item)null, recipes);
|
public Class<? extends TileEntityIronChest> clazz;
|
||||||
}
|
private ArrayList<String> matList;
|
||||||
IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List<String> mats,
|
private Item itemFilter;
|
||||||
Class<? extends TileEntityIronChest> clazz, Item itemFilter, String... recipes)
|
|
||||||
{
|
|
||||||
this.size = size;
|
|
||||||
this.rowLength = rowLength;
|
|
||||||
this.tieredChest = tieredChest;
|
|
||||||
this.friendlyName = friendlyName;
|
|
||||||
this.modelTexture = modelTexture;
|
|
||||||
this.textureRow = textureRow;
|
|
||||||
this.clazz = clazz;
|
|
||||||
this.itemFilter = itemFilter;
|
|
||||||
this.recipes = recipes;
|
|
||||||
this.matList = new ArrayList<String>();
|
|
||||||
matList.addAll(mats);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModelTexture()
|
IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List<String> mats, Class<? extends TileEntityIronChest> clazz, String... recipes) {
|
||||||
{
|
this(size, rowLength, tieredChest, friendlyName, modelTexture, textureRow, mats, clazz, (Item) null, recipes);
|
||||||
return modelTexture;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getTextureRow()
|
IronChestType(int size, int rowLength, boolean tieredChest, String friendlyName, String modelTexture, int textureRow, List<String> mats, Class<? extends TileEntityIronChest> clazz, Item itemFilter, String... recipes) {
|
||||||
{
|
this.size = size;
|
||||||
return textureRow;
|
this.rowLength = rowLength;
|
||||||
}
|
this.tieredChest = tieredChest;
|
||||||
|
this.friendlyName = friendlyName;
|
||||||
|
this.modelTexture = modelTexture;
|
||||||
|
this.textureRow = textureRow;
|
||||||
|
this.clazz = clazz;
|
||||||
|
this.itemFilter = itemFilter;
|
||||||
|
this.recipes = recipes;
|
||||||
|
this.matList = new ArrayList<String>();
|
||||||
|
matList.addAll(mats);
|
||||||
|
}
|
||||||
|
|
||||||
public static TileEntityIronChest makeEntity(int metadata)
|
public String getModelTexture() {
|
||||||
{
|
return modelTexture;
|
||||||
// Compatibility
|
}
|
||||||
int chesttype = validateMeta(metadata);
|
|
||||||
if (chesttype == metadata)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
TileEntityIronChest te = values()[chesttype].clazz.newInstance();
|
|
||||||
return te;
|
|
||||||
}
|
|
||||||
catch (InstantiationException e)
|
|
||||||
{
|
|
||||||
// unpossible
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException e)
|
|
||||||
{
|
|
||||||
// unpossible
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerTranslations()
|
public int getTextureRow() {
|
||||||
{
|
return textureRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBlocksAndRecipes(BlockIronChest blockResult)
|
public static TileEntityIronChest makeEntity(int metadata) {
|
||||||
{
|
int chesttype = validateMeta(metadata);
|
||||||
ItemStack previous = new ItemStack(Blocks.chest);
|
if (chesttype == metadata) {
|
||||||
for (IronChestType typ : values())
|
try {
|
||||||
{
|
return values()[chesttype].clazz.newInstance();
|
||||||
generateRecipesForType(blockResult, previous, typ);
|
} catch (InstantiationException e) {
|
||||||
ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal());
|
e.printStackTrace();
|
||||||
if (typ.isValidForCreativeMode()) GameRegistry.registerCustomItemStack(typ.friendlyName, chest);
|
} catch (IllegalAccessException e) {
|
||||||
if (typ.tieredChest) previous = chest;
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static void generateRecipesForType(BlockIronChest blockResult, Object previousTier, IronChestType type)
|
public static void registerBlocksAndRecipes(BlockIronChest blockResult) {
|
||||||
{
|
ItemStack previous = new ItemStack(Blocks.chest);
|
||||||
for (String recipe : type.recipes)
|
for (IronChestType typ : values()) {
|
||||||
{
|
generateRecipesForType(blockResult, previous, typ);
|
||||||
String[] recipeSplit = new String[] { recipe.substring(0, 3), recipe.substring(3, 6), recipe.substring(6, 9) };
|
ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal());
|
||||||
Object mainMaterial = null;
|
if (typ.isValidForCreativeMode())
|
||||||
for (String mat : type.matList)
|
GameRegistry.registerCustomItemStack(typ.friendlyName, chest);
|
||||||
{
|
if (typ.tieredChest)
|
||||||
mainMaterial = translateOreName(mat);
|
previous = chest;
|
||||||
addRecipe(new ItemStack(blockResult, 1, type.ordinal()), recipeSplit,
|
}
|
||||||
'm', mainMaterial, 'P', previousTier, /* previous tier of chest */
|
}
|
||||||
'G', Blocks.glass, 'C', Blocks.chest,
|
|
||||||
'0', new ItemStack(blockResult, 1, 0), /* Iron Chest */
|
|
||||||
'1', new ItemStack(blockResult, 1, 1), /* Gold Chest */
|
|
||||||
'2', new ItemStack(blockResult, 1, 2), /* Diamond Chest */
|
|
||||||
'3', new ItemStack(blockResult, 1, 3), /* Copper Chest */
|
|
||||||
'4', new ItemStack(blockResult, 1, 4)/* Silver Chest */
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object translateOreName(String mat)
|
public static void generateRecipesForType(BlockIronChest blockResult, Object previousTier, IronChestType type) {
|
||||||
{
|
for (String recipe : type.recipes) {
|
||||||
if (mat == "ingotIron")
|
String[] recipeSplit = new String[] { recipe.substring(0, 3), recipe.substring(3, 6), recipe.substring(6, 9) };
|
||||||
{
|
Object mainMaterial = null;
|
||||||
return Items.iron_ingot;
|
for (String mat : type.matList) {
|
||||||
}
|
mainMaterial = translateOreName(mat);
|
||||||
else if (mat == "ingotGold")
|
addRecipe(new ItemStack(blockResult, 1, type.ordinal()), recipeSplit, 'm', mainMaterial, 'P', previousTier, /* previous chest tier */ 'G', Blocks.glass, 'C', Blocks.chest,
|
||||||
{
|
'0', new ItemStack(blockResult, 1, 0), /* Iron Chest */
|
||||||
return Items.gold_ingot;
|
'1', new ItemStack(blockResult, 1, 1), /* Gold Chest */
|
||||||
}
|
'2', new ItemStack(blockResult, 1, 2), /* Diamond Chest */
|
||||||
else if (mat == "gemDiamond")
|
'3', new ItemStack(blockResult, 1, 3), /* Copper Chest */
|
||||||
{
|
'4', new ItemStack(blockResult, 1, 4)/* Silver Chest */
|
||||||
return Items.diamond;
|
);
|
||||||
}
|
}
|
||||||
else if (mat == "blockGlass")
|
}
|
||||||
{
|
}
|
||||||
return Blocks.glass;
|
|
||||||
}
|
|
||||||
else if (mat == "obsidian")
|
|
||||||
{
|
|
||||||
return Blocks.obsidian;
|
|
||||||
}
|
|
||||||
else if (mat == "dirt")
|
|
||||||
{
|
|
||||||
return Blocks.dirt;
|
|
||||||
}
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addRecipe(ItemStack is, Object... parts)
|
public static Object translateOreName(String mat) {
|
||||||
{
|
if (mat == "ingotIron") {
|
||||||
ShapedOreRecipe oreRecipe = new ShapedOreRecipe(is, parts);
|
return Items.iron_ingot;
|
||||||
GameRegistry.addRecipe(oreRecipe);
|
} else if (mat == "ingotGold") {
|
||||||
}
|
return Items.gold_ingot;
|
||||||
|
} else if (mat == "gemDiamond") {
|
||||||
|
return Items.diamond;
|
||||||
|
} else if (mat == "blockGlass") {
|
||||||
|
return Blocks.glass;
|
||||||
|
} else if (mat == "obsidian") {
|
||||||
|
return Blocks.obsidian;
|
||||||
|
} else if (mat == "dirt") {
|
||||||
|
return Blocks.dirt;
|
||||||
|
}
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRowCount()
|
public static void addRecipe(ItemStack is, Object... parts) {
|
||||||
{
|
ShapedOreRecipe oreRecipe = new ShapedOreRecipe(is, parts);
|
||||||
return size / rowLength;
|
GameRegistry.addRecipe(oreRecipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRowLength()
|
public int getRowCount() {
|
||||||
{
|
return size / rowLength;
|
||||||
return rowLength;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTransparent()
|
public int getRowLength() {
|
||||||
{
|
return rowLength;
|
||||||
return this == CRYSTAL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getMatList()
|
public boolean isTransparent() {
|
||||||
{
|
return this == CRYSTAL;
|
||||||
return matList;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static int validateMeta(int i)
|
public List<String> getMatList() {
|
||||||
{
|
return matList;
|
||||||
if (i < values().length && values()[i].size > 0)
|
}
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValidForCreativeMode()
|
public static int validateMeta(int i) {
|
||||||
{
|
if (i < values().length && values()[i].size > 0) {
|
||||||
return validateMeta(ordinal()) == ordinal();
|
return i;
|
||||||
}
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isExplosionResistant()
|
public boolean isValidForCreativeMode() {
|
||||||
{
|
return validateMeta(ordinal()) == ordinal();
|
||||||
return this == OBSIDIAN;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
public boolean isExplosionResistant() {
|
||||||
private IIcon[] icons;
|
return this == OBSIDIAN;
|
||||||
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void makeIcons(IIconRegister par1IconRegister)
|
private IIcon[] icons;
|
||||||
{
|
|
||||||
if (isValidForCreativeMode())
|
|
||||||
{
|
|
||||||
icons = new IIcon[3];
|
|
||||||
int i = 0;
|
|
||||||
for (String s : sideNames)
|
|
||||||
{
|
|
||||||
icons[i++] = par1IconRegister.registerIcon(String.format("ironchest:%s_%s",name().toLowerCase(),s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public IIcon getIcon(int side)
|
public void makeIcons(IIconRegister par1IconRegister) {
|
||||||
{
|
if (isValidForCreativeMode()) {
|
||||||
|
icons = new IIcon[3];
|
||||||
|
int i = 0;
|
||||||
|
for (String s : sideNames) {
|
||||||
|
icons[i++] = par1IconRegister.registerIcon(String.format("ironchest:%s_%s", name().toLowerCase(), s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return icons[sideMapping[side]];
|
@SideOnly(Side.CLIENT)
|
||||||
}
|
public IIcon getIcon(int side) {
|
||||||
|
return icons[sideMapping[side]];
|
||||||
|
}
|
||||||
|
|
||||||
private static String[] sideNames = { "top", "front", "side" };
|
private static String[] sideNames = { "top", "front", "side" };
|
||||||
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
|
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
|
||||||
|
|
||||||
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
|
public Slot makeSlot(IInventory chestInventory, int index, int x, int y) {
|
||||||
{
|
return new ValidatingSlot(chestInventory, index, x, y, this);
|
||||||
return new ValidatingSlot(chestInventory, index, x, y, this);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean acceptsStack(ItemStack itemstack)
|
public boolean acceptsStack(ItemStack itemstack) {
|
||||||
{
|
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;
|
||||||
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;
|
}
|
||||||
}
|
|
||||||
public void adornItemDrop(ItemStack item)
|
public void adornItemDrop(ItemStack item) {
|
||||||
{
|
if (this == DIRTCHEST9000) {
|
||||||
if (this == DIRTCHEST9000)
|
item.setTagInfo("dirtchest", new NBTTagByte((byte) 1));
|
||||||
{
|
}
|
||||||
item.setTagInfo("dirtchest", new NBTTagByte((byte) 1));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,92 +14,72 @@ import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class ItemChestChanger extends Item {
|
public class ItemChestChanger extends Item {
|
||||||
|
private ChestChangerType type;
|
||||||
|
|
||||||
private ChestChangerType type;
|
public ItemChestChanger(ChestChangerType type) {
|
||||||
|
super();
|
||||||
|
setMaxStackSize(1);
|
||||||
|
this.type = type;
|
||||||
|
setUnlocalizedName("ironchest:" + type.name());
|
||||||
|
setCreativeTab(CreativeTabs.tabMisc);
|
||||||
|
}
|
||||||
|
|
||||||
public ItemChestChanger(ChestChangerType type)
|
@Override
|
||||||
{
|
@SideOnly(Side.CLIENT)
|
||||||
super();
|
public void registerIcons(IIconRegister par1IconRegister) {
|
||||||
setMaxStackSize(1);
|
this.itemIcon = par1IconRegister.registerIcon("ironchest:" + type.itemName);
|
||||||
this.type = type;
|
}
|
||||||
setUnlocalizedName("ironchest:"+type.name());
|
|
||||||
setCreativeTab(CreativeTabs.tabMisc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side, float hitX, float hitY, float hitZ) {
|
||||||
|
if (world.isRemote)
|
||||||
|
return false;
|
||||||
|
TileEntity te = world.getTileEntity(X, Y, Z);
|
||||||
|
TileEntityIronChest newchest;
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest ironchest = (TileEntityIronChest) te;
|
||||||
|
newchest = ironchest.applyUpgradeItem(this);
|
||||||
|
if (newchest == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (te != null && te instanceof TileEntityChest) {
|
||||||
|
TileEntityChest tec = (TileEntityChest) te;
|
||||||
|
if (tec.numPlayersUsing > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!getType().canUpgrade(IronChestType.WOOD)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// force the old tileentity out of the world so that adjacent chests can update
|
||||||
|
newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal()));
|
||||||
|
int newSize = newchest.chestContents.length;
|
||||||
|
ItemStack[] chestContents = ObfuscationReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0);
|
||||||
|
System.arraycopy(chestContents, 0, newchest.chestContents, 0, Math.min(newSize, chestContents.length));
|
||||||
|
BlockIronChest block = IronChest.ironChestBlock;
|
||||||
|
block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord);
|
||||||
|
newchest.setFacing((byte) tec.getBlockMetadata());
|
||||||
|
newchest.sortTopStacks();
|
||||||
|
for (int i = 0; i < Math.min(newSize, chestContents.length); i++) {
|
||||||
|
chestContents[i] = null;
|
||||||
|
}
|
||||||
|
world.setBlock(X, Y, Z, Blocks.air, 0, 3); // clear the old block out
|
||||||
|
tec.updateContainingBlockInfo(); // reset neighboring block knowledge
|
||||||
|
tec.checkForAdjacentChests(); // update neighboring blocks
|
||||||
|
world.setBlock(X, Y, Z, block, newchest.getType().ordinal(), 3); // add in the iron chest
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
world.setTileEntity(X, Y, Z, newchest);
|
||||||
|
world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal(), 3);
|
||||||
|
stack.stackSize = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public int getTargetChestOrdinal(int sourceOrdinal) {
|
||||||
@SideOnly(Side.CLIENT)
|
return type.getTarget();
|
||||||
public void registerIcons(IIconRegister par1IconRegister)
|
}
|
||||||
{
|
|
||||||
this.itemIcon = par1IconRegister.registerIcon("ironchest:"+type.itemName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public ChestChangerType getType() {
|
||||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side, float hitX, float hitY, float hitZ)
|
return type;
|
||||||
{
|
}
|
||||||
if (world.isRemote) return false;
|
}
|
||||||
TileEntity te = world.getTileEntity(X, Y, Z);
|
|
||||||
TileEntityIronChest newchest;
|
|
||||||
if (te != null && te instanceof TileEntityIronChest)
|
|
||||||
{
|
|
||||||
TileEntityIronChest ironchest = (TileEntityIronChest) te;
|
|
||||||
newchest = ironchest.applyUpgradeItem(this);
|
|
||||||
if (newchest == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (te != null && te instanceof TileEntityChest)
|
|
||||||
{
|
|
||||||
TileEntityChest tec = (TileEntityChest) te;
|
|
||||||
if (tec.numPlayersUsing > 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!getType().canUpgrade(IronChestType.WOOD))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Force old TE out of the world so that adjacent chests can update
|
|
||||||
newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal()));
|
|
||||||
int newSize = newchest.chestContents.length;
|
|
||||||
ItemStack[] chestContents = ObfuscationReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0);
|
|
||||||
System.arraycopy(chestContents, 0, newchest.chestContents, 0, Math.min(newSize, chestContents.length));
|
|
||||||
BlockIronChest block = IronChest.ironChestBlock;
|
|
||||||
block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord);
|
|
||||||
newchest.setFacing((byte) tec.getBlockMetadata());
|
|
||||||
newchest.sortTopStacks();
|
|
||||||
for (int i = 0; i < Math.min(newSize, chestContents.length); i++)
|
|
||||||
{
|
|
||||||
chestContents[i] = null;
|
|
||||||
}
|
|
||||||
// Clear the old block out
|
|
||||||
world.setBlock(X, Y, Z, Blocks.air, 0, 3);
|
|
||||||
// Force the Chest TE to reset it's knowledge of neighbouring blocks
|
|
||||||
tec.updateContainingBlockInfo();
|
|
||||||
// Force the Chest TE to update any neighbours so they update next
|
|
||||||
// tick
|
|
||||||
tec.checkForAdjacentChests();
|
|
||||||
// And put in our block instead
|
|
||||||
world.setBlock(X, Y, Z, block, newchest.getType().ordinal(), 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
world.setTileEntity(X, Y, Z, newchest);
|
|
||||||
world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal(), 3);
|
|
||||||
stack.stackSize = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTargetChestOrdinal(int sourceOrdinal)
|
|
||||||
{
|
|
||||||
return type.getTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChestChangerType getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,23 +5,19 @@ import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemIronChest extends ItemBlock {
|
public class ItemIronChest extends ItemBlock {
|
||||||
|
public ItemIronChest(Block block) {
|
||||||
|
super(block);
|
||||||
|
setMaxDamage(0);
|
||||||
|
setHasSubtypes(true);
|
||||||
|
}
|
||||||
|
|
||||||
public ItemIronChest(Block block)
|
@Override
|
||||||
{
|
public int getMetadata(int i) {
|
||||||
super(block);
|
return IronChestType.validateMeta(i);
|
||||||
setMaxDamage(0);
|
}
|
||||||
setHasSubtypes(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetadata(int i)
|
public String getUnlocalizedName(ItemStack itemstack) {
|
||||||
{
|
return "tile.ironchest:" + IronChestType.values()[itemstack.getItemDamage()].name();
|
||||||
return IronChestType.validateMeta(i);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName(ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return "tile.ironchest:"+IronChestType.values()[itemstack.getItemDamage()].name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,31 +3,26 @@ package cpw.mods.ironchest;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class MappableItemStackWrapper {
|
public class MappableItemStackWrapper {
|
||||||
private ItemStack wrap;
|
private ItemStack wrap;
|
||||||
|
|
||||||
public MappableItemStackWrapper(ItemStack toWrap)
|
public MappableItemStackWrapper(ItemStack toWrap) {
|
||||||
{
|
wrap = toWrap;
|
||||||
wrap = toWrap;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj) {
|
||||||
{
|
if (!(obj instanceof MappableItemStackWrapper))
|
||||||
if (!(obj instanceof MappableItemStackWrapper)) return false;
|
return false;
|
||||||
MappableItemStackWrapper isw = (MappableItemStackWrapper) obj;
|
MappableItemStackWrapper isw = (MappableItemStackWrapper) obj;
|
||||||
if (wrap.getHasSubtypes())
|
if (wrap.getHasSubtypes()) {
|
||||||
{
|
return isw.wrap.isItemEqual(wrap);
|
||||||
return isw.wrap.isItemEqual(wrap);
|
} else {
|
||||||
}
|
return isw.wrap == wrap;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return isw.wrap == wrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode() {
|
||||||
{
|
return System.identityHashCode(wrap);
|
||||||
return System.identityHashCode(wrap);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,9 @@ package cpw.mods.ironchest;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
@ -17,174 +19,155 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the packet wrangling for IronChest
|
* Handles the packet wrangling for IronChest
|
||||||
|
*
|
||||||
* @author cpw
|
* @author cpw
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum PacketHandler {
|
public enum PacketHandler {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our channel "pair" from {@link NetworkRegistry}
|
* Our channel "pair" from {@link NetworkRegistry}
|
||||||
*/
|
*/
|
||||||
private EnumMap<Side, FMLEmbeddedChannel> channels;
|
private EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make our packet handler, and add an {@link IronChestCodec} always
|
* Make our packet handler, and add an {@link IronChestCodec} always
|
||||||
*/
|
*/
|
||||||
private PacketHandler()
|
private PacketHandler() {
|
||||||
{
|
// request a channel pair for IronChest from the network registry
|
||||||
// request a channel pair for IronChest from the network registry
|
// Add the IronChestCodec as a member of both channel pipelines
|
||||||
// Add the IronChestCodec as a member of both channel pipelines
|
this.channels = NetworkRegistry.INSTANCE.newChannel("IronChest", new IronChestCodec());
|
||||||
this.channels = NetworkRegistry.INSTANCE.newChannel("IronChest", new IronChestCodec());
|
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
|
||||||
if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
|
addClientHandler();
|
||||||
{
|
}
|
||||||
addClientHandler();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is only called on the client side - it adds an
|
* This is only called on the client side - it adds an
|
||||||
* {@link IronChestMessageHandler} to the client side pipeline, since the
|
* {@link IronChestMessageHandler} to the client side pipeline, since the
|
||||||
* only place we expect to <em>handle</em> messages is on the client.
|
* only place we expect to <em>handle</em> messages is on the client.
|
||||||
*/
|
*/
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
private void addClientHandler() {
|
private void addClientHandler() {
|
||||||
FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT);
|
FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT);
|
||||||
// These two lines find the existing codec (Ironchestcodec) and insert our message handler after it
|
// These two lines find the existing codec (Ironchestcodec) and insert
|
||||||
// in the pipeline
|
// our message handler after it in the pipeline
|
||||||
String codec = clientChannel.findChannelHandlerNameForType(IronChestCodec.class);
|
String codec = clientChannel.findChannelHandlerNameForType(IronChestCodec.class);
|
||||||
clientChannel.pipeline().addAfter(codec, "ClientHandler", new IronChestMessageHandler());
|
clientChannel.pipeline().addAfter(codec, "ClientHandler", new IronChestMessageHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class simply handles the {@link IronChestMessage} when it's received
|
* This class simply handles the {@link IronChestMessage} when it's received
|
||||||
* at the client side It can contain client only code, because it's only run
|
* at the client side It can contain client only code, because it's only run
|
||||||
* on the client.
|
* on the client.
|
||||||
*
|
*
|
||||||
* @author cpw
|
* @author cpw
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static class IronChestMessageHandler extends SimpleChannelInboundHandler<IronChestMessage>
|
private static class IronChestMessageHandler extends SimpleChannelInboundHandler<IronChestMessage> {
|
||||||
{
|
@Override
|
||||||
@Override
|
protected void channelRead0(ChannelHandlerContext ctx, IronChestMessage msg) throws Exception {
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, IronChestMessage msg) throws Exception
|
World world = IronChest.proxy.getClientWorld();
|
||||||
{
|
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
|
||||||
World world = IronChest.proxy.getClientWorld();
|
if (te instanceof TileEntityIronChest) {
|
||||||
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
|
TileEntityIronChest icte = (TileEntityIronChest) te;
|
||||||
if (te instanceof TileEntityIronChest)
|
icte.setFacing(msg.facing);
|
||||||
{
|
icte.handlePacketData(msg.type, msg.items);
|
||||||
TileEntityIronChest icte = (TileEntityIronChest) te;
|
}
|
||||||
icte.setFacing(msg.facing);
|
}
|
||||||
icte.handlePacketData(msg.type, msg.items);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is our "message". In fact, {@link FMLIndexedMessageToMessageCodec}
|
* This is our "message". In fact, {@link FMLIndexedMessageToMessageCodec}
|
||||||
* can handle many messages on the same channel at once, using a
|
* can handle many messages on the same channel at once, using a
|
||||||
* discriminator byte. But for IronChest, we only need the one message, so
|
* discriminator byte. But for IronChest, we only need the one message, so
|
||||||
* we have just this.
|
* we have just this.
|
||||||
*
|
*
|
||||||
* @author cpw
|
* @author cpw
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static class IronChestMessage
|
public static class IronChestMessage {
|
||||||
{
|
int x, y, z, type, facing, items[];
|
||||||
int x;
|
}
|
||||||
int y;
|
|
||||||
int z;
|
|
||||||
int type;
|
|
||||||
int facing;
|
|
||||||
int[] items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the codec that automatically transforms the
|
* This is the codec that automatically transforms the
|
||||||
* {@link FMLProxyPacket} which wraps the client and server custom payload
|
* {@link FMLProxyPacket} which wraps the client and server custom payload
|
||||||
* packets into a message we care about.
|
* packets into a message we care about.
|
||||||
*
|
*
|
||||||
* @author cpw
|
* @author cpw
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class IronChestCodec extends FMLIndexedMessageToMessageCodec<IronChestMessage>
|
private class IronChestCodec extends FMLIndexedMessageToMessageCodec<IronChestMessage> {
|
||||||
{
|
/**
|
||||||
/**
|
* We register our discriminator bytes here. We only have the one type,
|
||||||
* We register our discriminator bytes here. We only have the one type, so we only
|
* so we only register one.
|
||||||
* register one.
|
*/
|
||||||
*/
|
public IronChestCodec() {
|
||||||
public IronChestCodec()
|
addDiscriminator(0, IronChestMessage.class);
|
||||||
{
|
}
|
||||||
addDiscriminator(0, IronChestMessage.class);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void encodeInto(ChannelHandlerContext ctx, IronChestMessage msg, ByteBuf target) throws Exception
|
|
||||||
{
|
|
||||||
target.writeInt(msg.x);
|
|
||||||
target.writeInt(msg.y);
|
|
||||||
target.writeInt(msg.z);
|
|
||||||
int typeAndFacing = ((msg.type & 0x0F) | ((msg.facing & 0x0F) << 4)) & 0xFF;
|
|
||||||
target.writeByte(typeAndFacing);
|
|
||||||
target.writeBoolean(msg.items != null);
|
|
||||||
if (msg.items != null)
|
|
||||||
{
|
|
||||||
int[] items = msg.items;
|
|
||||||
for (int j = 0; j < items.length; j++)
|
|
||||||
{
|
|
||||||
int i = items[j];
|
|
||||||
target.writeInt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf dat, IronChestMessage msg)
|
public void encodeInto(ChannelHandlerContext ctx, IronChestMessage msg, ByteBuf target) throws Exception {
|
||||||
{
|
target.writeInt(msg.x);
|
||||||
msg.x = dat.readInt();
|
target.writeInt(msg.y);
|
||||||
msg.y = dat.readInt();
|
target.writeInt(msg.z);
|
||||||
msg.z = dat.readInt();
|
int typeAndFacing = ((msg.type & 0x0F) | ((msg.facing & 0x0F) << 4)) & 0xFF;
|
||||||
int typDat = dat.readByte();
|
target.writeByte(typeAndFacing);
|
||||||
msg.type = (byte)(typDat & 0xf);
|
target.writeBoolean(msg.items != null);
|
||||||
msg.facing = (byte)((typDat >> 4) & 0xf);
|
if (msg.items != null) {
|
||||||
boolean hasStacks = dat.readBoolean();
|
int[] items = msg.items;
|
||||||
msg.items = new int[0];
|
for (int j = 0; j < items.length; j++) {
|
||||||
if (hasStacks)
|
int i = items[j];
|
||||||
{
|
target.writeInt(i);
|
||||||
msg.items = new int[24];
|
}
|
||||||
for (int i = 0; i < msg.items.length; i++)
|
}
|
||||||
{
|
}
|
||||||
msg.items[i] = dat.readInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void decodeInto(ChannelHandlerContext ctx, ByteBuf dat, IronChestMessage msg) {
|
||||||
|
msg.x = dat.readInt();
|
||||||
|
msg.y = dat.readInt();
|
||||||
|
msg.z = dat.readInt();
|
||||||
|
int typDat = dat.readByte();
|
||||||
|
msg.type = (byte) (typDat & 0xf);
|
||||||
|
msg.facing = (byte) ((typDat >> 4) & 0xf);
|
||||||
|
boolean hasStacks = dat.readBoolean();
|
||||||
|
msg.items = new int[0];
|
||||||
|
if (hasStacks) {
|
||||||
|
msg.items = new int[24];
|
||||||
|
for (int i = 0; i < msg.items.length; i++) {
|
||||||
|
msg.items[i] = dat.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a utility method called to transform a packet from a custom
|
* This is a utility method called to transform a packet from a custom
|
||||||
* packet into a "system packet". We're called from
|
* packet into a "system packet". We're called from
|
||||||
* {@link TileEntity#getDescriptionPacket()} in this case, but there are
|
* {@link TileEntity#getDescriptionPacket()} in this case, but there are
|
||||||
* others. All network packet methods in minecraft have been adapted to
|
* others. All network packet methods in minecraft have been adapted to
|
||||||
* handle {@link FMLProxyPacket} but general purpose objects can't be
|
* handle {@link FMLProxyPacket} but general purpose objects can't be
|
||||||
* handled sadly.
|
* handled sadly.
|
||||||
*
|
*
|
||||||
* This method uses the {@link IronChestCodec} to transform a custom packet
|
* This method uses the {@link IronChestCodec} to transform a custom packet
|
||||||
* {@link IronChestMessage} into an {@link FMLProxyPacket} by using the
|
* {@link IronChestMessage} into an {@link FMLProxyPacket} by using the
|
||||||
* utility method {@link FMLEmbeddedChannel#generatePacketFrom(Object)} on
|
* utility method {@link FMLEmbeddedChannel#generatePacketFrom(Object)} on
|
||||||
* the channel to do exactly that.
|
* the channel to do exactly that.
|
||||||
*
|
*
|
||||||
* @param tileEntityIronChest
|
* @param tileEntityIronChest
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Packet getPacket(TileEntityIronChest tileEntityIronChest)
|
public static Packet getPacket(TileEntityIronChest tileEntityIronChest) {
|
||||||
{
|
IronChestMessage msg = new IronChestMessage();
|
||||||
IronChestMessage msg = new IronChestMessage();
|
msg.x = tileEntityIronChest.xCoord;
|
||||||
msg.x = tileEntityIronChest.xCoord;
|
msg.y = tileEntityIronChest.yCoord;
|
||||||
msg.y = tileEntityIronChest.yCoord;
|
msg.z = tileEntityIronChest.zCoord;
|
||||||
msg.z = tileEntityIronChest.zCoord;
|
msg.type = tileEntityIronChest.getType().ordinal();
|
||||||
msg.type = tileEntityIronChest.getType().ordinal();
|
msg.facing = tileEntityIronChest.getFacing();
|
||||||
msg.facing = tileEntityIronChest.getFacing();
|
msg.items = tileEntityIronChest.buildIntDataList();
|
||||||
msg.items = tileEntityIronChest.buildIntDataList();
|
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
||||||
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntityCopperChest extends TileEntityIronChest {
|
public class TileEntityCopperChest extends TileEntityIronChest {
|
||||||
public TileEntityCopperChest()
|
public TileEntityCopperChest() {
|
||||||
{
|
super(IronChestType.COPPER);
|
||||||
super(IronChestType.COPPER);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntityCrystalChest extends TileEntityIronChest {
|
public class TileEntityCrystalChest extends TileEntityIronChest {
|
||||||
public TileEntityCrystalChest()
|
public TileEntityCrystalChest() {
|
||||||
{
|
super(IronChestType.CRYSTAL);
|
||||||
super(IronChestType.CRYSTAL);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntityDiamondChest extends TileEntityIronChest {
|
public class TileEntityDiamondChest extends TileEntityIronChest {
|
||||||
public TileEntityDiamondChest()
|
public TileEntityDiamondChest() {
|
||||||
{
|
super(IronChestType.DIAMOND);
|
||||||
super(IronChestType.DIAMOND);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -8,35 +8,35 @@ import net.minecraft.nbt.NBTTagString;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
public class TileEntityDirtChest extends TileEntityIronChest {
|
public class TileEntityDirtChest extends TileEntityIronChest {
|
||||||
private static ItemStack dirtChest9000GuideBook = new ItemStack(Items.written_book);
|
private static ItemStack dirtChest9000GuideBook = new ItemStack(Items.written_book);
|
||||||
static {
|
|
||||||
dirtChest9000GuideBook.setTagInfo("author", new NBTTagString("cpw"));
|
|
||||||
dirtChest9000GuideBook.setTagInfo("title", new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.title")));
|
|
||||||
NBTTagList pages = new NBTTagList();
|
|
||||||
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page1")));
|
|
||||||
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page2")));
|
|
||||||
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page3")));
|
|
||||||
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page4")));
|
|
||||||
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page5")));
|
|
||||||
dirtChest9000GuideBook.setTagInfo("pages", pages);
|
|
||||||
}
|
|
||||||
public TileEntityDirtChest() {
|
|
||||||
super(IronChestType.DIRTCHEST9000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
static {
|
||||||
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack)
|
dirtChest9000GuideBook.setTagInfo("author", new NBTTagString("cpw"));
|
||||||
{
|
dirtChest9000GuideBook.setTagInfo("title", new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.title")));
|
||||||
if (!(itemStack.hasTagCompound() && itemStack.getTagCompound().getBoolean("dirtchest"))) {
|
NBTTagList pages = new NBTTagList();
|
||||||
setInventorySlotContents(0, dirtChest9000GuideBook.copy());
|
pages.appendTag(new NBTTagString(StatCollector .translateToLocal("book.ironchest:dirtchest9000.page1")));
|
||||||
}
|
pages.appendTag(new NBTTagString(StatCollector .translateToLocal("book.ironchest:dirtchest9000.page2")));
|
||||||
}
|
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page3")));
|
||||||
|
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page4")));
|
||||||
|
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page5")));
|
||||||
|
dirtChest9000GuideBook.setTagInfo("pages", pages);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public TileEntityDirtChest() {
|
||||||
public void removeAdornments()
|
super(IronChestType.DIRTCHEST9000);
|
||||||
{
|
}
|
||||||
if (chestContents[0] != null && chestContents[0].isItemEqual(dirtChest9000GuideBook)) {
|
|
||||||
chestContents[0] = null;
|
@Override
|
||||||
}
|
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack) {
|
||||||
}
|
if (!(itemStack.hasTagCompound() && itemStack.getTagCompound().getBoolean("dirtchest"))) {
|
||||||
}
|
setInventorySlotContents(0, dirtChest9000GuideBook.copy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAdornments() {
|
||||||
|
if (chestContents[0] != null && chestContents[0].isItemEqual(dirtChest9000GuideBook)) {
|
||||||
|
chestContents[0] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntityGoldChest extends TileEntityIronChest {
|
public class TileEntityGoldChest extends TileEntityIronChest {
|
||||||
public TileEntityGoldChest()
|
public TileEntityGoldChest() {
|
||||||
{
|
super(IronChestType.GOLD);
|
||||||
super(IronChestType.GOLD);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -19,504 +19,377 @@ import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityIronChest extends TileEntity implements IInventory {
|
public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
private int ticksSinceSync = -1;
|
private int ticksSinceSync = -1, numUsingPlayers, facing;
|
||||||
public float prevLidAngle;
|
public float prevLidAngle, lidAngle;
|
||||||
public float lidAngle;
|
private IronChestType type;
|
||||||
private int numUsingPlayers;
|
public ItemStack[] chestContents, topStacks;
|
||||||
private IronChestType type;
|
private boolean inventoryTouched, hadStuff;
|
||||||
public ItemStack[] chestContents;
|
|
||||||
private ItemStack[] topStacks;
|
|
||||||
private int facing;
|
|
||||||
private boolean inventoryTouched;
|
|
||||||
private boolean hadStuff;
|
|
||||||
|
|
||||||
public TileEntityIronChest()
|
public TileEntityIronChest() {
|
||||||
{
|
this(IronChestType.IRON);
|
||||||
this(IronChestType.IRON);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected TileEntityIronChest(IronChestType type)
|
protected TileEntityIronChest(IronChestType type) {
|
||||||
{
|
super();
|
||||||
super();
|
this.type = type;
|
||||||
this.type = type;
|
chestContents = new ItemStack[getSizeInventory()];
|
||||||
this.chestContents = new ItemStack[getSizeInventory()];
|
topStacks = new ItemStack[8];
|
||||||
this.topStacks = new ItemStack[8];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getContents()
|
public ItemStack[] getContents() {
|
||||||
{
|
return chestContents;
|
||||||
return chestContents;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory() {
|
||||||
{
|
return type.size;
|
||||||
return type.size;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getFacing()
|
public int getFacing() {
|
||||||
{
|
return facing;
|
||||||
return this.facing;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInventoryName()
|
public String getInventoryName() {
|
||||||
{
|
return type.name();
|
||||||
return type.name();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public IronChestType getType()
|
public IronChestType getType() {
|
||||||
{
|
return type;
|
||||||
return type;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int i)
|
public ItemStack getStackInSlot(int i) {
|
||||||
{
|
inventoryTouched = true;
|
||||||
inventoryTouched = true;
|
return chestContents[i];
|
||||||
return chestContents[i];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markDirty()
|
public void markDirty() {
|
||||||
{
|
super.markDirty();
|
||||||
super.markDirty();
|
sortTopStacks();
|
||||||
sortTopStacks();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void sortTopStacks()
|
protected void sortTopStacks() {
|
||||||
{
|
if (!type.isTransparent() || (worldObj != null && worldObj.isRemote)) {
|
||||||
if (!type.isTransparent() || (worldObj != null && worldObj.isRemote))
|
return;
|
||||||
{
|
}
|
||||||
return;
|
ItemStack[] tempCopy = new ItemStack[getSizeInventory()];
|
||||||
}
|
boolean hasStuff = false;
|
||||||
ItemStack[] tempCopy = new ItemStack[getSizeInventory()];
|
int compressedIdx = 0;
|
||||||
boolean hasStuff = false;
|
mainLoop: for (int i = 0; i < getSizeInventory(); i++) {
|
||||||
int compressedIdx = 0;
|
if (chestContents[i] != null) {
|
||||||
mainLoop: for (int i = 0; i < getSizeInventory(); i++)
|
for (int j = 0; j < compressedIdx; j++) {
|
||||||
{
|
if (tempCopy[j].isItemEqual(chestContents[i])) {
|
||||||
if (chestContents[i] != null)
|
tempCopy[j].stackSize += chestContents[i].stackSize;
|
||||||
{
|
continue mainLoop;
|
||||||
for (int j = 0; j < compressedIdx; j++)
|
}
|
||||||
{
|
}
|
||||||
if (tempCopy[j].isItemEqual(chestContents[i]))
|
tempCopy[compressedIdx++] = chestContents[i].copy();
|
||||||
{
|
hasStuff = true;
|
||||||
tempCopy[j].stackSize += chestContents[i].stackSize;
|
}
|
||||||
continue mainLoop;
|
}
|
||||||
}
|
if (!hasStuff && hadStuff) {
|
||||||
}
|
hadStuff = false;
|
||||||
tempCopy[compressedIdx++] = chestContents[i].copy();
|
for (int i = 0; i < topStacks.length; i++) {
|
||||||
hasStuff = true;
|
topStacks[i] = null;
|
||||||
}
|
}
|
||||||
}
|
if (worldObj != null) {
|
||||||
if (!hasStuff && hadStuff)
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
{
|
}
|
||||||
hadStuff = false;
|
return;
|
||||||
for (int i = 0; i < topStacks.length; i++)
|
}
|
||||||
{
|
hadStuff = true;
|
||||||
topStacks[i] = null;
|
Arrays.sort(tempCopy, new Comparator<ItemStack>() {
|
||||||
}
|
@Override
|
||||||
if (worldObj != null)
|
public int compare(ItemStack o1, ItemStack o2) {
|
||||||
{
|
if (o1 == null) {
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
return 1;
|
||||||
}
|
} else if (o2 == null) {
|
||||||
return;
|
return -1;
|
||||||
}
|
} else {
|
||||||
hadStuff = true;
|
return o2.stackSize - o1.stackSize;
|
||||||
Arrays.sort(tempCopy, new Comparator<ItemStack>() {
|
}
|
||||||
@Override
|
}
|
||||||
public int compare(ItemStack o1, ItemStack o2)
|
});
|
||||||
{
|
int p = 0;
|
||||||
if (o1 == null)
|
for (int i = 0; i < tempCopy.length; i++) {
|
||||||
{
|
if (tempCopy[i] != null && tempCopy[i].stackSize > 0) {
|
||||||
return 1;
|
topStacks[p++] = tempCopy[i];
|
||||||
}
|
if (p == topStacks.length) {
|
||||||
else if (o2 == null)
|
break;
|
||||||
{
|
}
|
||||||
return -1;
|
}
|
||||||
}
|
}
|
||||||
else
|
for (int i = p; i < topStacks.length; i++) {
|
||||||
{
|
topStacks[i] = null;
|
||||||
return o2.stackSize - o1.stackSize;
|
}
|
||||||
}
|
if (worldObj != null) {
|
||||||
}
|
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||||
});
|
}
|
||||||
int p = 0;
|
}
|
||||||
for (int i = 0; i < tempCopy.length; i++)
|
|
||||||
{
|
|
||||||
if (tempCopy[i] != null && tempCopy[i].stackSize > 0)
|
|
||||||
{
|
|
||||||
topStacks[p++] = tempCopy[i];
|
|
||||||
if (p == topStacks.length)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = p; i < topStacks.length; i++)
|
|
||||||
{
|
|
||||||
topStacks[i] = null;
|
|
||||||
}
|
|
||||||
if (worldObj != null)
|
|
||||||
{
|
|
||||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int i, int j)
|
public ItemStack decrStackSize(int i, int j) {
|
||||||
{
|
if (chestContents[i] != null) {
|
||||||
if (chestContents[i] != null)
|
if (chestContents[i].stackSize <= j) {
|
||||||
{
|
ItemStack itemstack = chestContents[i];
|
||||||
if (chestContents[i].stackSize <= j)
|
chestContents[i] = null;
|
||||||
{
|
markDirty();
|
||||||
ItemStack itemstack = chestContents[i];
|
return itemstack;
|
||||||
chestContents[i] = null;
|
}
|
||||||
markDirty();
|
ItemStack itemstack1 = chestContents[i].splitStack(j);
|
||||||
return itemstack;
|
if (chestContents[i].stackSize == 0) {
|
||||||
}
|
chestContents[i] = null;
|
||||||
ItemStack itemstack1 = chestContents[i].splitStack(j);
|
}
|
||||||
if (chestContents[i].stackSize == 0)
|
markDirty();
|
||||||
{
|
return itemstack1;
|
||||||
chestContents[i] = null;
|
} else {
|
||||||
}
|
return null;
|
||||||
markDirty();
|
}
|
||||||
return itemstack1;
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||||
{
|
chestContents[i] = itemstack;
|
||||||
chestContents[i] = itemstack;
|
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
|
||||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
itemstack.stackSize = getInventoryStackLimit();
|
||||||
{
|
}
|
||||||
itemstack.stackSize = getInventoryStackLimit();
|
markDirty();
|
||||||
}
|
}
|
||||||
markDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
{
|
super.readFromNBT(nbt);
|
||||||
super.readFromNBT(nbttagcompound);
|
NBTTagList nbttaglist = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
chestContents = new ItemStack[getSizeInventory()];
|
||||||
chestContents = new ItemStack[getSizeInventory()];
|
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||||
for (int i = 0; i < nbttaglist.tagCount(); i++)
|
NBTTagCompound nbt1 = nbttaglist.getCompoundTagAt(i);
|
||||||
{
|
int j = nbt1.getByte("Slot") & 0xff;
|
||||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
if (j >= 0 && j < chestContents.length) {
|
||||||
int j = nbttagcompound1.getByte("Slot") & 0xff;
|
chestContents[j] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||||
if (j >= 0 && j < chestContents.length)
|
}
|
||||||
{
|
}
|
||||||
chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
facing = nbt.getByte("facing");
|
||||||
}
|
sortTopStacks();
|
||||||
}
|
}
|
||||||
facing = nbttagcompound.getByte("facing");
|
|
||||||
sortTopStacks();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
{
|
super.writeToNBT(nbt);
|
||||||
super.writeToNBT(nbttagcompound);
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
NBTTagList nbttaglist = new NBTTagList();
|
for (int i = 0; i < chestContents.length; i++) {
|
||||||
for (int i = 0; i < chestContents.length; i++)
|
if (chestContents[i] != null) {
|
||||||
{
|
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||||
if (chestContents[i] != null)
|
nbt1.setByte("Slot", (byte) i);
|
||||||
{
|
chestContents[i].writeToNBT(nbt1);
|
||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
nbttaglist.appendTag(nbt1);
|
||||||
nbttagcompound1.setByte("Slot", (byte) i);
|
}
|
||||||
chestContents[i].writeToNBT(nbttagcompound1);
|
}
|
||||||
nbttaglist.appendTag(nbttagcompound1);
|
nbt.setTag("Items", nbttaglist);
|
||||||
}
|
nbt.setByte("facing", (byte) facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
nbttagcompound.setTag("Items", nbttaglist);
|
@Override
|
||||||
nbttagcompound.setByte("facing", (byte)facing);
|
public int getInventoryStackLimit() {
|
||||||
}
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInventoryStackLimit()
|
public boolean isUseableByPlayer(final EntityPlayer player) {
|
||||||
{
|
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64.0;
|
||||||
return 64;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
public void updateEntity() {
|
||||||
{
|
super.updateEntity();
|
||||||
if (worldObj == null)
|
if (worldObj != null && !worldObj.isRemote && numUsingPlayers != 0 && (ticksSinceSync + xCoord + yCoord + zCoord) % 200 == 0) {
|
||||||
{
|
numUsingPlayers = 0;
|
||||||
return true;
|
float var1 = 5.0F;
|
||||||
}
|
List<EntityPlayer> var2 = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB((double) ((float) xCoord - var1), (double) ((float) yCoord - var1), (double) ((float) zCoord - var1), (double) ((float) (xCoord + 1) + var1), (double) ((float) (yCoord + 1) + var1), (double) ((float) (zCoord + 1) + var1)));
|
||||||
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
Iterator<EntityPlayer> var3 = var2.iterator();
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
while (var3.hasNext()) {
|
||||||
public void updateEntity()
|
EntityPlayer var4 = var3.next();
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
// Resynchronize clients with the server state
|
|
||||||
if (worldObj != null && !this.worldObj.isRemote && this.numUsingPlayers != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0)
|
|
||||||
{
|
|
||||||
this.numUsingPlayers = 0;
|
|
||||||
float var1 = 5.0F;
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<EntityPlayer> var2 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)this.xCoord - var1), (double)((float)this.yCoord - var1), (double)((float)this.zCoord - var1), (double)((float)(this.xCoord + 1) + var1), (double)((float)(this.yCoord + 1) + var1), (double)((float)(this.zCoord + 1) + var1)));
|
|
||||||
Iterator<EntityPlayer> var3 = var2.iterator();
|
|
||||||
|
|
||||||
while (var3.hasNext())
|
if (var4.openContainer instanceof ContainerIronChest) {
|
||||||
{
|
++numUsingPlayers;
|
||||||
EntityPlayer var4 = var3.next();
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (var4.openContainer instanceof ContainerIronChest)
|
if (worldObj != null && !worldObj.isRemote && ticksSinceSync < 0) {
|
||||||
{
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
||||||
++this.numUsingPlayers;
|
}
|
||||||
}
|
if (!worldObj.isRemote && inventoryTouched) {
|
||||||
}
|
inventoryTouched = false;
|
||||||
}
|
sortTopStacks();
|
||||||
|
}
|
||||||
|
|
||||||
if (worldObj != null && !worldObj.isRemote && ticksSinceSync < 0)
|
ticksSinceSync++;
|
||||||
{
|
prevLidAngle = lidAngle;
|
||||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
float f = 0.1F;
|
||||||
}
|
if (numUsingPlayers > 0 && lidAngle == 0.0F) {
|
||||||
if (!worldObj.isRemote && inventoryTouched)
|
double d = (double) xCoord + 0.5D;
|
||||||
{
|
double d1 = (double) zCoord + 0.5D;
|
||||||
inventoryTouched = false;
|
worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
sortTopStacks();
|
}
|
||||||
}
|
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0
|
||||||
|
&& lidAngle < 1.0F) {
|
||||||
|
float f1 = lidAngle;
|
||||||
|
if (numUsingPlayers > 0) {
|
||||||
|
lidAngle += f;
|
||||||
|
} else {
|
||||||
|
lidAngle -= f;
|
||||||
|
}
|
||||||
|
if (lidAngle > 1.0F) {
|
||||||
|
lidAngle = 1.0F;
|
||||||
|
}
|
||||||
|
float f2 = 0.5F;
|
||||||
|
if (lidAngle < f2 && f1 >= f2) {
|
||||||
|
double d2 = (double) xCoord + 0.5D;
|
||||||
|
double d3 = (double) zCoord + 0.5D;
|
||||||
|
worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
|
}
|
||||||
|
if (lidAngle < 0.0F) {
|
||||||
|
lidAngle = 0.0F;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.ticksSinceSync++;
|
@Override
|
||||||
prevLidAngle = lidAngle;
|
public boolean receiveClientEvent(int i, int j) {
|
||||||
float f = 0.1F;
|
if (i == 1) {
|
||||||
if (numUsingPlayers > 0 && lidAngle == 0.0F)
|
numUsingPlayers = j;
|
||||||
{
|
} else if (i == 2) {
|
||||||
double d = (double) xCoord + 0.5D;
|
facing = (byte) j;
|
||||||
double d1 = (double) zCoord + 0.5D;
|
} else if (i == 3) {
|
||||||
worldObj.playSoundEffect(d, (double) yCoord + 0.5D, d1, "random.chestopen", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
facing = (byte) (j & 0x7);
|
||||||
}
|
numUsingPlayers = (j & 0xF8) >> 3;
|
||||||
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F)
|
}
|
||||||
{
|
return true;
|
||||||
float f1 = lidAngle;
|
}
|
||||||
if (numUsingPlayers > 0)
|
|
||||||
{
|
|
||||||
lidAngle += f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lidAngle -= f;
|
|
||||||
}
|
|
||||||
if (lidAngle > 1.0F)
|
|
||||||
{
|
|
||||||
lidAngle = 1.0F;
|
|
||||||
}
|
|
||||||
float f2 = 0.5F;
|
|
||||||
if (lidAngle < f2 && f1 >= f2)
|
|
||||||
{
|
|
||||||
double d2 = (double) xCoord + 0.5D;
|
|
||||||
double d3 = (double) zCoord + 0.5D;
|
|
||||||
worldObj.playSoundEffect(d2, (double) yCoord + 0.5D, d3, "random.chestclosed", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
|
||||||
}
|
|
||||||
if (lidAngle < 0.0F)
|
|
||||||
{
|
|
||||||
lidAngle = 0.0F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean receiveClientEvent(int i, int j)
|
public void openInventory() {
|
||||||
{
|
++numUsingPlayers;
|
||||||
if (i == 1)
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 1, numUsingPlayers);
|
||||||
{
|
}
|
||||||
numUsingPlayers = j;
|
|
||||||
}
|
|
||||||
else if (i == 2)
|
|
||||||
{
|
|
||||||
facing = (byte) j;
|
|
||||||
}
|
|
||||||
else if (i == 3)
|
|
||||||
{
|
|
||||||
facing = (byte) (j & 0x7);
|
|
||||||
numUsingPlayers = (j & 0xF8) >> 3;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openInventory()
|
public void closeInventory() {
|
||||||
{
|
--numUsingPlayers;
|
||||||
if (worldObj == null) return;
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 1, numUsingPlayers);
|
||||||
numUsingPlayers++;
|
}
|
||||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 1, numUsingPlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void setFacing(int facing2) {
|
||||||
public void closeInventory()
|
facing = facing2;
|
||||||
{
|
}
|
||||||
if (worldObj == null) return;
|
|
||||||
numUsingPlayers--;
|
|
||||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 1, numUsingPlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFacing(int facing2)
|
public TileEntityIronChest applyUpgradeItem(ItemChestChanger itemChestChanger) {
|
||||||
{
|
if (numUsingPlayers > 0 || !itemChestChanger.getType().canUpgrade(getType())) {
|
||||||
this.facing = facing2;
|
return null;
|
||||||
}
|
}
|
||||||
|
TileEntityIronChest newEntity = IronChestType.makeEntity(itemChestChanger.getTargetChestOrdinal(getType().ordinal()));
|
||||||
|
int newSize = newEntity.chestContents.length;
|
||||||
|
System.arraycopy(chestContents, 0, newEntity.chestContents, 0, Math.min(newSize, chestContents.length));
|
||||||
|
BlockIronChest block = IronChest.ironChestBlock;
|
||||||
|
block.dropContent(newSize, this, worldObj, xCoord, yCoord, zCoord);
|
||||||
|
newEntity.setFacing(facing);
|
||||||
|
newEntity.sortTopStacks();
|
||||||
|
newEntity.ticksSinceSync = -1;
|
||||||
|
return newEntity;
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntityIronChest applyUpgradeItem(ItemChestChanger itemChestChanger)
|
public ItemStack[] getTopItemStacks() {
|
||||||
{
|
return topStacks;
|
||||||
if (numUsingPlayers > 0)
|
}
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!itemChestChanger.getType().canUpgrade(this.getType()))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
TileEntityIronChest newEntity = IronChestType.makeEntity(itemChestChanger.getTargetChestOrdinal(getType().ordinal()));
|
|
||||||
int newSize = newEntity.chestContents.length;
|
|
||||||
System.arraycopy(chestContents, 0, newEntity.chestContents, 0, Math.min(newSize, chestContents.length));
|
|
||||||
BlockIronChest block = IronChest.ironChestBlock;
|
|
||||||
block.dropContent(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
|
||||||
newEntity.setFacing(facing);
|
|
||||||
newEntity.sortTopStacks();
|
|
||||||
newEntity.ticksSinceSync = -1;
|
|
||||||
return newEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getTopItemStacks()
|
public TileEntityIronChest updateFromMetadata(int l) {
|
||||||
{
|
if (worldObj != null && worldObj.isRemote) {
|
||||||
return topStacks;
|
if (l != type.ordinal()) {
|
||||||
}
|
worldObj.setTileEntity(xCoord, yCoord, zCoord, IronChestType.makeEntity(l));
|
||||||
|
return (TileEntityIronChest) worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntityIronChest updateFromMetadata(int l)
|
@Override
|
||||||
{
|
public Packet getDescriptionPacket() {
|
||||||
if (worldObj != null && worldObj.isRemote)
|
return PacketHandler.getPacket(this);
|
||||||
{
|
}
|
||||||
if (l != type.ordinal())
|
|
||||||
{
|
|
||||||
worldObj.setTileEntity(xCoord, yCoord, zCoord, IronChestType.makeEntity(l));
|
|
||||||
return (TileEntityIronChest) worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void handlePacketData(int typeData, int[] intData) {
|
||||||
public Packet getDescriptionPacket()
|
TileEntityIronChest chest = this;
|
||||||
{
|
if (type.ordinal() != typeData) {
|
||||||
return PacketHandler.getPacket(this);
|
chest = updateFromMetadata(typeData);
|
||||||
}
|
}
|
||||||
|
if (IronChestType.values()[typeData].isTransparent() && intData != null) {
|
||||||
|
int pos = 0;
|
||||||
|
if (intData.length < chest.topStacks.length * 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < chest.topStacks.length; i++) {
|
||||||
|
if (intData[pos + 2] != 0) {
|
||||||
|
Item it = Item.getItemById(intData[pos]);
|
||||||
|
ItemStack is = new ItemStack(it, intData[pos + 2], intData[pos + 1]);
|
||||||
|
chest.topStacks[i] = is;
|
||||||
|
} else {
|
||||||
|
chest.topStacks[i] = null;
|
||||||
|
}
|
||||||
|
pos += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void handlePacketData(int typeData, int[] intData)
|
public int[] buildIntDataList() {
|
||||||
{
|
if (type.isTransparent()) {
|
||||||
TileEntityIronChest chest = this;
|
int[] sortList = new int[topStacks.length * 3];
|
||||||
if (this.type.ordinal() != typeData)
|
int pos = 0;
|
||||||
{
|
for (ItemStack is : topStacks) {
|
||||||
chest = updateFromMetadata(typeData);
|
if (is != null) {
|
||||||
}
|
sortList[pos++] = Item.getIdFromItem(is.getItem());
|
||||||
if (IronChestType.values()[typeData].isTransparent() && intData != null)
|
sortList[pos++] = is.getItemDamage();
|
||||||
{
|
sortList[pos++] = is.stackSize;
|
||||||
int pos = 0;
|
} else {
|
||||||
if (intData.length < chest.topStacks.length * 3)
|
sortList[pos++] = 0;
|
||||||
{
|
sortList[pos++] = 0;
|
||||||
return;
|
sortList[pos++] = 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < chest.topStacks.length; i++)
|
}
|
||||||
{
|
return sortList;
|
||||||
if (intData[pos + 2] != 0)
|
}
|
||||||
{
|
return null;
|
||||||
Item it = Item.getItemById(intData[pos]);
|
}
|
||||||
ItemStack is = new ItemStack(it, intData[pos + 2], intData[pos + 1]);
|
|
||||||
chest.topStacks[i] = is;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
chest.topStacks[i] = null;
|
|
||||||
}
|
|
||||||
pos += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] buildIntDataList()
|
@Override
|
||||||
{
|
public ItemStack getStackInSlotOnClosing(int par1) {
|
||||||
if (type.isTransparent())
|
if (chestContents[par1] != null) {
|
||||||
{
|
ItemStack var2 = chestContents[par1];
|
||||||
int[] sortList = new int[topStacks.length * 3];
|
chestContents[par1] = null;
|
||||||
int pos = 0;
|
return var2;
|
||||||
for (ItemStack is : topStacks)
|
} else {
|
||||||
{
|
return null;
|
||||||
if (is != null)
|
}
|
||||||
{
|
}
|
||||||
sortList[pos++] = Item.getIdFromItem(is.getItem());
|
|
||||||
sortList[pos++] = is.getItemDamage();
|
|
||||||
sortList[pos++] = is.stackSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sortList[pos++] = 0;
|
|
||||||
sortList[pos++] = 0;
|
|
||||||
sortList[pos++] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sortList;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int par1)
|
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||||
{
|
return type.acceptsStack(itemstack);
|
||||||
if (this.chestContents[par1] != null)
|
}
|
||||||
{
|
|
||||||
ItemStack var2 = this.chestContents[par1];
|
|
||||||
this.chestContents[par1] = null;
|
|
||||||
return var2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxStackSize(int size)
|
@Override
|
||||||
{
|
public boolean hasCustomInventoryName() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
void rotateAround(ForgeDirection axis) {
|
||||||
|
setFacing((byte) ForgeDirection.getOrientation(facing).getRotation(axis).ordinal());
|
||||||
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock, 2, getFacing());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack) {}
|
||||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return type.acceptsStack(itemstack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void removeAdornments() {}
|
||||||
public boolean hasCustomInventoryName()
|
}
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rotateAround(ForgeDirection axis)
|
|
||||||
{
|
|
||||||
setFacing((byte)ForgeDirection.getOrientation(facing).getRotation(axis).ordinal());
|
|
||||||
worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, IronChest.ironChestBlock, 2, getFacing());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void wasPlaced(EntityLivingBase entityliving, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeAdornments()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntityObsidianChest extends TileEntityIronChest {
|
public class TileEntityObsidianChest extends TileEntityIronChest {
|
||||||
public TileEntityObsidianChest()
|
public TileEntityObsidianChest() {
|
||||||
{
|
super(IronChestType.OBSIDIAN);
|
||||||
super(IronChestType.OBSIDIAN);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
public class TileEntitySilverChest extends TileEntityIronChest {
|
public class TileEntitySilverChest extends TileEntityIronChest {
|
||||||
public TileEntitySilverChest()
|
public TileEntitySilverChest() {
|
||||||
{
|
super(IronChestType.SILVER);
|
||||||
super(IronChestType.SILVER);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -5,17 +5,15 @@ import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ValidatingSlot extends Slot {
|
public class ValidatingSlot extends Slot {
|
||||||
private IronChestType type;
|
private IronChestType type;
|
||||||
|
|
||||||
public ValidatingSlot(IInventory par1iInventory, int par2, int par3, int par4, IronChestType type)
|
public ValidatingSlot(IInventory inv, int i, int j, int k, IronChestType type) {
|
||||||
{
|
super(inv, i, j, k);
|
||||||
super(par1iInventory, par2, par3, par4);
|
this.type = type;
|
||||||
this.type = type;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack par1ItemStack)
|
public boolean isItemValid(ItemStack is) {
|
||||||
{
|
return type.acceptsStack(is);
|
||||||
return type.acceptsStack(par1ItemStack);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -3,22 +3,19 @@ package cpw.mods.ironchest;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
private static String major, minor, rev, build, mcversion;
|
private static String major, minor, rev, build, mcversion;
|
||||||
|
|
||||||
static void init(Properties properties)
|
static void init(Properties properties) {
|
||||||
{
|
if (properties != null) {
|
||||||
if (properties != null)
|
major = properties.getProperty("IronChest.build.major.number");
|
||||||
{
|
minor = properties.getProperty("IronChest.build.minor.number");
|
||||||
major = properties.getProperty("IronChest.build.major.number");
|
rev = properties.getProperty("IronChest.build.revision.number");
|
||||||
minor = properties.getProperty("IronChest.build.minor.number");
|
build = properties.getProperty("IronChest.build.number");
|
||||||
rev = properties.getProperty("IronChest.build.revision.number");
|
mcversion = properties.getProperty("IronChest.build.mcversion");
|
||||||
build = properties.getProperty("IronChest.build.number");
|
}
|
||||||
mcversion = properties.getProperty("IronChest.build.mcversion");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String fullVersionString()
|
public static String fullVersionString() {
|
||||||
{
|
return String.format("%s.%s.%s build %s", major, minor, rev, build);
|
||||||
return String.format("%s.%s.%s build %s", major, minor, rev, build);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -11,35 +11,28 @@ import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
@Override
|
@Override
|
||||||
public void registerRenderInformation()
|
public void registerRenderInformation() {
|
||||||
{
|
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
|
||||||
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
public void registerTileEntitySpecialRenderer(IronChestType typ) {
|
||||||
{
|
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getClientWorld()
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
{
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
return FMLClientHandler.instance().getClient().theWorld;
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
}
|
return GuiIronChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
public World getClientWorld() {
|
||||||
{
|
return FMLClientHandler.instance().getClient().theWorld;
|
||||||
TileEntity te = world.getTileEntity(x, y, z);
|
}
|
||||||
if (te != null && te instanceof TileEntityIronChest)
|
}
|
||||||
{
|
|
||||||
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
package cpw.mods.ironchest.client;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import cpw.mods.ironchest.ContainerIronChest;
|
|
||||||
import cpw.mods.ironchest.IronChestType;
|
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
|
||||||
|
|
||||||
public class GUIChest extends GuiContainer {
|
|
||||||
public enum ResourceList {
|
|
||||||
IRON(new ResourceLocation("ironchest", "textures/gui/ironcontainer.png")),
|
|
||||||
COPPER(new ResourceLocation("ironchest", "textures/gui/coppercontainer.png")),
|
|
||||||
SILVER(new ResourceLocation("ironchest", "textures/gui/silvercontainer.png")),
|
|
||||||
GOLD(new ResourceLocation("ironchest", "textures/gui/goldcontainer.png")),
|
|
||||||
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")),
|
|
||||||
DIRT(new ResourceLocation("ironchest", "textures/gui/dirtcontainer.png"));
|
|
||||||
public final ResourceLocation location;
|
|
||||||
private ResourceList(ResourceLocation loc) {
|
|
||||||
this.location = loc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public enum GUI {
|
|
||||||
IRON(184, 202, ResourceList.IRON, IronChestType.IRON),
|
|
||||||
GOLD(184, 256, ResourceList.GOLD, IronChestType.GOLD),
|
|
||||||
DIAMOND(238, 256, ResourceList.DIAMOND, IronChestType.DIAMOND),
|
|
||||||
COPPER(184, 184, ResourceList.COPPER, IronChestType.COPPER),
|
|
||||||
SILVER(184, 238, ResourceList.SILVER, IronChestType.SILVER),
|
|
||||||
CRYSTAL(238, 256, ResourceList.DIAMOND, IronChestType.CRYSTAL),
|
|
||||||
OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN),
|
|
||||||
DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000);
|
|
||||||
|
|
||||||
private int xSize;
|
|
||||||
private int ySize;
|
|
||||||
private ResourceList guiResourceList;
|
|
||||||
private IronChestType mainType;
|
|
||||||
|
|
||||||
private GUI(int xSize, int ySize, ResourceList guiResourceList, IronChestType mainType)
|
|
||||||
{
|
|
||||||
this.xSize = xSize;
|
|
||||||
this.ySize = ySize;
|
|
||||||
this.guiResourceList = guiResourceList;
|
|
||||||
this.mainType = mainType;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Container makeContainer(IInventory player, IInventory chest)
|
|
||||||
{
|
|
||||||
return new ContainerIronChest(player, chest, mainType, xSize, ySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GUIChest buildGUI(IronChestType type, IInventory playerInventory, TileEntityIronChest chestInventory)
|
|
||||||
{
|
|
||||||
return new GUIChest(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRowLength()
|
|
||||||
{
|
|
||||||
return type.mainType.getRowLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
private GUI type;
|
|
||||||
|
|
||||||
private GUIChest(GUI type, IInventory player, IInventory chest)
|
|
||||||
{
|
|
||||||
super(type.makeContainer(player, chest));
|
|
||||||
this.type = type;
|
|
||||||
this.xSize = type.xSize;
|
|
||||||
this.ySize = type.ySize;
|
|
||||||
this.allowUserInput = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
|
|
||||||
{
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
// new "bind tex"
|
|
||||||
this.mc.getTextureManager().bindTexture(type.guiResourceList.location);
|
|
||||||
int x = (width - xSize) / 2;
|
|
||||||
int y = (height - ySize) / 2;
|
|
||||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.ironchest.ContainerIronChest;
|
||||||
|
import cpw.mods.ironchest.IronChestType;
|
||||||
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
|
public class GuiIronChest extends GuiContainer {
|
||||||
|
public enum ResourceList {
|
||||||
|
IRON(new ResourceLocation("ironchest", "textures/gui/ironcontainer.png")),
|
||||||
|
COPPER(new ResourceLocation("ironchest", "textures/gui/coppercontainer.png")),
|
||||||
|
SILVER(new ResourceLocation("ironchest", "textures/gui/silvercontainer.png")),
|
||||||
|
GOLD(new ResourceLocation("ironchest", "textures/gui/goldcontainer.png")),
|
||||||
|
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")),
|
||||||
|
DIRT(new ResourceLocation("ironchest", "textures/gui/dirtcontainer.png"));
|
||||||
|
public final ResourceLocation location;
|
||||||
|
|
||||||
|
private ResourceList(ResourceLocation loc) {
|
||||||
|
this.location = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum GUI {
|
||||||
|
IRON(184, 202, ResourceList.IRON, IronChestType.IRON),
|
||||||
|
GOLD(184, 256, ResourceList.GOLD, IronChestType.GOLD),
|
||||||
|
DIAMOND(238, 256, ResourceList.DIAMOND, IronChestType.DIAMOND),
|
||||||
|
COPPER(184, 184, ResourceList.COPPER, IronChestType.COPPER),
|
||||||
|
SILVER(184, 238, ResourceList.SILVER, IronChestType.SILVER),
|
||||||
|
CRYSTAL(238, 256, ResourceList.DIAMOND, IronChestType.CRYSTAL),
|
||||||
|
OBSIDIAN(238, 256, ResourceList.DIAMOND, IronChestType.OBSIDIAN),
|
||||||
|
DIRTCHEST9000(184, 184, ResourceList.DIRT, IronChestType.DIRTCHEST9000);
|
||||||
|
|
||||||
|
private int xSize, ySize;
|
||||||
|
private ResourceList guiResourceList;
|
||||||
|
private IronChestType mainType;
|
||||||
|
|
||||||
|
private GUI(int xSize, int ySize, ResourceList guiResourceList, IronChestType mainType) {
|
||||||
|
this.xSize = xSize;
|
||||||
|
this.ySize = ySize;
|
||||||
|
this.guiResourceList = guiResourceList;
|
||||||
|
this.mainType = mainType;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Container makeContainer(IInventory player, IInventory chest) {
|
||||||
|
return new ContainerIronChest(player, chest, mainType, xSize, ySize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiIronChest buildGUI(IronChestType type, IInventory playerInventory, TileEntityIronChest chestInventory) {
|
||||||
|
return new GuiIronChest(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRowLength() {
|
||||||
|
return type.mainType.getRowLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUI type;
|
||||||
|
|
||||||
|
private GuiIronChest(GUI type, IInventory player, IInventory chest) {
|
||||||
|
super(type.makeContainer(player, chest));
|
||||||
|
this.type = type;
|
||||||
|
this.xSize = type.xSize;
|
||||||
|
this.ySize = type.ySize;
|
||||||
|
this.allowUserInput = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.mc.getTextureManager().bindTexture(type.guiResourceList.location);
|
||||||
|
int x = (width - xSize) / 2;
|
||||||
|
int y = (height - ySize) / 2;
|
||||||
|
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,35 +1,31 @@
|
||||||
package cpw.mods.ironchest.client;
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import cpw.mods.ironchest.IronChest;
|
import cpw.mods.ironchest.IronChest;
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class IronChestRenderHelper extends TileEntityRendererChestHelper {
|
public class IronChestRenderHelper extends TileEntityRendererChestHelper {
|
||||||
private Map<Integer, TileEntityIronChest> itemRenders = Maps.newHashMap();
|
private Map<Integer, TileEntityIronChest> itemRenders = Maps.newHashMap();
|
||||||
|
|
||||||
public IronChestRenderHelper()
|
public IronChestRenderHelper() {
|
||||||
{
|
for (IronChestType typ : IronChestType.values())
|
||||||
for (IronChestType typ : IronChestType.values())
|
itemRenders.put(typ.ordinal(), (TileEntityIronChest) IronChest.ironChestBlock.createTileEntity(null, typ.ordinal()));
|
||||||
{
|
}
|
||||||
itemRenders.put(typ.ordinal(), (TileEntityIronChest) IronChest.ironChestBlock.createTileEntity(null, typ.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderChest(Block block, int i, float f)
|
public void renderChest(Block block, int i, float f) {
|
||||||
{
|
if (block == IronChest.ironChestBlock) {
|
||||||
if (block == IronChest.ironChestBlock)
|
TileEntityRendererDispatcher.instance.renderTileEntityAt(itemRenders.get(i), 0.0D, 0.0D, 0.0D, 0.0F);
|
||||||
{
|
} else {
|
||||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(itemRenders.get(i), 0.0D, 0.0D, 0.0D, 0.0F);
|
super.renderChest(block, i, f);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
super.renderChest(block, i, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,11 +8,11 @@ import static org.lwjgl.opengl.GL11.glPushMatrix;
|
||||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||||
import static org.lwjgl.opengl.GL11.glScalef;
|
import static org.lwjgl.opengl.GL11.glScalef;
|
||||||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelChest;
|
import net.minecraft.client.model.ModelChest;
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
|
@ -20,146 +20,140 @@ import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.common.primitives.SignedBytes;
|
import com.google.common.primitives.SignedBytes;
|
||||||
|
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.MappableItemStackWrapper;
|
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
private static Map<IronChestType, ResourceLocation> locations;
|
private ModelChest model;
|
||||||
|
private static Map<IronChestType, ResourceLocation> locations;
|
||||||
static {
|
|
||||||
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
|
|
||||||
for (IronChestType typ : IronChestType.values()) {
|
|
||||||
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture()));
|
|
||||||
}
|
|
||||||
locations = builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Random random;
|
|
||||||
private RenderItem itemRenderer;
|
|
||||||
|
|
||||||
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F },
|
static {
|
||||||
{ 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType, ResourceLocation> builder();
|
||||||
|
for (IronChestType typ : IronChestType.values())
|
||||||
|
builder.put(typ, new ResourceLocation("ironchest", "textures/model/" + typ.getModelTexture()));
|
||||||
|
locations = builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntityIronChestRenderer()
|
private Random random;
|
||||||
{
|
private RenderItem itemRenderer;
|
||||||
model = new ModelChest();
|
|
||||||
random = new Random();
|
|
||||||
itemRenderer = new RenderItem() {
|
|
||||||
@Override
|
|
||||||
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public byte getMiniItemCount(ItemStack stack, byte original) {
|
|
||||||
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean shouldBob() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean shouldSpreadItems() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
itemRenderer.setRenderManager(RenderManager.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
||||||
if (tile == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int facing = 3;
|
|
||||||
IronChestType type = tile.getType();
|
|
||||||
if (tile != null && tile.hasWorldObj()) {
|
|
||||||
facing = tile.getFacing();
|
|
||||||
type = tile.getType();
|
|
||||||
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
|
||||||
type = IronChestType.values()[typ];
|
|
||||||
}
|
|
||||||
bindTexture(locations.get(type));
|
|
||||||
glPushMatrix();
|
|
||||||
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
|
||||||
glScalef(1.0F, -1F, -1F);
|
|
||||||
glTranslatef(0.5F, 0.5F, 0.5F);
|
|
||||||
int k = 0;
|
|
||||||
if (facing == 2) {
|
|
||||||
k = 180;
|
|
||||||
}
|
|
||||||
if (facing == 3) {
|
|
||||||
k = 0;
|
|
||||||
}
|
|
||||||
if (facing == 4) {
|
|
||||||
k = 90;
|
|
||||||
}
|
|
||||||
if (facing == 5) {
|
|
||||||
k = -90;
|
|
||||||
}
|
|
||||||
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
|
||||||
glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
||||||
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
|
||||||
lidangle = 1.0F - lidangle;
|
|
||||||
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
|
||||||
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
|
||||||
// Render the chest itself
|
|
||||||
model.renderAll();
|
|
||||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
|
||||||
glPopMatrix();
|
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) {
|
|
||||||
random.setSeed(254L);
|
|
||||||
float shiftX;
|
|
||||||
float shiftY;
|
|
||||||
float shiftZ;
|
|
||||||
int shift = 0;
|
|
||||||
float blockScale = 0.70F;
|
|
||||||
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
|
|
||||||
if (tile.getTopItemStacks()[1] == null) {
|
|
||||||
shift = 8;
|
|
||||||
blockScale = 0.85F;
|
|
||||||
}
|
|
||||||
glPushMatrix();
|
|
||||||
glDisable(2896 /* GL_LIGHTING */);
|
|
||||||
glTranslatef((float) x, (float) y, (float) z);
|
|
||||||
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
|
||||||
customitem.hoverStart = 0f;
|
|
||||||
for (ItemStack item : tile.getTopItemStacks()) {
|
|
||||||
if (shift > shifts.length) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (item == null) {
|
|
||||||
shift++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
shiftX = shifts[shift][0];
|
|
||||||
shiftY = shifts[shift][1];
|
|
||||||
shiftZ = shifts[shift][2];
|
|
||||||
shift++;
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(shiftX, shiftY, shiftZ);
|
|
||||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
|
||||||
glScalef(blockScale, blockScale, blockScale);
|
|
||||||
customitem.setEntityItemStack(item);
|
|
||||||
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
glEnable(2896 /* GL_LIGHTING */);
|
|
||||||
glPopMatrix();
|
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public TileEntityIronChestRenderer() {
|
||||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
|
model = new ModelChest();
|
||||||
{
|
random = new Random();
|
||||||
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
itemRenderer = new RenderItem() {
|
||||||
}
|
@Override
|
||||||
|
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
||||||
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
private ModelChest model;
|
@Override
|
||||||
}
|
public byte getMiniItemCount(ItemStack stack, byte original) {
|
||||||
|
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldBob() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSpreadItems() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
itemRenderer.setRenderManager(RenderManager.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
|
||||||
|
if (tile == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int facing = 3;
|
||||||
|
IronChestType type = tile.getType();
|
||||||
|
if (tile != null && tile.hasWorldObj()) {
|
||||||
|
facing = tile.getFacing();
|
||||||
|
type = tile.getType();
|
||||||
|
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||||
|
type = IronChestType.values()[typ];
|
||||||
|
}
|
||||||
|
bindTexture(locations.get(type));
|
||||||
|
glPushMatrix();
|
||||||
|
glEnable(32826);
|
||||||
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
||||||
|
glScalef(1.0F, -1F, -1F);
|
||||||
|
glTranslatef(0.5F, 0.5F, 0.5F);
|
||||||
|
int k = 0;
|
||||||
|
if (facing == 2) {
|
||||||
|
k = 180;
|
||||||
|
}
|
||||||
|
if (facing == 3) {
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
if (facing == 4) {
|
||||||
|
k = 90;
|
||||||
|
}
|
||||||
|
if (facing == 5) {
|
||||||
|
k = -90;
|
||||||
|
}
|
||||||
|
glRotatef(k, 0.0F, 1.0F, 0.0F);
|
||||||
|
glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||||
|
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
|
||||||
|
lidangle = 1.0F - lidangle;
|
||||||
|
lidangle = 1.0F - lidangle * lidangle * lidangle;
|
||||||
|
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
|
||||||
|
model.renderAll();
|
||||||
|
glDisable(32826);
|
||||||
|
glPopMatrix();
|
||||||
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) {
|
||||||
|
random.setSeed(254L);
|
||||||
|
float shiftX, shiftY, shiftZ, blockScale = 0.70F;
|
||||||
|
int shift = 0;
|
||||||
|
if (tile.getTopItemStacks()[1] == null) {
|
||||||
|
shift = 8;
|
||||||
|
blockScale = 0.85F;
|
||||||
|
}
|
||||||
|
glPushMatrix();
|
||||||
|
glDisable(2896);
|
||||||
|
glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
|
||||||
|
customitem.hoverStart = 0f;
|
||||||
|
for (ItemStack item : tile.getTopItemStacks()) {
|
||||||
|
if (shift > shifts.length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (item == null) {
|
||||||
|
shift++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
shiftX = shifts[shift][0];
|
||||||
|
shiftY = shifts[shift][1];
|
||||||
|
shiftZ = shifts[shift][2];
|
||||||
|
shift++;
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(shiftX, shiftY, shiftZ);
|
||||||
|
glRotatef((float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL), 0.0F, 1.0F, 0.0F);
|
||||||
|
glScalef(blockScale, blockScale, blockScale);
|
||||||
|
customitem.setEntityItemStack(item);
|
||||||
|
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
glEnable(2896);
|
||||||
|
glPopMatrix();
|
||||||
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) {
|
||||||
|
render((TileEntityIronChest) tileentity, x, y, z, partialTick);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue