Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.grossik.farmcraft2.racks;
- import javax.annotation.Nullable;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.ISidedInventory;
- import net.minecraft.inventory.ItemStackHelper;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.tileentity.TileEntityLockable;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.ITickable;
- import net.minecraftforge.fml.common.FMLCommonHandler;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class TileEntityRacks extends TileEntityLockable implements ITickable, ISidedInventory
- {
- private ItemStack[] wineItemStacks = new ItemStack[9];
- private String furnaceCustomName;
- private NBTTagCompound update_packet;
- public int getSizeInventory()
- {
- return this.wineItemStacks.length;
- }
- public ItemStack getStackInSlot(int index)
- {
- return this.wineItemStacks[index];
- }
- @Nullable
- public ItemStack decrStackSize(int index, int count)
- {
- return ItemStackHelper.getAndSplit(this.wineItemStacks, index, count);
- }
- @Nullable
- public ItemStack removeStackFromSlot(int index)
- {
- return ItemStackHelper.getAndRemove(this.wineItemStacks, index);
- }
- public void setCustomInventoryName(String p_145951_1_)
- {
- this.furnaceCustomName = p_145951_1_;
- }
- public void setInventorySlotContents(int index, ItemStack stack)
- {
- boolean flag = stack != null && stack.isItemEqual(this.wineItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.wineItemStacks[index]);
- this.wineItemStacks[index] = stack;
- if (stack != null && stack.stackSize > this.getInventoryStackLimit())
- {
- stack.stackSize = this.getInventoryStackLimit();
- }
- }
- @Override
- public int getInventoryStackLimit() {
- return 1;
- }
- public void readFromNBT(NBTTagCompound compound)
- {
- super.readFromNBT(compound);
- NBTTagList nbttaglist = compound.getTagList("Items", 10);
- this.wineItemStacks = new ItemStack[this.getSizeInventory()];
- for (int i = 0; i < nbttaglist.tagCount(); ++i)
- {
- NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
- int j = nbttagcompound.getByte("Slot");
- if (j >= 0 && j < this.wineItemStacks.length)
- {
- this.wineItemStacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
- }
- }
- if (compound.hasKey("CustomName", 8))
- {
- this.furnaceCustomName = compound.getString("CustomName");
- }
- }
- public NBTTagCompound writeToNBT(NBTTagCompound compound)
- {
- super.writeToNBT(compound);
- NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < this.wineItemStacks.length; ++i)
- {
- if (this.wineItemStacks[i] != null)
- {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- nbttagcompound.setByte("Slot", (byte)i);
- this.wineItemStacks[i].writeToNBT(nbttagcompound);
- nbttaglist.appendTag(nbttagcompound);
- }
- }
- compound.setTag("Items", nbttaglist);
- if (this.hasCustomName())
- {
- compound.setString("CustomName", this.furnaceCustomName);
- }
- return compound;
- }
- public boolean isUseableByPlayer(EntityPlayer player)
- {
- return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
- }
- public void openInventory(EntityPlayer player)
- {
- }
- public void closeInventory(EntityPlayer player)
- {
- }
- public boolean isItemValidForSlot(int index, ItemStack stack) {
- return false;
- }
- @Override
- public int getField(int id) {
- return 0;
- }
- @Override
- public void setField(int id, int value) {
- }
- @Override
- public int getFieldCount() {
- return 0;
- }
- public void clear()
- {
- for (int i = 0; i < this.wineItemStacks.length; ++i)
- {
- this.wineItemStacks[i] = null;
- }
- }
- public String getName() {
- return this.hasCustomName() ? this.furnaceCustomName : "Racks";
- }
- public boolean hasCustomName()
- {
- return this.furnaceCustomName != null && !this.furnaceCustomName.isEmpty();
- }
- @Override
- public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
- return new ContainerRacks(playerInventory, this);
- }
- @Override
- public String getGuiID() {
- return "10";
- }
- @Override
- public int[] getSlotsForFace(EnumFacing side) {
- return null;
- }
- @Override
- public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
- return this.isItemValidForSlot(index, itemStackIn);
- }
- public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
- return true;
- }
- @Override
- public void update() {
- boolean Check00 = this.Check0();
- System.out.println(" " + Check00);
- }
- public boolean Check0(){
- if(wineItemStacks[0] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check1(){
- if(wineItemStacks[1] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check2(){
- if(wineItemStacks[2] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check3(){
- if(wineItemStacks[3] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check4(){
- if(wineItemStacks[4] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check5(){
- if(wineItemStacks[5] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check6(){
- if(wineItemStacks[6] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check7(){
- if(wineItemStacks[7] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- public boolean Check8(){
- if(wineItemStacks[8] != null)
- {
- return true;
- } else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment