Getting somewhere with the Aludel as well. More to come tonight, for now, hometime and pizza
This commit is contained in:
parent
92b8d6f8c5
commit
7723f846e6
5 changed files with 146 additions and 185 deletions
|
@ -57,8 +57,8 @@ public class Names
|
|||
public static final String VANILLA_CRAFTING = "container.crafting";
|
||||
public static final String ALCHEMICAL_BAG = "container.ee3:" + Items.ALCHEMICAL_BAG;
|
||||
public static final String ALCHEMICAL_CHEST = "container.ee3:" + Blocks.ALCHEMICAL_CHEST;
|
||||
public static final String CALCINATOR_NAME = "container.ee3:" + Blocks.CALCINATOR;
|
||||
public static final String ALUDEL_NAME = "container.ee3:" + Blocks.ALUDEL;
|
||||
public static final String CALCINATOR = "container.ee3:" + Blocks.CALCINATOR;
|
||||
public static final String ALUDEL = "container.ee3:" + Blocks.ALUDEL;
|
||||
|
||||
public static final String GLASS_BELL = "container.ee3:" + Blocks.GLASS_BELL;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class TileEntityAlchemicalChest extends TileEntityEE implements IInventory
|
||||
{
|
||||
public class TileEntityAlchemicalChest extends TileEntityEE implements IInventory {
|
||||
/**
|
||||
* The current angle of the chest lid (between 0 and 1)
|
||||
*/
|
||||
|
@ -37,52 +36,38 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
*/
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public TileEntityAlchemicalChest(int metaData)
|
||||
{
|
||||
public TileEntityAlchemicalChest(int metaData) {
|
||||
super();
|
||||
this.state = (byte) metaData;
|
||||
|
||||
if (metaData == 0)
|
||||
{
|
||||
if (metaData == 0) {
|
||||
inventory = new ItemStack[ContainerAlchemicalChest.SMALL_INVENTORY_SIZE];
|
||||
}
|
||||
else if (metaData == 1)
|
||||
{
|
||||
} else if (metaData == 1) {
|
||||
inventory = new ItemStack[ContainerAlchemicalChest.MEDIUM_INVENTORY_SIZE];
|
||||
}
|
||||
else if (metaData == 2)
|
||||
{
|
||||
} else if (metaData == 2) {
|
||||
inventory = new ItemStack[ContainerAlchemicalChest.LARGE_INVENTORY_SIZE];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
public int getSizeInventory() {
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount) {
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.stackSize <= decrementAmount)
|
||||
{
|
||||
if (itemStack != null) {
|
||||
if (itemStack.stackSize <= decrementAmount) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemStack = itemStack.splitStack(decrementAmount);
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
if (itemStack.stackSize == 0) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
}
|
||||
|
@ -92,27 +77,21 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex)
|
||||
{
|
||||
if (inventory[slotIndex] != null)
|
||||
{
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
if (inventory[slotIndex] != null) {
|
||||
ItemStack itemStack = inventory[slotIndex];
|
||||
inventory[slotIndex] = null;
|
||||
return itemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
|
||||
inventory[slotIndex] = itemStack;
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) {
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
|
@ -121,32 +100,27 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALCHEMICAL_CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not make give this method the name canInteractWith because it clashes with Container
|
||||
*
|
||||
* @param entityplayer
|
||||
* The player we are checking to see if they can use this chest
|
||||
* @param entityplayer The player we are checking to see if they can use this chest
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -154,69 +128,56 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
* Called when a client event is received with the event number and argument, see World.sendClientEvent
|
||||
*/
|
||||
@Override
|
||||
public boolean receiveClientEvent(int eventID, int numUsingPlayers)
|
||||
{
|
||||
if (eventID == 1)
|
||||
{
|
||||
public boolean receiveClientEvent(int eventID, int numUsingPlayers) {
|
||||
if (eventID == 1) {
|
||||
this.numUsingPlayers = numUsingPlayers;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return super.receiveClientEvent(eventID, numUsingPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
public void openInventory() {
|
||||
++numUsingPlayers;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
public void closeInventory() {
|
||||
--numUsingPlayers;
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
// Read in the ItemStacks in the inventory from NBT
|
||||
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
byte slotIndex = tagCompound.getByte("Slot");
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length)
|
||||
{
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length) {
|
||||
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
|
||||
{
|
||||
if (inventory[currentIndex] != null)
|
||||
{
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
|
@ -231,12 +192,10 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (++ticksSinceSync % 20 * 4 == 0)
|
||||
{
|
||||
if (++ticksSinceSync % 20 * 4 == 0) {
|
||||
worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers);
|
||||
}
|
||||
|
||||
|
@ -244,40 +203,32 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor
|
|||
float angleIncrement = 0.1F;
|
||||
double adjustedXCoord, adjustedZCoord;
|
||||
|
||||
if (numUsingPlayers > 0 && lidAngle == 0.0F)
|
||||
{
|
||||
if (numUsingPlayers > 0 && lidAngle == 0.0F) {
|
||||
adjustedXCoord = xCoord + 0.5D;
|
||||
adjustedZCoord = zCoord + 0.5D;
|
||||
worldObj.playSoundEffect(adjustedXCoord, yCoord + 0.5D, adjustedZCoord, Sounds.CHEST_OPEN, 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F)
|
||||
{
|
||||
if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) {
|
||||
float var8 = lidAngle;
|
||||
|
||||
if (numUsingPlayers > 0)
|
||||
{
|
||||
if (numUsingPlayers > 0) {
|
||||
lidAngle += angleIncrement;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
lidAngle -= angleIncrement;
|
||||
}
|
||||
|
||||
if (lidAngle > 1.0F)
|
||||
{
|
||||
if (lidAngle > 1.0F) {
|
||||
lidAngle = 1.0F;
|
||||
}
|
||||
|
||||
if (lidAngle < 0.5F && var8 >= 0.5F)
|
||||
{
|
||||
if (lidAngle < 0.5F && var8 >= 0.5F) {
|
||||
adjustedXCoord = xCoord + 0.5D;
|
||||
adjustedZCoord = zCoord + 0.5D;
|
||||
worldObj.playSoundEffect(adjustedXCoord, yCoord + 0.5D, adjustedZCoord, Sounds.CHEST_CLOSE, 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
||||
}
|
||||
|
||||
if (lidAngle < 0.0F)
|
||||
{
|
||||
if (lidAngle < 0.0F) {
|
||||
lidAngle = 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package com.pahimar.ee3.tileentity;
|
||||
|
||||
import com.pahimar.ee3.item.ItemAlchemicalDust;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.network.message.MessageTileEntityAludel;
|
||||
import com.pahimar.ee3.reference.Names;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
||||
{
|
||||
|
@ -14,10 +18,13 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
|||
public static final int INPUT_INVENTORY_INDEX = 1;
|
||||
public static final int DUST_INVENTORY_INDEX = 2;
|
||||
public static final int OUTPUT_INVENTORY_INDEX = 3;
|
||||
|
||||
public int deviceCookTime; // How much longer the Aludel will cook
|
||||
public int fuelBurnTime; // The fuel value for the currently burning fuel
|
||||
public int itemCookTime; // How long the current item has been "cooking"
|
||||
|
||||
public ItemStack outputItemStack;
|
||||
|
||||
public boolean hasGlassBell = false;
|
||||
/**
|
||||
* The ItemStacks that hold the items currently being used in the Aludel
|
||||
|
@ -30,94 +37,130 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1)
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return new int[0];
|
||||
return side == ForgeDirection.DOWN.ordinal() ? new int[]{FUEL_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX} : new int[]{INPUT_INVENTORY_INDEX, DUST_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int var1, ItemStack var2, int var3)
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side)
|
||||
{
|
||||
if (worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileEntityGlassBell) {
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int var1, ItemStack var2, int var3)
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side)
|
||||
{
|
||||
return false;
|
||||
return slotIndex == OUTPUT_INVENTORY_INDEX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 0;
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1)
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
return null;
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int var1, int var2)
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
return null;
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null) {
|
||||
if (itemStack.stackSize <= decrementAmount) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
} else {
|
||||
itemStack = itemStack.splitStack(decrementAmount);
|
||||
if (itemStack.stackSize == 0) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1)
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex)
|
||||
{
|
||||
return null;
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int var1, ItemStack var2)
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
|
||||
inventory[slotIndex] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return null;
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALUDEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 0;
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2)
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
switch (slotIndex) {
|
||||
case FUEL_INVENTORY_INDEX: {
|
||||
return TileEntityFurnace.isItemFuel(itemStack);
|
||||
}
|
||||
case INPUT_INVENTORY_INDEX: {
|
||||
return true;
|
||||
}
|
||||
case DUST_INVENTORY_INDEX: {
|
||||
return itemStack.getItem() instanceof ItemAlchemicalDust;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
|
|
|
@ -106,12 +106,12 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor
|
|||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.CALCINATOR_NAME;
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.CALCINATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,8 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
public class TileEntityGlassBell extends TileEntityEE implements IInventory
|
||||
{
|
||||
public class TileEntityGlassBell extends TileEntityEE implements IInventory {
|
||||
public static final int INVENTORY_SIZE = 1;
|
||||
public static final int DISPLAY_SLOT_INVENTORY_INDEX = 0;
|
||||
public ItemStack outputItemStack;
|
||||
|
@ -23,38 +22,29 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory
|
|||
*/
|
||||
private ItemStack[] inventory;
|
||||
|
||||
public TileEntityGlassBell()
|
||||
{
|
||||
public TileEntityGlassBell() {
|
||||
inventory = new ItemStack[INVENTORY_SIZE];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
public int getSizeInventory() {
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex)
|
||||
{
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
return inventory[slotIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount)
|
||||
{
|
||||
public ItemStack decrStackSize(int slotIndex, int decrementAmount) {
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.stackSize <= decrementAmount)
|
||||
{
|
||||
if (itemStack != null) {
|
||||
if (itemStack.stackSize <= decrementAmount) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemStack = itemStack.splitStack(decrementAmount);
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
if (itemStack.stackSize == 0) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
}
|
||||
|
@ -64,36 +54,28 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex)
|
||||
{
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
ItemStack itemStack = getStackInSlot(slotIndex);
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack != null) {
|
||||
setInventorySlotContents(slotIndex, null);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemStack) {
|
||||
inventory[slotIndex] = itemStack;
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (!this.worldObj.isRemote) {
|
||||
ItemStack displayStack = this.inventory[DISPLAY_SLOT_INVENTORY_INDEX];
|
||||
|
||||
if (displayStack != null)
|
||||
{
|
||||
if (displayStack != null) {
|
||||
this.state = (byte) Block.getBlockFromItem(displayStack.getItem()).getLightValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.state = 0;
|
||||
}
|
||||
|
||||
|
@ -104,75 +86,62 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomName() ? this.getCustomName() : Names.Containers.GLASS_BELL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
|
||||
// Read in the ItemStacks in the inventory from NBT
|
||||
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[this.getSizeInventory()];
|
||||
for (int i = 0; i < tagList.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); ++i) {
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
byte slotIndex = tagCompound.getByte("Slot");
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length)
|
||||
{
|
||||
if (slotIndex >= 0 && slotIndex < inventory.length) {
|
||||
inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.writeToNBT(nbtTagCompound);
|
||||
|
||||
// Write the ItemStacks in the inventory to NBT
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex)
|
||||
{
|
||||
if (inventory[currentIndex] != null)
|
||||
{
|
||||
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
|
||||
if (inventory[currentIndex] != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte) currentIndex);
|
||||
inventory[currentIndex].writeToNBT(tagCompound);
|
||||
|
@ -183,10 +152,8 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
if (getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX) != null && getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX).stackSize > 0)
|
||||
{
|
||||
public Packet getDescriptionPacket() {
|
||||
if (getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX) != null && getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX).stackSize > 0) {
|
||||
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityGlassBell(this, getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue