start of 1.11 update

This commit is contained in:
Progwml6 2016-11-16 10:58:31 -05:00
parent 07510cf030
commit a43c7259c3
6 changed files with 130 additions and 242 deletions

View File

@ -33,7 +33,7 @@ repositories {
} }
dependencies { dependencies {
deobfCompile "mezz.jei:jei_1.10.2:3.7.6.232" //deobfCompile "mezz.jei:jei_1.10.2:3.7.6.232"
} }
// This is our group. I'm cpw.mods // This is our group. I'm cpw.mods
@ -43,8 +43,8 @@ archivesBaseName = "ironchest"
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here // Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
minecraft { minecraft {
version = "1.10.2-12.18.1.2014" version = "1.11-13.19.0.2130"
mappings = "snapshot_20160715" mappings = "snapshot_20161111"
runDir = "run" runDir = "run"
} }

View File

@ -64,7 +64,7 @@ public class ContainerIronChest extends Container
{ {
return null; return null;
} }
if (itemstack1.stackSize == 0) if (itemstack1.func_190916_E() == 0)
{ {
slot.putStack(null); slot.putStack(null);
} }

View File

@ -21,7 +21,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
@Mod(modid = IronChest.MOD_ID, name = "Iron Chests", dependencies = "required-after:Forge@[12.17.0.1909,)", acceptedMinecraftVersions = "[1.9.4, 1.11)") @Mod(modid = IronChest.MOD_ID, name = "Iron Chests", dependencies = "required-after:Forge@[12.17.0.1909,)", acceptedMinecraftVersions = "[1.11, 1.12)")
public class IronChest public class IronChest
{ {
public static final String MOD_ID = "ironchest"; public static final String MOD_ID = "ironchest";

View File

@ -128,7 +128,7 @@ public class ItemChestChanger extends Item
((TileEntityIronChest) te2).setFacing(chestFacing); ((TileEntityIronChest) te2).setFacing(chestFacing);
} }
stack.stackSize = playerIn.capabilities.isCreativeMode ? stack.stackSize : stack.stackSize - 1; stack.func_190920_e(playerIn.capabilities.isCreativeMode ? stack.func_190916_E() : stack.func_190916_E() - 1);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }

View File

@ -10,11 +10,6 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import java.util.Arrays;
import java.util.Comparator;
import javax.annotation.Nullable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -35,13 +30,17 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable, IInventory import java.util.Arrays;
{ import java.util.Comparator;
private int ticksSinceSync = -1;
import javax.annotation.Nullable;
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable, IInventory {
public float prevLidAngle; public float prevLidAngle;
public float lidAngle; public float lidAngle;
private int numPlayersUsing;
public ItemStack[] chestContents; public ItemStack[] chestContents;
private int ticksSinceSync = -1;
private int numPlayersUsing;
private ItemStack[] topStacks; private ItemStack[] topStacks;
private EnumFacing facing; private EnumFacing facing;
private boolean inventoryTouched; private boolean inventoryTouched;
@ -49,13 +48,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
private String customName; private String customName;
private IronChestType chestType; private IronChestType chestType;
public TileEntityIronChest() public TileEntityIronChest () {
{
this(IronChestType.IRON); this(IronChestType.IRON);
} }
protected TileEntityIronChest(IronChestType type) protected TileEntityIronChest (IronChestType type) {
{
super(); super();
this.chestType = type; this.chestType = type;
this.chestContents = new ItemStack[type.size]; this.chestContents = new ItemStack[type.size];
@ -63,14 +60,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
this.facing = EnumFacing.NORTH; this.facing = EnumFacing.NORTH;
} }
public void setContents(ItemStack[] contents) public void setContents (ItemStack[] contents) {
{
this.chestContents = new ItemStack[this.getType().size]; this.chestContents = new ItemStack[this.getType().size];
for (int i = 0; i < contents.length; i++) for (int i = 0; i < contents.length; i++) {
{ if (i < this.chestContents.length) {
if (i < this.chestContents.length)
{
this.chestContents[i] = contents[i]; this.chestContents[i] = contents[i];
} }
} }
@ -79,26 +73,25 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public int getSizeInventory() public int getSizeInventory () {
{
return this.chestContents.length; return this.chestContents.length;
} }
public EnumFacing getFacing() public EnumFacing getFacing () {
{
return this.facing; return this.facing;
} }
public IronChestType getType() public void setFacing (EnumFacing facing) {
{ this.facing = facing;
}
public IronChestType getType () {
IronChestType type = IronChestType.IRON; IronChestType type = IronChestType.IRON;
if (this.hasWorldObj()) if (this.hasWorldObj()) {
{
IBlockState state = this.worldObj.getBlockState(this.pos); IBlockState state = this.worldObj.getBlockState(this.pos);
if (state.getBlock() == IronChest.ironChestBlock) if (state.getBlock() == IronChest.ironChestBlock) {
{
type = state.getValue(BlockIronChest.VARIANT_PROP); type = state.getValue(BlockIronChest.VARIANT_PROP);
} }
} }
@ -107,8 +100,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public ItemStack getStackInSlot(int index) public ItemStack getStackInSlot (int index) {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
this.inventoryTouched = true; this.inventoryTouched = true;
@ -117,17 +109,14 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void markDirty() public void markDirty () {
{
super.markDirty(); super.markDirty();
this.sortTopStacks(); this.sortTopStacks();
} }
protected void sortTopStacks() protected void sortTopStacks () {
{ if (!this.getType().isTransparent() || (this.worldObj != null && this.worldObj.isRemote)) {
if (!this.getType().isTransparent() || (this.worldObj != null && this.worldObj.isRemote))
{
return; return;
} }
@ -137,15 +126,12 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
int compressedIdx = 0; int compressedIdx = 0;
mainLoop: for (int i = 0; i < this.getSizeInventory(); i++) mainLoop:
{ for (int i = 0; i < this.getSizeInventory(); i++) {
if (this.chestContents[i] != null) if (this.chestContents[i] != null) {
{ for (int j = 0; j < compressedIdx; j++) {
for (int j = 0; j < compressedIdx; j++) if (tempCopy[j].isItemEqual(this.chestContents[i])) {
{ tempCopy[j].func_190920_e(tempCopy[j].func_190916_E() + this.chestContents[i].func_190916_E());
if (tempCopy[j].isItemEqual(this.chestContents[i]))
{
tempCopy[j].stackSize += this.chestContents[i].stackSize;
continue mainLoop; continue mainLoop;
} }
} }
@ -154,17 +140,14 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
} }
if (!hasStuff && this.hadStuff) if (!hasStuff && this.hadStuff) {
{
this.hadStuff = false; this.hadStuff = false;
for (int i = 0; i < this.topStacks.length; i++) for (int i = 0; i < this.topStacks.length; i++) {
{
this.topStacks[i] = null; this.topStacks[i] = null;
} }
if (this.worldObj != null) if (this.worldObj != null) {
{
IBlockState iblockstate = this.worldObj.getBlockState(this.pos); IBlockState iblockstate = this.worldObj.getBlockState(this.pos);
this.worldObj.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3); this.worldObj.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
} }
@ -176,45 +159,34 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
Arrays.sort(tempCopy, new Comparator<ItemStack>() { Arrays.sort(tempCopy, new Comparator<ItemStack>() {
@Override @Override
public int compare(ItemStack o1, ItemStack o2) public int compare (ItemStack o1, ItemStack o2) {
{ if (o1 == null) {
if (o1 == null)
{
return 1; return 1;
} } else if (o2 == null) {
else if (o2 == null)
{
return -1; return -1;
} } else {
else return o2.func_190916_E() - o1.func_190916_E();
{
return o2.stackSize - o1.stackSize;
} }
} }
}); });
int p = 0; int p = 0;
for (ItemStack element : tempCopy) for (ItemStack element : tempCopy) {
{ if (element != ItemStack.field_190927_a && element.func_190916_E() > 0) {
if (element != null && element.stackSize > 0)
{
this.topStacks[p++] = element; this.topStacks[p++] = element;
if (p == this.topStacks.length) if (p == this.topStacks.length) {
{
break; break;
} }
} }
} }
for (int i = p; i < this.topStacks.length; i++) for (int i = p; i < this.topStacks.length; i++) {
{
this.topStacks[i] = null; this.topStacks[i] = null;
} }
if (this.worldObj != null) if (this.worldObj != null) {
{
IBlockState iblockstate = this.worldObj.getBlockState(this.pos); IBlockState iblockstate = this.worldObj.getBlockState(this.pos);
this.worldObj.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3); this.worldObj.notifyBlockUpdate(this.pos, iblockstate, iblockstate, 3);
@ -223,14 +195,12 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
@Override @Override
@Nullable @Nullable
public ItemStack decrStackSize(int index, int count) public ItemStack decrStackSize (int index, int count) {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
ItemStack itemstack = ItemStackHelper.getAndSplit(this.chestContents, index, count); ItemStack itemstack = ItemStackHelper.getAndSplit(this.chestContents, index, count);
if (itemstack != null) if (itemstack != null) {
{
this.markDirty(); this.markDirty();
} }
@ -238,61 +208,51 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void setInventorySlotContents(int index, @Nullable ItemStack stack) public void setInventorySlotContents (int index, @Nullable ItemStack stack) {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
this.chestContents[index] = stack; this.chestContents[index] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit()) if (stack != null && stack.func_190916_E() > this.getInventoryStackLimit()) {
{ stack.func_190920_e(this.getInventoryStackLimit());
stack.stackSize = this.getInventoryStackLimit();
} }
this.markDirty(); this.markDirty();
} }
@Override @Override
public String getName() public String getName () {
{
return this.hasCustomName() ? this.customName : this.getType().name(); return this.hasCustomName() ? this.customName : this.getType().name();
} }
@Override @Override
public boolean hasCustomName() public boolean hasCustomName () {
{
return this.customName != null && this.customName.length() > 0; return this.customName != null && this.customName.length() > 0;
} }
public void setCustomName(String name) public void setCustomName (String name) {
{
this.customName = name; this.customName = name;
} }
@Override @Override
public void readFromNBT(NBTTagCompound compound) public void readFromNBT (NBTTagCompound compound) {
{
super.readFromNBT(compound); super.readFromNBT(compound);
this.chestContents = new ItemStack[this.getSizeInventory()]; this.chestContents = new ItemStack[this.getSizeInventory()];
if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) {
{
this.customName = compound.getString("CustomName"); this.customName = compound.getString("CustomName");
} }
if (!this.checkLootAndRead(compound)) if (!this.checkLootAndRead(compound)) {
{
NBTTagList itemList = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); NBTTagList itemList = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int itemNumber = 0; itemNumber < itemList.tagCount(); ++itemNumber) for (int itemNumber = 0; itemNumber < itemList.tagCount(); ++itemNumber) {
{
NBTTagCompound item = itemList.getCompoundTagAt(itemNumber); NBTTagCompound item = itemList.getCompoundTagAt(itemNumber);
int slot = item.getByte("Slot") & 255; int slot = item.getByte("Slot") & 255;
if (slot >= 0 && slot < this.chestContents.length) if (slot >= 0 && slot < this.chestContents.length) {
{
this.chestContents[slot] = ItemStack.loadItemStackFromNBT(item); this.chestContents[slot] = ItemStack.loadItemStackFromNBT(item);
} }
} }
@ -304,18 +264,14 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) public NBTTagCompound writeToNBT (NBTTagCompound compound) {
{
super.writeToNBT(compound); super.writeToNBT(compound);
if (!this.checkLootAndWrite(compound)) if (!this.checkLootAndWrite(compound)) {
{
NBTTagList itemList = new NBTTagList(); NBTTagList itemList = new NBTTagList();
for (int slot = 0; slot < this.chestContents.length; ++slot) for (int slot = 0; slot < this.chestContents.length; ++slot) {
{ if (this.chestContents[slot] != null) {
if (this.chestContents[slot] != null)
{
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
tag.setByte("Slot", (byte) slot); tag.setByte("Slot", (byte) slot);
@ -331,8 +287,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
compound.setByte("facing", (byte) this.facing.ordinal()); compound.setByte("facing", (byte) this.facing.ordinal());
if (this.hasCustomName()) if (this.hasCustomName()) {
{
compound.setString("CustomName", this.customName); compound.setString("CustomName", this.customName);
} }
@ -340,21 +295,17 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public int getInventoryStackLimit() public int getInventoryStackLimit () {
{
return 64; return 64;
} }
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player) public boolean isUseableByPlayer (EntityPlayer player) {
{ if (this.worldObj == null) {
if (this.worldObj == null)
{
return true; return true;
} }
if (this.worldObj.getTileEntity(this.pos) != this) if (this.worldObj.getTileEntity(this.pos) != this) {
{
return false; return false;
} }
@ -362,8 +313,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void update() public void update () {
{
// Resynchronizes clients with the server state // Resynchronizes clients with the server state
//@formatter:off //@formatter:off
if (this.worldObj != null && !this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.pos.getX() + this.pos.getY() + this.pos.getZ()) % 200 == 0) if (this.worldObj != null && !this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.pos.getX() + this.pos.getY() + this.pos.getZ()) % 200 == 0)
@ -374,23 +324,21 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
float f = 5.0F; float f = 5.0F;
//@formatter:off //@formatter:off
for (EntityPlayer player : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(this.pos.getX() - f, this.pos.getY() - f, this.pos.getZ() - f, this.pos.getX() + 1 + f, this.pos.getY() + 1 + f, this.pos.getZ() + 1 + f))) for (EntityPlayer player : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class,
new AxisAlignedBB(this.pos.getX() - f, this.pos.getY() - f, this.pos.getZ() - f, this.pos.getX() + 1 + f, this.pos.getY() + 1 + f, this.pos.getZ() + 1 + f)))
//@formatter:on //@formatter:on
{ {
if (player.openContainer instanceof ContainerIronChest) if (player.openContainer instanceof ContainerIronChest) {
{
++this.numPlayersUsing; ++this.numPlayersUsing;
} }
} }
} }
if (this.worldObj != null && !this.worldObj.isRemote && this.ticksSinceSync < 0) if (this.worldObj != null && !this.worldObj.isRemote && this.ticksSinceSync < 0) {
{
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 3, ((this.numPlayersUsing << 3) & 0xF8) | (this.facing.ordinal() & 0x7)); this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 3, ((this.numPlayersUsing << 3) & 0xF8) | (this.facing.ordinal() & 0x7));
} }
if (!this.worldObj.isRemote && this.inventoryTouched) if (!this.worldObj.isRemote && this.inventoryTouched) {
{
this.inventoryTouched = false; this.inventoryTouched = false;
this.sortTopStacks(); this.sortTopStacks();
@ -402,8 +350,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
float angle = 0.1F; float angle = 0.1F;
if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F) {
{
double x = this.pos.getX() + 0.5D; double x = this.pos.getX() + 0.5D;
double y = this.pos.getY() + 0.5D; double y = this.pos.getY() + 0.5D;
double z = this.pos.getZ() + 0.5D; double z = this.pos.getZ() + 0.5D;
@ -413,28 +360,22 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
//@formatter:on //@formatter:on
} }
if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) {
{
float currentAngle = this.lidAngle; float currentAngle = this.lidAngle;
if (this.numPlayersUsing > 0) if (this.numPlayersUsing > 0) {
{
this.lidAngle += angle; this.lidAngle += angle;
} } else {
else
{
this.lidAngle -= angle; this.lidAngle -= angle;
} }
if (this.lidAngle > 1.0F) if (this.lidAngle > 1.0F) {
{
this.lidAngle = 1.0F; this.lidAngle = 1.0F;
} }
float maxAngle = 0.5F; float maxAngle = 0.5F;
if (this.lidAngle < maxAngle && currentAngle >= maxAngle) if (this.lidAngle < maxAngle && currentAngle >= maxAngle) {
{
double x = this.pos.getX() + 0.5D; double x = this.pos.getX() + 0.5D;
double y = this.pos.getY() + 0.5D; double y = this.pos.getY() + 0.5D;
double z = this.pos.getZ() + 0.5D; double z = this.pos.getZ() + 0.5D;
@ -444,26 +385,19 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
//@formatter:on //@formatter:on
} }
if (this.lidAngle < 0.0F) if (this.lidAngle < 0.0F) {
{
this.lidAngle = 0.0F; this.lidAngle = 0.0F;
} }
} }
} }
@Override @Override
public boolean receiveClientEvent(int id, int type) public boolean receiveClientEvent (int id, int type) {
{ if (id == 1) {
if (id == 1)
{
this.numPlayersUsing = type; this.numPlayersUsing = type;
} } else if (id == 2) {
else if (id == 2)
{
this.facing = EnumFacing.VALUES[type]; this.facing = EnumFacing.VALUES[type];
} } else if (id == 3) {
else if (id == 3)
{
this.facing = EnumFacing.VALUES[type & 0x7]; this.facing = EnumFacing.VALUES[type & 0x7];
this.numPlayersUsing = (type & 0xF8) >> 3; this.numPlayersUsing = (type & 0xF8) >> 3;
} }
@ -472,17 +406,13 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void openInventory(EntityPlayer player) public void openInventory (EntityPlayer player) {
{ if (!player.isSpectator()) {
if (!player.isSpectator()) if (this.worldObj == null) {
{
if (this.worldObj == null)
{
return; return;
} }
if (this.numPlayersUsing < 0) if (this.numPlayersUsing < 0) {
{
this.numPlayersUsing = 0; this.numPlayersUsing = 0;
} }
@ -495,12 +425,9 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void closeInventory(EntityPlayer player) public void closeInventory (EntityPlayer player) {
{ if (!player.isSpectator()) {
if (!player.isSpectator()) if (this.worldObj == null) {
{
if (this.worldObj == null)
{
return; return;
} }
@ -512,33 +439,23 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
} }
public void setFacing(EnumFacing facing) public ItemStack[] getTopItemStacks () {
{
this.facing = facing;
}
public ItemStack[] getTopItemStacks()
{
return this.topStacks; return this.topStacks;
} }
@Override @Override
public SPacketUpdateTileEntity getUpdatePacket() public SPacketUpdateTileEntity getUpdatePacket () {
{
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
compound.setByte("facing", (byte) this.facing.ordinal()); compound.setByte("facing", (byte) this.facing.ordinal());
ItemStack[] stacks = this.buildItemStackDataList(); ItemStack[] stacks = this.buildItemStackDataList();
if (stacks != null) if (stacks != null) {
{
NBTTagList itemList = new NBTTagList(); NBTTagList itemList = new NBTTagList();
for (int slot = 0; slot < stacks.length; slot++) for (int slot = 0; slot < stacks.length; slot++) {
{ if (stacks[slot] != null) {
if (stacks[slot] != null)
{
NBTTagCompound item = new NBTTagCompound(); NBTTagCompound item = new NBTTagCompound();
item.setByte("Slot", (byte) slot); item.setByte("Slot", (byte) slot);
@ -556,10 +473,8 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) public void onDataPacket (NetworkManager net, SPacketUpdateTileEntity pkt) {
{ if (pkt.getTileEntityType() == 0) {
if (pkt.getTileEntityType() == 0)
{
NBTTagCompound compound = pkt.getNbtCompound(); NBTTagCompound compound = pkt.getNbtCompound();
this.facing = EnumFacing.VALUES[compound.getByte("facing")]; this.facing = EnumFacing.VALUES[compound.getByte("facing")];
@ -568,30 +483,23 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
ItemStack[] stacks = new ItemStack[this.topStacks.length]; ItemStack[] stacks = new ItemStack[this.topStacks.length];
for (int item = 0; item < stacks.length; item++) for (int item = 0; item < stacks.length; item++) {
{
NBTTagCompound itemStack = itemList.getCompoundTagAt(item); NBTTagCompound itemStack = itemList.getCompoundTagAt(item);
int slot = itemStack.getByte("Slot") & 255; int slot = itemStack.getByte("Slot") & 255;
if (slot >= 0 && slot < stacks.length) if (slot >= 0 && slot < stacks.length) {
{
stacks[slot] = ItemStack.loadItemStackFromNBT(itemStack); stacks[slot] = ItemStack.loadItemStackFromNBT(itemStack);
} }
} }
if (this.getType().isTransparent() && stacks != null) if (this.getType().isTransparent() && stacks != null) {
{
int pos = 0; int pos = 0;
for (int i = 0; i < this.topStacks.length; i++) for (int i = 0; i < this.topStacks.length; i++) {
{ if (stacks[pos] != null) {
if (stacks[pos] != null)
{
this.topStacks[i] = stacks[pos]; this.topStacks[i] = stacks[pos];
} } else {
else
{
this.topStacks[i] = null; this.topStacks[i] = null;
} }
@ -601,22 +509,16 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
} }
} }
public ItemStack[] buildItemStackDataList() public ItemStack[] buildItemStackDataList () {
{ if (this.getType().isTransparent()) {
if (this.getType().isTransparent())
{
ItemStack[] sortList = new ItemStack[this.topStacks.length]; ItemStack[] sortList = new ItemStack[this.topStacks.length];
int pos = 0; int pos = 0;
for (ItemStack is : this.topStacks) for (ItemStack is : this.topStacks) {
{ if (is != null) {
if (is != null)
{
sortList[pos++] = is; sortList[pos++] = is;
} } else {
else
{
sortList[pos++] = null; sortList[pos++] = null;
} }
} }
@ -629,85 +531,71 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
@Override @Override
@Nullable @Nullable
public ItemStack removeStackFromSlot(int index) public ItemStack removeStackFromSlot (int index) {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
return ItemStackHelper.getAndRemove(this.chestContents, index); return ItemStackHelper.getAndRemove(this.chestContents, index);
} }
@Override @Override
public boolean isItemValidForSlot(int index, ItemStack stack) public boolean isItemValidForSlot (int index, ItemStack stack) {
{
return this.getType().acceptsStack(stack); return this.getType().acceptsStack(stack);
} }
public void rotateAround() public void rotateAround () {
{
this.setFacing(this.facing.rotateY()); this.setFacing(this.facing.rotateY());
this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 2, this.facing.ordinal()); this.worldObj.addBlockEvent(this.pos, IronChest.ironChestBlock, 2, this.facing.ordinal());
} }
public void wasPlaced(EntityLivingBase entityliving, ItemStack stack) public void wasPlaced (EntityLivingBase entityliving, ItemStack stack) {
{
} }
public void removeAdornments() public void removeAdornments () {
{
} }
@Override @Override
public int getField(int id) public int getField (int id) {
{
return 0; return 0;
} }
@Override @Override
public void setField(int id, int value) public void setField (int id, int value) {
{
} }
@Override @Override
public int getFieldCount() public int getFieldCount () {
{
return 0; return 0;
} }
@Override @Override
public void clear() public void clear () {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
for (int slot = 0; slot < this.chestContents.length; ++slot) for (int slot = 0; slot < this.chestContents.length; ++slot) {
{
this.chestContents[slot] = null; this.chestContents[slot] = null;
} }
} }
@Override @Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) public Container createContainer (InventoryPlayer playerInventory, EntityPlayer playerIn) {
{
this.fillWithLoot((EntityPlayer) null); this.fillWithLoot((EntityPlayer) null);
return new ContainerIronChest(playerInventory, this, this.chestType, this.chestType.xSize, this.chestType.ySize); return new ContainerIronChest(playerInventory, this, this.chestType, this.chestType.xSize, this.chestType.ySize);
} }
@Override @Override
public String getGuiID() public String getGuiID () {
{
return "IronChest:" + this.getType().name(); return "IronChest:" + this.getType().name();
} }
@Override @Override
public boolean canRenderBreaking() public boolean canRenderBreaking () {
{
return true; return true;
} }
@Override @Override
public NBTTagCompound getUpdateTag() public NBTTagCompound getUpdateTag () {
{
return this.writeToNBT(new NBTTagCompound()); return this.writeToNBT(new NBTTagCompound());
} }
} }

View File

@ -188,7 +188,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
@Override @Override
public int getModelCount(ItemStack stack) public int getModelCount(ItemStack stack)
{ {
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1); return SignedBytes.saturatedCast(Math.min(stack.func_190916_E() / 32, 15) + 1);
} }
@Override @Override