Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Looke81.BioWarfare.tileentity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.inventory.IInventory;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.network.NetworkManager;
- import net.minecraft.network.Packet;
- import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraftforge.common.util.Constants;
- public class TileEntityAgarPlate extends TileEntity implements IInventory{
- public static final int sizeInv = 1;
- private ItemStack[] inv;
- private int resultID;
- private int resultDamage;
- private int upgradeLevel;
- public int capacity;
- private boolean isActive;
- private int liquidRequired; //mB
- private boolean canBeFilled;
- private int consumptionRate;
- private int drainRate;
- private float consumptionMultiplier;
- private float efficiencyMultiplier;
- private float sacrificeEfficiencyMultiplier;
- private float selfSacrificeEfficiencyMultiplier;
- private float capacityMultiplier;
- private float orbCapacityMultiplier;
- private float dislocationMultiplier;
- private int accelerationUpgrades;
- private boolean isUpgraded;
- private boolean isResultBlock;
- private int bufferCapacity;
- private int progress;
- private int hasChanged = 0;
- public TileEntityAgarPlate()
- {
- this.inv = new ItemStack[1];
- resultID = 0;
- resultDamage = 0;
- isActive = false;
- consumptionRate = 0;
- drainRate = 0;
- consumptionMultiplier = 0;
- efficiencyMultiplier = 0;
- capacityMultiplier = 1;
- isUpgraded = false;
- upgradeLevel = 0;
- isResultBlock = false;
- progress = 0;
- }
- public ItemStack displayItem;
- public void writeToNBT(NBTTagCompound tag)
- {
- super.writeToNBT(tag);
- NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < this.inv.length; ++i)
- {
- if (this.inv[i] != null)
- {
- NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- nbttagcompound1.setByte("slot", (byte)i);
- this.inv[i].writeToNBT(nbttagcompound1);
- nbttaglist.appendTag(nbttagcompound1);
- }
- }
- }
- public void readFromNBT(NBTTagCompound p_145839_1_)
- {
- super.readFromNBT(p_145839_1_);
- NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
- this.inv = new ItemStack[this.getSizeInventory()];
- for (int i = 0; i < nbttaglist.tagCount(); ++i)
- {
- NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
- int j = nbttagcompound1.getByte("slot");
- if (j >= 0 && j < this.inv.length)
- {
- this.inv[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
- }
- }
- }
- @Override
- public Packet getDescriptionPacket() {
- NBTTagCompound nbtTag = new NBTTagCompound();
- writeToNBT(nbtTag);
- return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbtTag);
- }
- @Override
- public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
- readFromNBT(packet.func_148857_g());
- }
- @Override
- public ItemStack getStackInSlot(int slot)
- {
- return inv[slot];
- }
- @Override
- public int getSizeInventory() {
- return 1;
- }
- @Override
- public ItemStack decrStackSize(int slot, int amt) {
- ItemStack stack = getStackInSlot(slot);
- if (stack != null)
- {
- if (stack.stackSize <= amt)
- {
- setInventorySlotContents(slot, null);
- } else
- {
- stack = stack.splitStack(amt);
- if (stack.stackSize == 0)
- {
- setInventorySlotContents(slot, null);
- }
- }
- }
- return stack;
- }
- @Override
- public ItemStack getStackInSlotOnClosing(int slot)
- {
- ItemStack stack = getStackInSlot(slot);
- if (stack != null)
- {
- setInventorySlotContents(slot, null);
- }
- return stack;
- }
- @Override
- public void setInventorySlotContents(int slot, ItemStack itemStack)
- {
- inv[slot] = itemStack;
- this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- if (itemStack != null && itemStack.stackSize > getInventoryStackLimit())
- {
- itemStack.stackSize = getInventoryStackLimit();
- }
- }
- @Override
- public String getInventoryName() {
- return "TileEntityAgarPlate" ;
- }
- @Override
- public boolean hasCustomInventoryName() {
- return false;
- }
- @Override
- public int getInventoryStackLimit() {
- return 2;
- }
- @Override
- public boolean isUseableByPlayer(EntityPlayer entityPlayer)
- {
- return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
- }
- @Override
- public void openInventory() {
- }
- @Override
- public void closeInventory() {
- }
- @Override
- public boolean isItemValidForSlot(int slot, ItemStack itemstack)
- {
- return slot == 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement