Update Iron Chests to 1.11.2!
This commit is contained in:
parent
e5e601a1b8
commit
9515e682ef
|
@ -33,7 +33,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
deobfCompile "mezz.jei:jei_1.11:4.0.1.193"
|
deobfCompile "mezz.jei:jei_1.11.2:4.2.7.241"
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is our group. I'm cpw.mods
|
// This is our group. I'm cpw.mods
|
||||||
|
@ -43,7 +43,7 @@ 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.11-13.19.0.2153"
|
version = "1.11.2-13.20.0.2252"
|
||||||
mappings = "snapshot_20161118"
|
mappings = "snapshot_20161118"
|
||||||
runDir = "run"
|
runDir = "run"
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ public class ContainerIronChest extends Container
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player)
|
public boolean canInteractWith(EntityPlayer playerIn)
|
||||||
{
|
{
|
||||||
return this.chest.isUsableByPlayer(player);
|
return this.chest.isUsableByPlayer(playerIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,10 +83,11 @@ public class ContainerIronChest extends Container
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContainerClosed(EntityPlayer entityplayer)
|
public void onContainerClosed(EntityPlayer playerIn)
|
||||||
{
|
{
|
||||||
super.onContainerClosed(entityplayer);
|
super.onContainerClosed(playerIn);
|
||||||
this.chest.closeInventory(entityplayer);
|
|
||||||
|
this.chest.closeInventory(playerIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -111,8 +112,7 @@ public class ContainerIronChest extends Container
|
||||||
{
|
{
|
||||||
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
||||||
{
|
{
|
||||||
this.addSlotToContainer(
|
this.addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
|
||||||
new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class IronChest
|
||||||
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
|
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@EventHandler
|
||||||
public void onMissingMappings(FMLMissingMappingsEvent event)
|
public void onMissingMappings(FMLMissingMappingsEvent event)
|
||||||
{
|
{
|
||||||
for (MissingMapping mapping : event.get())
|
for (MissingMapping mapping : event.get())
|
||||||
|
|
|
@ -37,35 +37,37 @@ public class ItemChestChanger extends Item
|
||||||
this.setCreativeTab(CreativeTabs.MISC);
|
this.setCreativeTab(CreativeTabs.MISC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a Block is right-clicked with this Item
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
//@formatter:off
|
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
|
|
||||||
//@formatter:on
|
|
||||||
{
|
{
|
||||||
if (world.isRemote)
|
ItemStack itemstack = playerIn.getHeldItem(hand);
|
||||||
|
|
||||||
|
if (worldIn.isRemote)
|
||||||
{
|
{
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type.canUpgrade(IronChestType.WOOD))
|
if (this.type.canUpgrade(IronChestType.WOOD))
|
||||||
{
|
{
|
||||||
if (!(world.getBlockState(pos).getBlock() instanceof BlockChest))
|
if (!(worldIn.getBlockState(pos).getBlock() instanceof BlockChest))
|
||||||
{
|
{
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//@formatter:off
|
if (worldIn.getBlockState(pos) != IronChest.ironChestBlock.getStateFromMeta(IronChestType.valueOf(this.type.source.getName().toUpperCase()).ordinal()))
|
||||||
if (world.getBlockState(pos) != IronChest.ironChestBlock.getStateFromMeta(IronChestType.valueOf(this.type.source.getName().toUpperCase()).ordinal()))
|
|
||||||
//@formatter:on
|
|
||||||
{
|
{
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
TileEntity te = worldIn.getTileEntity(pos);
|
||||||
TileEntityIronChest newchest = new TileEntityIronChest();
|
TileEntityIronChest newchest = new TileEntityIronChest();
|
||||||
|
|
||||||
NonNullList<ItemStack> chestContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY);
|
NonNullList<ItemStack> chestContents = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY);
|
||||||
EnumFacing chestFacing = EnumFacing.DOWN;
|
EnumFacing chestFacing = EnumFacing.DOWN;
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ public class ItemChestChanger extends Item
|
||||||
chestContents = ((TileEntityIronChest) te).getItems();
|
chestContents = ((TileEntityIronChest) te).getItems();
|
||||||
chestFacing = ((TileEntityIronChest) te).getFacing();
|
chestFacing = ((TileEntityIronChest) te).getFacing();
|
||||||
newchest = this.type.target.makeEntity();
|
newchest = this.type.target.makeEntity();
|
||||||
|
|
||||||
if (newchest == null)
|
if (newchest == null)
|
||||||
{
|
{
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
|
@ -83,7 +86,7 @@ public class ItemChestChanger extends Item
|
||||||
}
|
}
|
||||||
else if (te instanceof TileEntityChest)
|
else if (te instanceof TileEntityChest)
|
||||||
{
|
{
|
||||||
IBlockState chestState = world.getBlockState(pos);
|
IBlockState chestState = worldIn.getBlockState(pos);
|
||||||
chestFacing = chestState.getValue(BlockChest.FACING);
|
chestFacing = chestState.getValue(BlockChest.FACING);
|
||||||
TileEntityChest chest = (TileEntityChest) te;
|
TileEntityChest chest = (TileEntityChest) te;
|
||||||
|
|
||||||
|
@ -95,11 +98,14 @@ public class ItemChestChanger extends Item
|
||||||
{
|
{
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
chestContents = NonNullList.<ItemStack> withSize(chest.getSizeInventory(), ItemStack.EMPTY);
|
chestContents = NonNullList.<ItemStack> withSize(chest.getSizeInventory(), ItemStack.EMPTY);
|
||||||
|
|
||||||
for (int i = 0; i < chestContents.size(); i++)
|
for (int i = 0; i < chestContents.size(); i++)
|
||||||
{
|
{
|
||||||
chestContents.set(i, chest.getStackInSlot(i));
|
chestContents.set(i, chest.getStackInSlot(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
newchest = this.type.target.makeEntity();
|
newchest = this.type.target.makeEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,17 +117,17 @@ public class ItemChestChanger extends Item
|
||||||
((TileEntityChest) te).checkForAdjacentChests();
|
((TileEntityChest) te).checkForAdjacentChests();
|
||||||
}
|
}
|
||||||
|
|
||||||
world.removeTileEntity(pos);
|
worldIn.removeTileEntity(pos);
|
||||||
world.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
|
|
||||||
IBlockState iblockstate = IronChest.ironChestBlock.getDefaultState().withProperty(BlockIronChest.VARIANT_PROP, this.type.target);
|
IBlockState iblockstate = IronChest.ironChestBlock.getDefaultState().withProperty(BlockIronChest.VARIANT_PROP, this.type.target);
|
||||||
|
|
||||||
world.setTileEntity(pos, newchest);
|
worldIn.setTileEntity(pos, newchest);
|
||||||
world.setBlockState(pos, iblockstate, 3);
|
worldIn.setBlockState(pos, iblockstate, 3);
|
||||||
|
|
||||||
world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
|
worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
|
||||||
|
|
||||||
TileEntity te2 = world.getTileEntity(pos);
|
TileEntity te2 = worldIn.getTileEntity(pos);
|
||||||
|
|
||||||
if (te2 instanceof TileEntityIronChest)
|
if (te2 instanceof TileEntityIronChest)
|
||||||
{
|
{
|
||||||
|
@ -129,9 +135,10 @@ public class ItemChestChanger extends Item
|
||||||
((TileEntityIronChest) te2).setFacing(chestFacing);
|
((TileEntityIronChest) te2).setFacing(chestFacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
if (!playerIn.capabilities.isCreativeMode)
|
||||||
|
{
|
||||||
stack.setCount(player.capabilities.isCreativeMode ? stack.getCount() : stack.getCount() - 1);
|
itemstack.shrink(1);
|
||||||
|
}
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.ItemStackHelper;
|
import net.minecraft.inventory.ItemStackHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityLockableLoot;
|
import net.minecraft.tileentity.TileEntityLockableLoot;
|
||||||
|
@ -35,24 +34,31 @@ import net.minecraftforge.common.util.Constants;
|
||||||
|
|
||||||
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable
|
public class TileEntityIronChest extends TileEntityLockableLoot implements ITickable
|
||||||
{
|
{
|
||||||
|
/** Chest Contents */
|
||||||
|
public NonNullList<ItemStack> chestContents;
|
||||||
|
|
||||||
|
/** Crystal chest top stacks */
|
||||||
|
private NonNullList<ItemStack> topStacks;
|
||||||
|
|
||||||
/** The current angle of the lid (between 0 and 1) */
|
/** The current angle of the lid (between 0 and 1) */
|
||||||
public float lidAngle;
|
public float lidAngle;
|
||||||
|
|
||||||
/** The angle of the lid last tick */
|
/** The angle of the lid last tick */
|
||||||
public float prevLidAngle;
|
public float prevLidAngle;
|
||||||
|
|
||||||
private NonNullList<ItemStack> chestContents;
|
/** The number of players currently using this chest */
|
||||||
|
|
||||||
private int ticksSinceSync = -1;
|
|
||||||
|
|
||||||
public int numPlayersUsing;
|
public int numPlayersUsing;
|
||||||
|
|
||||||
private NonNullList<ItemStack> topStacks;
|
/** Server sync counter (once per 20 ticks) */
|
||||||
|
private int ticksSinceSync;
|
||||||
|
|
||||||
|
/** Direction chest is facing */
|
||||||
private EnumFacing facing;
|
private EnumFacing facing;
|
||||||
|
|
||||||
|
/** If the inventory got touched */
|
||||||
private boolean inventoryTouched;
|
private boolean inventoryTouched;
|
||||||
|
|
||||||
|
/** If the inventory had items */
|
||||||
private boolean hadStuff;
|
private boolean hadStuff;
|
||||||
|
|
||||||
private String customName;
|
private String customName;
|
||||||
|
@ -81,7 +87,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
{
|
{
|
||||||
if (i < this.chestContents.size())
|
if (i < this.chestContents.size())
|
||||||
{
|
{
|
||||||
this.chestContents.set(i, contents.get(i));
|
this.getItems().set(i, contents.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +97,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
{
|
{
|
||||||
return this.chestContents.size();
|
return this.getItems().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnumFacing getFacing()
|
public EnumFacing getFacing()
|
||||||
|
@ -99,11 +105,6 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
return this.facing;
|
return this.facing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacing(EnumFacing facing)
|
|
||||||
{
|
|
||||||
this.facing = facing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IronChestType getType()
|
public IronChestType getType()
|
||||||
{
|
{
|
||||||
IronChestType type = IronChestType.IRON;
|
IronChestType type = IronChestType.IRON;
|
||||||
|
@ -152,19 +153,22 @@ 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.get(i) != ItemStack.EMPTY)
|
if (this.getItems().get(i) != ItemStack.EMPTY)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < compressedIdx; j++)
|
for (int j = 0; j < compressedIdx; j++)
|
||||||
{
|
{
|
||||||
if (tempCopy.get(j).isItemEqual(this.chestContents.get(i)))
|
if (tempCopy.get(j).isItemEqual(this.getItems().get(i)))
|
||||||
{
|
{
|
||||||
tempCopy.get(j).setCount(tempCopy.get(j).getCount() + this.chestContents.get(i).getCount());
|
tempCopy.get(j).grow(this.getItems().get(i).getCount());
|
||||||
|
|
||||||
continue mainLoop;
|
continue mainLoop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempCopy.set(compressedIdx++, this.chestContents.get(i).copy());
|
|
||||||
|
tempCopy.set(compressedIdx++, this.getItems().get(i).copy());
|
||||||
hasStuff = true;
|
hasStuff = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,9 +177,9 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
{
|
{
|
||||||
this.hadStuff = false;
|
this.hadStuff = false;
|
||||||
|
|
||||||
for (int i = 0; i < this.topStacks.size(); i++)
|
for (int i = 0; i < this.getTopItems().size(); i++)
|
||||||
{
|
{
|
||||||
this.topStacks.set(i, ItemStack.EMPTY);
|
this.getTopItems().set(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world != null)
|
if (this.world != null)
|
||||||
|
@ -189,15 +193,16 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
|
|
||||||
this.hadStuff = true;
|
this.hadStuff = true;
|
||||||
|
|
||||||
Collections.sort(tempCopy, new Comparator<ItemStack>() {
|
Collections.sort(tempCopy, new Comparator<ItemStack>()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public int compare(ItemStack stack1, ItemStack stack2)
|
public int compare(ItemStack stack1, ItemStack stack2)
|
||||||
{
|
{
|
||||||
if (stack1 == null)
|
if (stack1 == ItemStack.EMPTY)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (stack2 == null)
|
else if (stack2 == ItemStack.EMPTY)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -210,23 +215,22 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
|
|
||||||
int p = 0;
|
int p = 0;
|
||||||
|
|
||||||
for (int i = 0; i < tempCopy.size(); i++)
|
for (ItemStack element : tempCopy)
|
||||||
{
|
{
|
||||||
ItemStack element = tempCopy.get(i);
|
|
||||||
if (element != ItemStack.EMPTY && element.getCount() > 0)
|
if (element != ItemStack.EMPTY && element.getCount() > 0)
|
||||||
{
|
{
|
||||||
this.topStacks.set(p++, element);
|
this.getTopItems().set(p++, element);
|
||||||
|
|
||||||
if (p == this.topStacks.size())
|
if (p == this.getTopItems().size())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = p; i < this.topStacks.size(); i++)
|
for (int i = p; i < this.getTopItems().size(); i++)
|
||||||
{
|
{
|
||||||
this.topStacks.set(i, ItemStack.EMPTY);
|
this.getTopItems().set(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world != null)
|
if (this.world != null)
|
||||||
|
@ -323,18 +327,13 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
// Resynchronizes clients with the server state
|
// Resynchronizes clients with the server state
|
||||||
//@formatter:off
|
|
||||||
if (this.world != null && !this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.pos.getX() + this.pos.getY() + this.pos.getZ()) % 200 == 0)
|
if (this.world != null && !this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.pos.getX() + this.pos.getY() + this.pos.getZ()) % 200 == 0)
|
||||||
//@formatter:on
|
|
||||||
{
|
{
|
||||||
this.numPlayersUsing = 0;
|
this.numPlayersUsing = 0;
|
||||||
|
|
||||||
float f = 5.0F;
|
float f = 5.0F;
|
||||||
|
|
||||||
//@formatter:off
|
for (EntityPlayer player : this.world.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.world.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
|
|
||||||
{
|
{
|
||||||
if (player.openContainer instanceof ContainerIronChest)
|
if (player.openContainer instanceof ContainerIronChest)
|
||||||
{
|
{
|
||||||
|
@ -367,9 +366,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
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;
|
||||||
|
|
||||||
//@formatter:off
|
|
||||||
this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
|
this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
//@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)
|
||||||
|
@ -398,9 +395,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
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;
|
||||||
|
|
||||||
//@formatter:off
|
|
||||||
this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
|
this.world.playSound(null, x, y, z, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
|
||||||
//@formatter:on
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lidAngle < 0.0F)
|
if (this.lidAngle < 0.0F)
|
||||||
|
@ -471,9 +466,9 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NonNullList<ItemStack> getTopItemStacks()
|
public void setFacing(EnumFacing facing)
|
||||||
{
|
{
|
||||||
return this.topStacks;
|
this.facing = facing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -485,26 +480,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
|
|
||||||
NonNullList<ItemStack> stacks = this.buildItemStackDataList();
|
NonNullList<ItemStack> stacks = this.buildItemStackDataList();
|
||||||
|
|
||||||
if (stacks != null)
|
ItemStackHelper.saveAllItems(compound, stacks);
|
||||||
{
|
|
||||||
NBTTagList itemList = new NBTTagList();
|
|
||||||
|
|
||||||
for (int slot = 0; slot < stacks.size(); slot++)
|
|
||||||
{
|
|
||||||
if (stacks.get(slot) != ItemStack.EMPTY)
|
|
||||||
{
|
|
||||||
NBTTagCompound item = new NBTTagCompound();
|
|
||||||
|
|
||||||
item.setByte("Slot", (byte) slot);
|
|
||||||
|
|
||||||
stacks.get(slot).writeToNBT(item);
|
|
||||||
|
|
||||||
itemList.appendTag(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compound.setTag("stacks", itemList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new SPacketUpdateTileEntity(this.pos, 0, compound);
|
return new SPacketUpdateTileEntity(this.pos, 0, compound);
|
||||||
}
|
}
|
||||||
|
@ -518,35 +494,23 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
|
|
||||||
this.facing = EnumFacing.VALUES[compound.getByte("facing")];
|
this.facing = EnumFacing.VALUES[compound.getByte("facing")];
|
||||||
|
|
||||||
NBTTagList itemList = compound.getTagList("stacks", Constants.NBT.TAG_COMPOUND);
|
NonNullList<ItemStack> stacks = NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
|
||||||
|
|
||||||
ItemStack[] stacks = new ItemStack[this.topStacks.size()];
|
ItemStackHelper.loadAllItems(compound, stacks);
|
||||||
|
|
||||||
for (int item = 0; item < stacks.length; item++)
|
if (this.getType().isTransparent())
|
||||||
{
|
|
||||||
NBTTagCompound itemNBT = itemList.getCompoundTagAt(item);
|
|
||||||
|
|
||||||
int slot = itemNBT.getByte("Slot") & 255;
|
|
||||||
|
|
||||||
if (slot >= 0 && slot < stacks.length)
|
|
||||||
{
|
|
||||||
stacks[slot] = new ItemStack(itemNBT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.getType().isTransparent() && stacks != null)
|
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (int i = 0; i < this.topStacks.size(); i++)
|
for (int i = 0; i < this.getTopItems().size(); i++)
|
||||||
{
|
{
|
||||||
if (stacks[pos] != null)
|
if (stacks.get(pos) != ItemStack.EMPTY)
|
||||||
{
|
{
|
||||||
this.topStacks.set(i, stacks[pos]);
|
this.getTopItems().set(i, stacks.get(pos));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.topStacks.set(i, ItemStack.EMPTY);
|
this.getTopItems().set(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -559,13 +523,12 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
{
|
{
|
||||||
if (this.getType().isTransparent())
|
if (this.getType().isTransparent())
|
||||||
{
|
{
|
||||||
NonNullList<ItemStack> sortList = NonNullList.<ItemStack> withSize(this.topStacks.size(), ItemStack.EMPTY);
|
NonNullList<ItemStack> sortList = NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
for (int i = 0; i < this.topStacks.size(); i++)
|
for (ItemStack is : this.topStacks)
|
||||||
{
|
{
|
||||||
ItemStack is = this.topStacks.get(i);
|
|
||||||
if (is != null)
|
if (is != null)
|
||||||
{
|
{
|
||||||
sortList.set(pos++, is);
|
sortList.set(pos++, is);
|
||||||
|
@ -579,7 +542,7 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
return sortList;
|
return sortList;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return NonNullList.<ItemStack> withSize(this.getTopItems().size(), ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -635,6 +598,11 @@ public class TileEntityIronChest extends TileEntityLockableLoot implements ITick
|
||||||
return this.chestContents;
|
return this.chestContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NonNullList<ItemStack> getTopItems()
|
||||||
|
{
|
||||||
|
return this.topStacks;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty()
|
public boolean isEmpty()
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,6 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
|
|
||||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileEntityIronChest>
|
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileEntityIronChest>
|
||||||
{
|
{
|
||||||
|
@ -81,11 +80,14 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
{
|
{
|
||||||
this.bindTexture(type.modelTexture);
|
this.bindTexture(type.modelTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
if (type == IronChestType.CRYSTAL)
|
if (type == IronChestType.CRYSTAL)
|
||||||
{
|
{
|
||||||
GlStateManager.disableCull();
|
GlStateManager.disableCull();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||||
GlStateManager.translate((float) x, (float) y + 1F, (float) z + 1F);
|
GlStateManager.translate((float) x, (float) y + 1F, (float) z + 1F);
|
||||||
GlStateManager.scale(1F, -1F, -1F);
|
GlStateManager.scale(1F, -1F, -1F);
|
||||||
|
@ -121,7 +123,9 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
||||||
|
|
||||||
float lidangle = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
|
float lidangle = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
|
||||||
|
|
||||||
lidangle = 1F - lidangle;
|
lidangle = 1F - lidangle;
|
||||||
lidangle = 1F - lidangle * lidangle * lidangle;
|
lidangle = 1F - lidangle * lidangle * lidangle;
|
||||||
|
|
||||||
|
@ -133,22 +137,26 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
this.model.chestLid.rotateAngleX = -lidangle * halfPI;
|
this.model.chestLid.rotateAngleX = -lidangle * halfPI;
|
||||||
// Render the chest itself
|
// Render the chest itself
|
||||||
this.model.renderAll();
|
this.model.renderAll();
|
||||||
|
|
||||||
if (destroyStage >= 0)
|
if (destroyStage >= 0)
|
||||||
{
|
{
|
||||||
GlStateManager.matrixMode(5890);
|
GlStateManager.matrixMode(5890);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
GlStateManager.matrixMode(5888);
|
GlStateManager.matrixMode(5888);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == IronChestType.CRYSTAL)
|
if (type == IronChestType.CRYSTAL)
|
||||||
{
|
{
|
||||||
GlStateManager.enableCull();
|
GlStateManager.enableCull();
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||||
|
|
||||||
if (type.isTransparent() && te.getDistanceSq(this.rendererDispatcher.entityX, this.rendererDispatcher.entityY, this.rendererDispatcher.entityZ) < 128d)
|
if (type.isTransparent() && te.getDistanceSq(this.rendererDispatcher.entityX, this.rendererDispatcher.entityY, this.rendererDispatcher.entityZ) < 128d)
|
||||||
{
|
{
|
||||||
this.random.setSeed(254L);
|
this.random.setSeed(254L);
|
||||||
|
|
||||||
float shiftX;
|
float shiftX;
|
||||||
float shiftY;
|
float shiftY;
|
||||||
float shiftZ;
|
float shiftZ;
|
||||||
|
@ -156,7 +164,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
float blockScale = 0.70F;
|
float blockScale = 0.70F;
|
||||||
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
|
float timeD = (float) (360D * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL) - partialTicks;
|
||||||
|
|
||||||
if (te.getTopItemStacks().get(1) == ItemStack.EMPTY)
|
if (te.getTopItems().get(1).isEmpty())
|
||||||
{
|
{
|
||||||
shift = 8;
|
shift = 8;
|
||||||
blockScale = 0.85F;
|
blockScale = 0.85F;
|
||||||
|
@ -168,32 +176,35 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
customitem.setWorld(this.getWorld());
|
customitem.setWorld(this.getWorld());
|
||||||
customitem.hoverStart = 0F;
|
customitem.hoverStart = 0F;
|
||||||
|
|
||||||
NonNullList<ItemStack> stacks = te.getTopItemStacks();
|
for (ItemStack item : te.getTopItems())
|
||||||
for (int i = 0; i < stacks.size(); i++)
|
|
||||||
{
|
{
|
||||||
ItemStack item = stacks.get(i);
|
|
||||||
if (shift > shifts.length)
|
if (shift > shifts.length)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == ItemStack.EMPTY)
|
if (item == ItemStack.EMPTY)
|
||||||
{
|
{
|
||||||
shift++;
|
shift++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
shiftX = shifts[shift][0];
|
shiftX = shifts[shift][0];
|
||||||
shiftY = shifts[shift][1];
|
shiftY = shifts[shift][1];
|
||||||
shiftZ = shifts[shift][2];
|
shiftZ = shifts[shift][2];
|
||||||
shift++;
|
shift++;
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate(shiftX, shiftY, shiftZ);
|
GlStateManager.translate(shiftX, shiftY, shiftZ);
|
||||||
GlStateManager.rotate(timeD, 0F, 1F, 0F);
|
GlStateManager.rotate(timeD, 0F, 1F, 0F);
|
||||||
GlStateManager.scale(blockScale, blockScale, blockScale);
|
GlStateManager.scale(blockScale, blockScale, blockScale);
|
||||||
|
|
||||||
customitem.setEntityItemStack(item);
|
customitem.setEntityItemStack(item);
|
||||||
|
|
||||||
if (this.itemRenderer == null)
|
if (this.itemRenderer == null)
|
||||||
{
|
{
|
||||||
this.itemRenderer = new RenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem()) {
|
this.itemRenderer = new RenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem())
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getModelCount(ItemStack stack)
|
public int getModelCount(ItemStack stack)
|
||||||
{
|
{
|
||||||
|
@ -215,6 +226,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer<TileE
|
||||||
}
|
}
|
||||||
|
|
||||||
this.itemRenderer.doRender(customitem, 0D, 0D, 0D, 0F, partialTicks);
|
this.itemRenderer.doRender(customitem, 0D, 0D, 0D, 0F, partialTicks);
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue