Liquid boiler is almost functional.
parent
e646132553
commit
bca84d3433
|
@ -55,14 +55,18 @@ public class GuiLiquidBoiler extends BaseContainerGui
|
|||
this.drawTexturedModalRect(this.guiLeft + 43, (this.guiTop + 48) - burnTime, 176, 12 - burnTime, 14, burnTime + 2);
|
||||
}
|
||||
|
||||
this.drawFluid(new FluidStack(FluidRegistry.getFluid("water"), 0), this.boiler.getScaledWaterLevel(60), this.guiLeft + 8, this.guiTop + 18,
|
||||
20, 60);
|
||||
this.drawFluid(new FluidStack(FluidRegistry.getFluid("steam"), 0), this.boiler.getScaledSteamLevel(60), this.guiLeft + 74, this.guiTop + 18,
|
||||
this.drawFluid(new FluidStack(FluidRegistry.getFluid("water"), 0), this.boiler.getScaledWaterLevel(60), this.guiLeft + 8, this.guiTop + 8, 20,
|
||||
60);
|
||||
if (this.boiler.fuelTank.getFluid() != null)
|
||||
this.drawFluid(new FluidStack(this.boiler.fuelTank.getFluid().getFluid(), 0), this.boiler.getScaledFuelLevel(60), this.guiLeft + 20,
|
||||
this.guiTop + 8, 20, 60);
|
||||
this.drawFluid(new FluidStack(FluidRegistry.getFluid("steam"), 0), this.boiler.getScaledSteamLevel(60), this.guiLeft + 74, this.guiTop + 8,
|
||||
32, 60);
|
||||
|
||||
this.mc.renderEngine.bindTexture(guitexture);
|
||||
this.drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 24, 176, 14, 20, 49);
|
||||
this.drawTexturedModalRect(this.guiLeft + 74, this.guiTop + 24, 176, 14, 20, 49);
|
||||
this.drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 15, 176, 14, 20, 49);
|
||||
this.drawTexturedModalRect(this.guiLeft + 15, this.guiTop + 20, 176, 14, 20, 49);
|
||||
this.drawTexturedModalRect(this.guiLeft + 74, this.guiTop + 15, 176, 14, 20, 49);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,4 +31,5 @@ public class GuiIDs
|
|||
public static final int POCKET = 10;
|
||||
public static final int REFINERY = 11;
|
||||
public static final int CAPACITOR = 12;
|
||||
public static final int LIQUID_BOILER = 13;
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* This class was created by BrassGoggledCoders modding team.
|
||||
* This class is available as part of the Steamcraft 2 Mod for Minecraft.
|
||||
*
|
||||
* Steamcraft 2 is open-source and is distributed under the MMPL v1.0 License.
|
||||
* (http://www.mod-buildcraft.com/MMPL-1.0.txt)
|
||||
*
|
||||
* Steamcraft 2 is based on the original Steamcraft Mod created by Proloe.
|
||||
* Steamcraft (c) Proloe 2011
|
||||
* (http://www.minecraftforum.net/topic/251532-181-steamcraft-source-code-releasedmlv054wip/)
|
||||
*
|
||||
*/
|
||||
package steamcraft.common.blocks.machines;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import steamcraft.client.lib.GuiIDs;
|
||||
import steamcraft.common.Steamcraft;
|
||||
import steamcraft.common.lib.ModInfo;
|
||||
import steamcraft.common.tiles.TileLiquidBoiler;
|
||||
|
||||
/**
|
||||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public class BlockLiquidBoiler extends BlockBaseBoiler
|
||||
{
|
||||
public BlockLiquidBoiler()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister icon)
|
||||
{
|
||||
this.blockIcon = icon.registerIcon(ModInfo.PREFIX + "blockSteamBoilerSide");
|
||||
this.iconFront = icon.registerIcon(ModInfo.PREFIX + "blockSteamBoilerFrontInactive");
|
||||
this.iconFrontActive = icon.registerIcon(ModInfo.PREFIX + "blockSteamBoilerFrontActive");
|
||||
this.iconTop = icon.registerIcon(ModInfo.PREFIX + "blockSteamBoilerTop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
TileLiquidBoiler tile = (TileLiquidBoiler) world.getTileEntity(par2, par3, par4);
|
||||
|
||||
if ((tile == null) || player.isSneaking())
|
||||
return false;
|
||||
|
||||
player.openGui(Steamcraft.instance, GuiIDs.LIQUID_BOILER, world, par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
int l = world.getBlockMetadata(par2, par3, par4);
|
||||
if (l >= 7)
|
||||
{
|
||||
float f = par2 + 0.5F;
|
||||
float f1 = par3 + 0.0F + ((par5Random.nextFloat() * 6.0F) / 16.0F);
|
||||
float f2 = par4 + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = (par5Random.nextFloat() * 0.6F) - 0.3F;
|
||||
|
||||
if ((l == 4) || (l == 11))
|
||||
{
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if ((l == 5) || (l == 12))
|
||||
{
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if ((l == 2) || (l == 9))
|
||||
{
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if ((l == 3) || (l == 10))
|
||||
{
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World par1World, int metadata)
|
||||
{
|
||||
return new TileLiquidBoiler();
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@ import steamcraft.common.blocks.machines.BlockCopperWire;
|
|||
import steamcraft.common.blocks.machines.BlockDropHammerAnvil;
|
||||
import steamcraft.common.blocks.machines.BlockIntake;
|
||||
import steamcraft.common.blocks.machines.BlockLightningRod;
|
||||
import steamcraft.common.blocks.machines.BlockLiquidBoiler;
|
||||
import steamcraft.common.blocks.machines.BlockNuclearBoiler;
|
||||
import steamcraft.common.blocks.machines.BlockRefinery;
|
||||
import steamcraft.common.blocks.machines.BlockSawmill;
|
||||
|
@ -103,6 +104,7 @@ import steamcraft.common.tiles.TileBloomery;
|
|||
import steamcraft.common.tiles.TileCopperPipe;
|
||||
import steamcraft.common.tiles.TileCopperTank;
|
||||
import steamcraft.common.tiles.TileIntake;
|
||||
import steamcraft.common.tiles.TileLiquidBoiler;
|
||||
import steamcraft.common.tiles.TileNuclearBoiler;
|
||||
import steamcraft.common.tiles.TileRefinery;
|
||||
import steamcraft.common.tiles.TileSteamBoiler;
|
||||
|
@ -205,7 +207,8 @@ public class InitBlocks
|
|||
public static Block blockSteam;
|
||||
|
||||
/* Machines */
|
||||
public static Block blockSteamBoiler, blockNuclearBoiler, blockIntake, blockTurbine, blockBattery, blockCharger, blockCapacitor;
|
||||
public static Block blockSteamBoiler, blockNuclearBoiler, blockLiquidBoiler;
|
||||
public static Block blockIntake, blockTurbine, blockBattery, blockCharger, blockCapacitor;
|
||||
public static Block blockStonebrickWall, blockStoneslabWall, blockBrickWall;
|
||||
public static Block blockTeaPlant, blockHatch;
|
||||
public static Block blockTimeBomb;
|
||||
|
@ -310,11 +313,13 @@ public class InitBlocks
|
|||
{
|
||||
// Steam related
|
||||
blockSteamBoiler = new BlockSteamBoiler().setBlockName("blockSteamBoiler");
|
||||
blockNuclearBoiler = new BlockNuclearBoiler().setBlockName("blockNuclearBoiler");
|
||||
blockIntake = new BlockIntake().setBlockName("blockIntake");
|
||||
|
||||
RegistryHelper.registerContainerBlockWithDesc(blockSteamBoiler, TileSteamBoiler.class, "BlockSteamBoiler");
|
||||
blockNuclearBoiler = new BlockNuclearBoiler().setBlockName("blockNuclearBoiler");
|
||||
RegistryHelper.registerContainerBlockWithDesc(blockNuclearBoiler, TileNuclearBoiler.class, "BlockNuclearBoiler");
|
||||
blockLiquidBoiler = new BlockLiquidBoiler().setBlockName("blockLiquidBoiler");
|
||||
RegistryHelper.registerContainerBlockWithDesc(blockLiquidBoiler, TileLiquidBoiler.class, "BlockLiquidBoiler");
|
||||
|
||||
blockIntake = new BlockIntake().setBlockName("blockIntake");
|
||||
RegistryHelper.registerContainerBlockWithDesc(blockIntake, TileIntake.class, "BlockIntake");
|
||||
|
||||
// Energy related
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
|||
import boilerplate.api.IOpenableGUI;
|
||||
import steamcraft.client.gui.GuiLiquidBoiler;
|
||||
import steamcraft.common.blocks.machines.BlockBaseBoiler;
|
||||
import steamcraft.common.init.InitBlocks;
|
||||
import steamcraft.common.items.ItemCanister;
|
||||
import steamcraft.common.tiles.container.ContainerLiquidBoiler;
|
||||
|
||||
|
@ -40,6 +41,7 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
public static final int steamPerTick = 20;
|
||||
protected static final int waterPerTick = 5; // 3x3 RC boiler is 5
|
||||
// water/tick
|
||||
protected static final int fuelPerTick = 10;
|
||||
|
||||
public int furnaceBurnTime = 0;
|
||||
public int currentItemBurnTime = 0;
|
||||
|
@ -91,21 +93,39 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.inventory[1] != null)
|
||||
// Water Input
|
||||
if (this.inventory[0] != null)
|
||||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(this.inventory[1]);
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(this.inventory[0]);
|
||||
|
||||
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[0].stackSize > 1)
|
||||
this.inventory[0].stackSize--;
|
||||
else
|
||||
this.inventory[0] = this.inventory[0].getItem().getContainerItem(this.inventory[0]);
|
||||
}
|
||||
}
|
||||
// Fuel Input
|
||||
if (this.inventory[1] != null)
|
||||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(this.inventory[1]);
|
||||
|
||||
if ((liquid != null) && (this.fuelTank.fill(new FluidStack(liquid, liquid.amount), false) == liquid.amount))
|
||||
if (this.getFuelBurnTime(liquid.getFluid()) > 0)
|
||||
{
|
||||
this.fuelTank.fill(new FluidStack(liquid, 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]);
|
||||
}
|
||||
}
|
||||
// Steam Draining
|
||||
if ((this.inventory[2] != null) && (this.inventory[2].getItem() instanceof ItemCanister))
|
||||
{
|
||||
ItemCanister canister = (ItemCanister) this.inventory[2].getItem();
|
||||
|
@ -115,19 +135,17 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
this.steamTank.drain(steamPerTick, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Burn fuel
|
||||
if ((this.getItemBurnTime(inventory[0]) > 0) && (this.furnaceBurnTime == 0) && (this.waterTank.getFluidAmount() >= waterPerTick)
|
||||
&& (this.steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), steamPerTick), false) > 0))
|
||||
&& (this.steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), steamPerTick), false) > 0)
|
||||
&& (this.fuelTank.getFluidAmount() >= fuelPerTick))
|
||||
{
|
||||
this.currentItemBurnTime = this.furnaceBurnTime = this.getItemBurnTime(inventory[0]) / 4;
|
||||
|
||||
if (this.inventory[0].stackSize == 1)
|
||||
this.inventory[0] = this.inventory[0].getItem().getContainerItem(this.inventory[0]);
|
||||
else
|
||||
--this.inventory[0].stackSize;
|
||||
this.currentItemBurnTime = this.furnaceBurnTime = this.getFuelBurnTime(this.fuelTank.getFluid().getFluid()) / 4;
|
||||
this.fuelTank.drain(fuelPerTick, true);
|
||||
}
|
||||
|
||||
if ((this.furnaceBurnTime > 0) && (this.waterTank.getFluidAmount() >= waterPerTick) && (this.steamTank.getFluidAmount() < 10000))
|
||||
// Produce steam
|
||||
if ((this.furnaceBurnTime > 0) && (this.waterTank.getFluidAmount() >= waterPerTick) && (this.fuelTank.getFluidAmount() >= fuelPerTick)
|
||||
&& (this.steamTank.getFluidAmount() < this.steamTank.getCapacity()))
|
||||
{
|
||||
this.steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), steamPerTick), true);
|
||||
this.furnaceBurnTime--;
|
||||
|
@ -155,19 +173,13 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
@Override
|
||||
public boolean canInsertItem(int par1, ItemStack itemstack, int par3)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
// return ((par1 == 1) && FluidContainerRegistry.isContainer(itemstack))
|
||||
// || ((par1 == 0) && (TileEntityFurnace.getItemBurnTime(itemstack) >
|
||||
// 0));
|
||||
return ((par1 == 0 || par1 == 1) && FluidContainerRegistry.isContainer(itemstack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
// return (i == 0) || (i == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,7 +214,7 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid != FluidRegistry.WATER; // TODO
|
||||
return fluid != FluidRegistry.getFluid("steam");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -228,4 +240,15 @@ public class TileLiquidBoiler extends TileBaseBoiler implements IOpenableGUI
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getFuelBurnTime(Fluid fluid)
|
||||
{
|
||||
if (fluid == InitBlocks.whaleOilFluid)
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
private int lastBurnTime = 0;
|
||||
private int lastItemBurnTime = 0;
|
||||
private int lastSteamLevel = 0;
|
||||
private int lastFuelLevel = 0;
|
||||
private int lastWaterLevel = 0;
|
||||
|
||||
public ContainerLiquidBoiler(InventoryPlayer player, TileLiquidBoiler tileLiquidBoiler)
|
||||
|
@ -48,8 +49,7 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
this.tileent = tileLiquidBoiler;
|
||||
this.setTile(this.tileent);
|
||||
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 0, 42, 52));
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 1, 132, 57)
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 0, 116, 61)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
|
@ -57,7 +57,15 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
return FluidContainerRegistry.isContainer(stack);
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 2, 132, 21)
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 1, 135, 61)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return FluidContainerRegistry.isContainer(stack);
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(tileLiquidBoiler, 2, 154, 61)
|
||||
{
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
|
@ -83,7 +91,8 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
par1ICrafting.sendProgressBarUpdate(this, 0, this.tileent.furnaceBurnTime);
|
||||
par1ICrafting.sendProgressBarUpdate(this, 1, this.tileent.currentItemBurnTime);
|
||||
par1ICrafting.sendProgressBarUpdate(this, 2, this.tileent.steamTank.getFluidAmount());
|
||||
par1ICrafting.sendProgressBarUpdate(this, 3, this.tileent.waterTank.getFluidAmount());
|
||||
par1ICrafting.sendProgressBarUpdate(this, 3, this.tileent.fuelTank.getFluidAmount());
|
||||
par1ICrafting.sendProgressBarUpdate(this, 4, this.tileent.waterTank.getFluidAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,13 +113,17 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
if (this.lastSteamLevel != this.tileent.steamTank.getFluidAmount())
|
||||
var2.sendProgressBarUpdate(this, 2, this.tileent.steamTank.getFluidAmount());
|
||||
|
||||
if (this.lastFuelLevel != this.tileent.fuelTank.getFluidAmount())
|
||||
var2.sendProgressBarUpdate(this, 3, this.tileent.fuelTank.getFluidAmount());
|
||||
|
||||
if (this.lastWaterLevel != this.tileent.waterTank.getFluidAmount())
|
||||
var2.sendProgressBarUpdate(this, 3, this.tileent.waterTank.getFluidAmount());
|
||||
var2.sendProgressBarUpdate(this, 4, this.tileent.waterTank.getFluidAmount());
|
||||
}
|
||||
|
||||
this.lastBurnTime = this.tileent.furnaceBurnTime;
|
||||
this.lastItemBurnTime = this.tileent.currentItemBurnTime;
|
||||
this.lastSteamLevel = this.tileent.steamTank.getFluidAmount();
|
||||
this.lastFuelLevel = this.tileent.fuelTank.getFluidAmount();
|
||||
this.lastWaterLevel = this.tileent.waterTank.getFluidAmount();
|
||||
}
|
||||
|
||||
|
@ -124,7 +137,9 @@ public class ContainerLiquidBoiler extends BaseContainer
|
|||
this.tileent.currentItemBurnTime = par2;
|
||||
else if (par1 == 2)
|
||||
this.tileent.steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), par2));
|
||||
else if (par1 == 3)
|
||||
else if (par1 == 3 && this.tileent.fuelTank.getFluid() != null)
|
||||
this.tileent.fuelTank.setFluid(new FluidStack(this.tileent.fuelTank.getFluid().getFluid(), par2));
|
||||
else if (par1 == 4)
|
||||
this.tileent.waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), par2));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue