Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -17,22 +17,27 @@ import net.minecraft.util.IChatComponent;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileInventory extends TileEntity implements IInventory {
|
||||
public class TileInventory extends TileEntity implements IInventory
|
||||
{
|
||||
|
||||
protected int[] syncedSlots = new int[0];
|
||||
private ItemStack[] inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
|
||||
public TileInventory(int size, String name) {
|
||||
public TileInventory(int size, String name)
|
||||
{
|
||||
this.inventory = new ItemStack[size];
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private boolean isSyncedSlot(int slot) {
|
||||
for (int s : this.syncedSlots) {
|
||||
if (s == slot) {
|
||||
private boolean isSyncedSlot(int slot)
|
||||
{
|
||||
for (int s : this.syncedSlots)
|
||||
{
|
||||
if (s == slot)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -40,17 +45,21 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
NBTTagList tags = tagCompound.getTagList("Items", 10);
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
if (!isSyncedSlot(i))
|
||||
{
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
byte j = data.getByte("Slot");
|
||||
|
||||
if (j >= 0 && j < inventory.length) {
|
||||
if (j >= 0 && j < inventory.length)
|
||||
{
|
||||
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +67,15 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if ((inventory[i] != null) && !isSyncedSlot(i)) {
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
if ((inventory[i] != null) && !isSyncedSlot(i))
|
||||
{
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(data);
|
||||
|
@ -75,46 +87,55 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
super.onDataPacket(net, pkt);
|
||||
readFromNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
|
||||
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||
{
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
}
|
||||
|
||||
public void dropItems() {
|
||||
public void dropItems()
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
|
||||
}
|
||||
|
||||
// IInventory
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index) {
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return inventory[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (inventory[index] != null) {
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
if (inventory[index] != null)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
worldObj.markBlockForUpdate(this.pos);
|
||||
|
||||
if (inventory[index].stackSize <= count) {
|
||||
if (inventory[index].stackSize <= count)
|
||||
{
|
||||
ItemStack itemStack = inventory[index];
|
||||
inventory[index] = null;
|
||||
markDirty();
|
||||
|
@ -133,8 +154,10 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
if (inventory[slot] != null) {
|
||||
public ItemStack removeStackFromSlot(int slot)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
ItemStack itemStack = inventory[slot];
|
||||
setInventorySlotContents(slot, null);
|
||||
return itemStack;
|
||||
|
@ -143,7 +166,8 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
inventory[slot] = stack;
|
||||
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
||||
stack.stackSize = getInventoryStackLimit();
|
||||
|
@ -153,64 +177,76 @@ public class TileInventory extends TileEntity implements IInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player) {
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id) {
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value) {
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount() {
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public void clear()
|
||||
{
|
||||
this.inventory = new ItemStack[size];
|
||||
}
|
||||
|
||||
// IWorldNameable
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return StatCollector.translateToLocal("tile.BloodMagic." + name + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName() {
|
||||
public IChatComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue