Begin to utilise new fluidutils methods, and refine fluid management within our tile entities
parent
0946a5af29
commit
46982ef0f7
|
@ -26,8 +26,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
|||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import boilerplate.common.baseclasses.BaseTileWithInventory;
|
||||
import boilerplate.common.utils.FluidUtils;
|
||||
import steamcraft.common.blocks.machines.BlockBaseBoiler;
|
||||
import steamcraft.common.items.ItemCanister;
|
||||
|
||||
/**
|
||||
* @author Decebaldecebal
|
||||
|
@ -102,25 +102,12 @@ public abstract class TileBaseBoiler extends BaseTileWithInventory implements IF
|
|||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(this.inventory[1]);
|
||||
|
||||
if ((liquid != null) && (this.waterTank.fill(new FluidStack(FluidRegistry.getFluid("water"), liquid.amount), false) == liquid.amount))
|
||||
if (liquid.getFluid() == FluidRegistry.WATER)
|
||||
{
|
||||
this.waterTank.fill(new FluidStack(FluidRegistry.getFluid("water"), liquid.amount), true);
|
||||
|
||||
if (this.inventory[1].stackSize > 1)
|
||||
this.inventory[1].stackSize--;
|
||||
else
|
||||
this.inventory[1] = this.inventory[1].getItem().getContainerItem(this.inventory[1]);
|
||||
if ((liquid != null) && liquid.getFluid() == FluidRegistry.WATER)
|
||||
FluidUtils.drainFluidContainer(this.waterTank, this.inventory[1], this.inventory[2]);
|
||||
}
|
||||
}
|
||||
if ((this.inventory[2] != null) && (this.inventory[2].getItem() instanceof ItemCanister))
|
||||
if ((this.inventory[3] != null))
|
||||
{
|
||||
ItemCanister canister = (ItemCanister) this.inventory[2].getItem();
|
||||
if ((this.steamTank.getFluidAmount() >= steamPerTick) && (canister.getFluidAmount(this.inventory[2]) != canister.maxSteam))
|
||||
{
|
||||
canister.fill(this.inventory[2], new FluidStack(FluidRegistry.getFluid("steam"), steamPerTick), true);
|
||||
this.steamTank.drain(steamPerTick, true);
|
||||
}
|
||||
FluidUtils.fillFluidContainer(steamTank, this.inventory[3], this.inventory[3]);
|
||||
}
|
||||
|
||||
if ((this.getItemBurnTime(inventory[0]) > 0) && (this.furnaceBurnTime == 0) && (this.waterTank.getFluidAmount() >= waterPerTick)
|
||||
|
|
|
@ -29,6 +29,8 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import boilerplate.common.baseclasses.blocks.BaseContainer;
|
||||
import steamcraft.common.items.ItemCanister;
|
||||
import steamcraft.common.tiles.TileSteamBoiler;
|
||||
import steamcraft.common.tiles.container.slot.SlotFluidContainer;
|
||||
import steamcraft.common.tiles.container.slot.SlotOutput;
|
||||
|
||||
/**
|
||||
* @author Decebaldecebal
|
||||
|
@ -49,22 +51,9 @@ public class ContainerSteamBoiler extends BaseContainer
|
|||
this.setTile(this.tileent);
|
||||
|
||||
this.addSlotToContainer(new Slot(tile, 0, 42, 52));
|
||||
this.addSlotToContainer(new Slot(tile, 1, 132, 57)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return FluidContainerRegistry.isContainer(stack);
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(tile, 2, 132, 21)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemCanister;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new SlotFluidContainer(tile, 1, 132, 57));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 2, 132, 30));
|
||||
this.addSlotToContainer(new SlotFluidContainer(tile, 3, 132, 21));
|
||||
|
||||
int var3;
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package steamcraft.common.tiles.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import steamcraft.common.items.ItemCanister;
|
||||
|
||||
public class SlotFluidContainer extends Slot
|
||||
{
|
||||
public SlotFluidContainer(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_)
|
||||
{
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() instanceof ItemCanister;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package steamcraft.common.tiles.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotOutput extends Slot
|
||||
{
|
||||
public SlotOutput(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_)
|
||||
{
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue