Fixed up some stuff with the vat.

This commit is contained in:
cp committed 2014-03-28 22:41:47 +08:00
1 parent fae5fe6f54
commit cbaee02e9b
4 files changed
+95 -3

No files matched your search

+1 -1
View File
@@ -311,7 +311,7 @@ public final class Config {
hootchPowerPerCycle = config.get("Settings", "hootchPowerPerCycle", hootchPowerPerCycle,
"The amount of power generated per BC engine cycle. Examples: BC Oil = 3, BC Fuel = 6").getInt(hootchPowerPerCycle);
hootchPowerTotalBurnTime = config.get("Settings", "hootchPowerTotalBurnTime", hootchPowerPerCycle,
hootchPowerTotalBurnTime = config.get("Settings", "hootchPowerTotalBurnTime", hootchPowerTotalBurnTime,
"The total burn time. Examples: BC Oil = 5000, BC Fuel = 25000").getInt(hootchPowerTotalBurnTime);
//TODO: Debug
@@ -106,8 +106,13 @@ public class BlockReservoir extends BlockContainer {
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
if(available != null) {
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
if(current.getItem() == Items.bucket) {
filled = new ItemStack(Items.water_bucket);
}
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
if(current.getItem() == Items.bucket) {
liquid = new FluidStack(FluidRegistry.WATER, 1000);
}
if(liquid != null) {
if(!entityPlayer.capabilities.isCreativeMode) {
@@ -1,11 +1,20 @@
package crazypants.enderio.machine.still;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.util.ItemUtil;
import crazypants.util.Util;
public class BlockVat extends AbstractMachineBlock<TileVat> {
@@ -19,6 +28,84 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
super(ModObject.blockVat, TileVat.class);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileVat)) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
TileVat vat = (TileVat) te;
ItemStack item = entityPlayer.inventory.getCurrentItem();
if(item == null) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
//check for filled fluid containers and see if we can fill up
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if(fluid == null) {
if(item.getItem() == Items.water_bucket) {
fluid = new FluidStack(FluidRegistry.WATER, 1000);
} else if(item.getItem() == Items.lava_bucket) {
fluid = new FluidStack(FluidRegistry.LAVA, 1000);
}
}
if(fluid != null) {
int filled = vat.fill(ForgeDirection.UP, fluid, false);
if(filled >= fluid.amount) {
vat.fill(ForgeDirection.UP, fluid, true);
}
if(!entityPlayer.capabilities.isCreativeMode) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, Util.consumeItem(item));
}
return true;
}
//now check for empty fluid containers to fill
FluidStack available = vat.outputTank.getFluid();
if(available != null) {
ItemStack res = FluidContainerRegistry.fillFluidContainer(available.copy(), item);
FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(res);
if(filled == null) { //this shouldn't be necessary but it appears to be a bug as the above method doesnt work
FluidContainerData[] datas = FluidContainerRegistry.getRegisteredFluidContainerData();
for (FluidContainerData data : datas) {
if(data.fluid.getFluid().getName().equals(available.getFluid().getName())) {
res = data.filledContainer.copy();
filled = FluidContainerRegistry.getFluidForFilledItem(res);
}
}
}
if(filled != null) {
vat.drain(ForgeDirection.DOWN, filled, true);
if(item.stackSize > 1) {
item.stackSize--;
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, item);
for (int i = 0; i < entityPlayer.inventory.mainInventory.length; i++) {
if(entityPlayer.inventory.mainInventory[i] == null) {
entityPlayer.inventory.setInventorySlotContents(i, res);
return true;
}
}
if(!world.isRemote) {
Util.dropItems(world, res, x, y, z, true);
}
} else {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, res);
}
return true;
}
}
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
// The server needs the container as it manages the adding and removing of
@@ -146,7 +146,7 @@ public class TileVat extends AbstractPoweredTaskEntity implements IFluidHandler
inputTank.setFluid(null);
}
if(nbtRoot.hasKey("inputTank")) {
if(nbtRoot.hasKey("outputTank")) {
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("outputTank");
if(tankRoot != null) {
outputTank.readFromNBT(tankRoot);