Finishing off for tonight.
This commit is contained in:
parent
da25ed6add
commit
700012697e
6 changed files with 375 additions and 9 deletions
|
@ -2,11 +2,24 @@ package techreborn.tiles;
|
|||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import techreborn.Core;
|
||||
import techreborn.util.Inventory;
|
||||
import techreborn.util.Tank;
|
||||
|
||||
public class TileThermalGenerator extends TileEntity implements IWrenchable, IFluidHandler, IInventory {
|
||||
|
||||
public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 16, this);
|
||||
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64);
|
||||
|
||||
public class TileThermalGenerator extends TileEntity implements IWrenchable {
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return false;
|
||||
|
@ -36,4 +49,143 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable {
|
|||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(Core.thermalGenerator, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
if (fluid != null) {
|
||||
if (FluidRegistry.getFluidName(fluid.getID()).contentEquals("lava")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return getTankInfo(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
tank.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
tank.writeToNBT(tagCompound);
|
||||
inventory.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if(tank.getFluidAmount() != 0){
|
||||
setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock(), 1));
|
||||
}
|
||||
// if(getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof IFluidContainerItem){
|
||||
// FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(getStackInSlot(0));
|
||||
// // TODO
|
||||
// if (liquid != null) {
|
||||
// int qty = fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int p_70301_1_) {
|
||||
return inventory.getStackInSlot(p_70301_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
|
||||
return inventory.decrStackSize(p_70298_1_, p_70298_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
|
||||
return inventory.getStackInSlotOnClosing(p_70304_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
|
||||
inventory.setInventorySlotContents(p_70299_1_, p_70299_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return inventory.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return inventory.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
|
||||
return inventory.isUseableByPlayer(p_70300_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
inventory.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
inventory.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue