Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
src/main/java/WayofTime/bloodmagic/tile
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.tile.base.TileBase;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -17,29 +18,31 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
|||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class TileInventory extends TileBase implements IInventory
|
||||
{
|
||||
public class TileInventory extends TileBase implements IInventory {
|
||||
protected int[] syncedSlots = new int[0];
|
||||
protected NonNullList<ItemStack> inventory;
|
||||
IItemHandler handlerDown;
|
||||
IItemHandler handlerUp;
|
||||
IItemHandler handlerNorth;
|
||||
IItemHandler handlerSouth;
|
||||
IItemHandler handlerWest;
|
||||
IItemHandler handlerEast;
|
||||
private int size;
|
||||
|
||||
// IInventory
|
||||
private String name;
|
||||
|
||||
public TileInventory(int size, String name)
|
||||
{
|
||||
public TileInventory(int size, String name) {
|
||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
initializeItemHandlers();
|
||||
}
|
||||
|
||||
protected boolean isSyncedSlot(int slot)
|
||||
{
|
||||
for (int s : this.syncedSlots)
|
||||
{
|
||||
if (s == slot)
|
||||
{
|
||||
protected boolean isSyncedSlot(int slot) {
|
||||
for (int s : this.syncedSlots) {
|
||||
if (s == slot) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -47,21 +50,17 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void deserialize(NBTTagCompound tagCompound) {
|
||||
super.deserialize(tagCompound);
|
||||
NBTTagList tags = tagCompound.getTagList("Items", 10);
|
||||
inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
|
||||
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.size())
|
||||
{
|
||||
if (j >= 0 && j < inventory.size()) {
|
||||
inventory.set(j, new ItemStack(data)); // No matter how much an i looks like a j, it is not one. They are drastically different characters and cause drastically different things to happen. Apparently I didn't know this at one point. - TehNut
|
||||
}
|
||||
}
|
||||
|
@ -69,15 +68,12 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound)
|
||||
{
|
||||
public NBTTagCompound serialize(NBTTagCompound tagCompound) {
|
||||
super.serialize(tagCompound);
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.size(); i++)
|
||||
{
|
||||
if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i))
|
||||
{
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte("Slot", (byte) i);
|
||||
inventory.get(i).writeToNBT(data);
|
||||
|
@ -89,35 +85,27 @@ public class TileInventory extends TileBase implements IInventory
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
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.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
if (!getStackInSlot(index).isEmpty())
|
||||
{
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (!getStackInSlot(index).isEmpty()) {
|
||||
if (!getWorld().isRemote)
|
||||
getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3);
|
||||
|
||||
if (getStackInSlot(index).getCount() <= count)
|
||||
{
|
||||
if (getStackInSlot(index).getCount() <= count) {
|
||||
ItemStack itemStack = inventory.get(index);
|
||||
inventory.set(index, ItemStack.EMPTY);
|
||||
markDirty();
|
||||
|
@ -133,10 +121,8 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot)
|
||||
{
|
||||
if (!inventory.get(slot).isEmpty())
|
||||
{
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
if (!inventory.get(slot).isEmpty()) {
|
||||
ItemStack itemStack = inventory.get(slot);
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
return itemStack;
|
||||
|
@ -145,8 +131,7 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.set(slot, stack);
|
||||
if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit())
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
|
@ -156,50 +141,44 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
// IWorldNameable
|
||||
|
||||
@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 = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
|
@ -217,38 +196,30 @@ public class TileInventory extends TileBase implements IInventory
|
|||
return true;
|
||||
}
|
||||
|
||||
// IWorldNameable
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return TextHelper.localize("tile.bloodmagic." + name + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
public boolean hasCustomName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TextComponentString(getName());
|
||||
}
|
||||
|
||||
protected void initializeItemHandlers()
|
||||
{
|
||||
if (this instanceof ISidedInventory)
|
||||
{
|
||||
protected void initializeItemHandlers() {
|
||||
if (this instanceof ISidedInventory) {
|
||||
handlerDown = new SidedInvWrapper((ISidedInventory) this, EnumFacing.DOWN);
|
||||
handlerUp = new SidedInvWrapper((ISidedInventory) this, EnumFacing.UP);
|
||||
handlerNorth = new SidedInvWrapper((ISidedInventory) this, EnumFacing.NORTH);
|
||||
handlerSouth = new SidedInvWrapper((ISidedInventory) this, EnumFacing.SOUTH);
|
||||
handlerWest = new SidedInvWrapper((ISidedInventory) this, EnumFacing.WEST);
|
||||
handlerEast = new SidedInvWrapper((ISidedInventory) this, EnumFacing.EAST);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
handlerDown = new InvWrapper(this);
|
||||
handlerUp = handlerDown;
|
||||
handlerNorth = handlerDown;
|
||||
|
@ -258,36 +229,25 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
}
|
||||
|
||||
IItemHandler handlerDown;
|
||||
IItemHandler handlerUp;
|
||||
IItemHandler handlerNorth;
|
||||
IItemHandler handlerSouth;
|
||||
IItemHandler handlerWest;
|
||||
IItemHandler handlerEast;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
|
||||
{
|
||||
if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
switch (facing)
|
||||
{
|
||||
case DOWN:
|
||||
return (T) handlerDown;
|
||||
case EAST:
|
||||
return (T) handlerEast;
|
||||
case NORTH:
|
||||
return (T) handlerNorth;
|
||||
case SOUTH:
|
||||
return (T) handlerSouth;
|
||||
case UP:
|
||||
return (T) handlerUp;
|
||||
case WEST:
|
||||
return (T) handlerWest;
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
return (T) handlerDown;
|
||||
case EAST:
|
||||
return (T) handlerEast;
|
||||
case NORTH:
|
||||
return (T) handlerNorth;
|
||||
case SOUTH:
|
||||
return (T) handlerSouth;
|
||||
case UP:
|
||||
return (T) handlerUp;
|
||||
case WEST:
|
||||
return (T) handlerWest;
|
||||
}
|
||||
} else if (facing == null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
||||
{
|
||||
} else if (facing == null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return (T) handlerDown;
|
||||
}
|
||||
|
||||
|
@ -295,8 +255,7 @@ public class TileInventory extends TileBase implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
|
||||
{
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue