From 8d22221c5d26fe37463e1caa8acdc47e323ad677 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 31 Jan 2014 19:14:36 +0800 Subject: [PATCH] Removed electric hot plate. Added electric firebox --- .../resonantinduction/archaic/Archaic.java | 8 ++-- .../archaic/firebox/BlockFirebox.java | 12 ++++- .../archaic/firebox/BlockHotPlate.java | 7 --- .../archaic/firebox/TileFirebox.java | 48 ++++++++++++++----- .../archaic/firebox/TileHotPlate.java | 40 ++++------------ .../languages/en_US.properties | 6 +-- 6 files changed, 62 insertions(+), 59 deletions(-) diff --git a/src/main/java/resonantinduction/archaic/Archaic.java b/src/main/java/resonantinduction/archaic/Archaic.java index d057c4a4..7c171c91 100644 --- a/src/main/java/resonantinduction/archaic/Archaic.java +++ b/src/main/java/resonantinduction/archaic/Archaic.java @@ -90,8 +90,8 @@ public class Archaic blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class); blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class); blockTurntable = contentRegistry.createBlock(BlockTurntable.class); - blockFirebox = contentRegistry.createTile(BlockFirebox.class, TileFirebox.class); - blockHotPlate = contentRegistry.createBlock(BlockHotPlate.class, ItemBlockMetadata.class, TileHotPlate.class); + blockFirebox = contentRegistry.createBlock(BlockFirebox.class, ItemBlockMetadata.class, TileFirebox.class); + blockHotPlate = contentRegistry.createTile(BlockHotPlate.class, TileHotPlate.class); blockMillstone = contentRegistry.createTile(BlockMillstone.class, TileMillstone.class); blockCast = contentRegistry.createTile(BlockCast.class, TileCast.class); blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class); @@ -117,9 +117,10 @@ public class Archaic GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 0), "WWW", "WSW", "WWW", 'S', Item.stick, 'W', "logWood")); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 1), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 0), 'W', "ingotIron")); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 1), 'W', "ingotSteel")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockCrate, 1, 2), "WWW", "WSW", "WWW", 'S', new ItemStack(blockCrate, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get())); GameRegistry.addRecipe(new ShapedOreRecipe(blockFirebox, "III", "SFS", "SSS", 'I', Item.ingotIron, 'F', Block.furnaceIdle, 'S', Block.stone)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockFirebox, 1, 1), "III", "SFS", "SSS", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'F', new ItemStack(blockFirebox, 1, 0), 'S', UniversalRecipe.WIRE.get())); GameRegistry.addRecipe(new ShapedOreRecipe(blockImprinter, "SSS", "W W", "PPP", 'S', Block.stone, 'P', Block.pistonBase, 'W', "logWood")); @@ -127,7 +128,6 @@ public class Archaic GameRegistry.addRecipe(new ShapedOreRecipe(blockCast, "I I", "IBI", "III", 'S', Item.ingotIron, 'B', Block.fenceIron)); GameRegistry.addRecipe(new ShapedOreRecipe(blockHotPlate, "SSS", "III", 'I', Item.ingotIron, 'S', Block.stone)); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockHotPlate, 1, 1), "HHH", "WWW", 'H', new ItemStack(blockHotPlate, 1, 0), 'W', UniversalRecipe.WIRE.get())); GameRegistry.addRecipe(new ShapedOreRecipe(itemImprint, "PPP", "PIP", "PPP", 'P', Item.paper, 'I', new ItemStack(Item.dyePowder, 0))); GameRegistry.addRecipe(new ShapedOreRecipe(itemHammer, "CC ", "CS ", " S", 'C', Block.cobblestone, 'S', Item.stick)); diff --git a/src/main/java/resonantinduction/archaic/firebox/BlockFirebox.java b/src/main/java/resonantinduction/archaic/firebox/BlockFirebox.java index 9c56fe93..06dd8510 100644 --- a/src/main/java/resonantinduction/archaic/firebox/BlockFirebox.java +++ b/src/main/java/resonantinduction/archaic/firebox/BlockFirebox.java @@ -1,11 +1,14 @@ package resonantinduction.archaic.firebox; +import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; @@ -123,7 +126,7 @@ public class BlockFirebox extends BlockRI int blockIDAbove = world.getBlockId(x, y + 1, z); - if (blockIDAbove == Block.waterStill.blockID ) + if (blockIDAbove == Block.waterStill.blockID) { for (int i = 0; i < 4; i++) world.spawnParticle("bubble", xDisplace + (par5Random.nextFloat() - 0.5), yDisplace + 1.5, zDisplace + (par5Random.nextFloat() - 0.5), 0.0D, 0.05D, 0.0D); @@ -144,6 +147,13 @@ public class BlockFirebox extends BlockRI return 0; } + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 0)); + par3List.add(new ItemStack(par1, 1, 1)); + } + @Override public TileEntity createNewTileEntity(World world) { diff --git a/src/main/java/resonantinduction/archaic/firebox/BlockHotPlate.java b/src/main/java/resonantinduction/archaic/firebox/BlockHotPlate.java index 91aaf55b..332b2327 100644 --- a/src/main/java/resonantinduction/archaic/firebox/BlockHotPlate.java +++ b/src/main/java/resonantinduction/archaic/firebox/BlockHotPlate.java @@ -163,13 +163,6 @@ public class BlockHotPlate extends BlockRI } } - @Override - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) - { - par3List.add(new ItemStack(par1, 1, 0)); - par3List.add(new ItemStack(par1, 1, 1)); - } - @Override public TileEntity createNewTileEntity(World world) { diff --git a/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java b/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java index 62e97020..f33353b0 100644 --- a/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java +++ b/src/main/java/resonantinduction/archaic/firebox/TileFirebox.java @@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -16,10 +17,11 @@ import net.minecraftforge.fluids.FluidStack; import resonantinduction.core.ResonantInduction; import resonantinduction.core.resource.ResourceGenerator; import resonantinduction.core.resource.TileMaterial; +import universalelectricity.api.energy.EnergyStorageHandler; import universalelectricity.api.vector.Vector3; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketSender; -import calclavia.lib.prefab.tile.TileExternalInventory; +import calclavia.lib.prefab.tile.TileElectricalInventory; import calclavia.lib.thermal.BoilEvent; import com.google.common.io.ByteArrayDataInput; @@ -30,7 +32,7 @@ import com.google.common.io.ByteArrayDataInput; * @author Calclavia * */ -public class TileFirebox extends TileExternalInventory implements IPacketSender, IPacketReceiver +public class TileFirebox extends TileElectricalInventory implements IPacketSender, IPacketReceiver { /** * One coal = 4MJ, one coal lasts 80 seconds. Therefore, we are producing 50000 watts. @@ -52,11 +54,32 @@ public class TileFirebox extends TileExternalInventory implements IPacketSender, private final long requiredMeltIronEnergy = 4781700 + 1904000; private long heatEnergy = 0; + public TileFirebox() + { + energy = new EnergyStorageHandler(POWER * 4, POWER * 2); + setIO(ForgeDirection.UP, 0); + } + @Override public void updateEntity() { if (!worldObj.isRemote) { + if (energy.checkExtract()) + { + energy.extractEnergy(); + burnTime += 2; + } + else if (canBurn(this.getStackInSlot(0))) + { + if (burnTime == 0) + { + burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0)); + decrStackSize(0, 1); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + int blockID = worldObj.getBlockId(xCoord, yCoord + 1, zCoord); if (burnTime > 0) @@ -124,19 +147,20 @@ public class TileFirebox extends TileExternalInventory implements IPacketSender, worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } - - if (canBurn(this.getStackInSlot(0))) - { - if (burnTime == 0) - { - burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0)); - decrStackSize(0, 1); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - } - } } } + @Override + public boolean canConnect(ForgeDirection direction) + { + return isElectrical() && super.canConnect(direction); + } + + public boolean isElectrical() + { + return this.getBlockMetadata() == 1; + } + public boolean canBurn(ItemStack stack) { return TileEntityFurnace.getItemBurnTime(stack) > 0; diff --git a/src/main/java/resonantinduction/archaic/firebox/TileHotPlate.java b/src/main/java/resonantinduction/archaic/firebox/TileHotPlate.java index c6c64f60..7b126f83 100644 --- a/src/main/java/resonantinduction/archaic/firebox/TileHotPlate.java +++ b/src/main/java/resonantinduction/archaic/firebox/TileHotPlate.java @@ -15,7 +15,7 @@ import universalelectricity.api.energy.EnergyStorageHandler; import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketSender; import calclavia.lib.network.PacketHandler; -import calclavia.lib.prefab.tile.TileElectricalInventory; +import calclavia.lib.prefab.tile.TileExternalInventory; import com.google.common.io.ByteArrayDataInput; @@ -25,7 +25,7 @@ import com.google.common.io.ByteArrayDataInput; * @author Calclavia * */ -public class TileHotPlate extends TileElectricalInventory implements IPacketSender, IPacketReceiver +public class TileHotPlate extends TileExternalInventory implements IPacketSender, IPacketReceiver { private final int POWER = 50000; public final int[] smeltTime = new int[] { 0, 0, 0, 0 }; @@ -35,8 +35,6 @@ public class TileHotPlate extends TileElectricalInventory implements IPacketSend public TileHotPlate() { maxSlots = 4; - energy = new EnergyStorageHandler(POWER * 2, POWER); - setIO(ForgeDirection.UP, 0); } @Override @@ -83,11 +81,6 @@ public class TileHotPlate extends TileElectricalInventory implements IPacketSend smeltTime[i] = 0; } } - - if (didSmelt) - { - energy.extractEnergy(); - } } } @@ -125,39 +118,22 @@ public class TileHotPlate extends TileElectricalInventory implements IPacketSend } } - public boolean isElectrical() - { - return this.getBlockMetadata() == 1; - } - public boolean canRun() { - if (isElectrical()) - { - return energy.checkExtract(); - } - else - { - TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); - if (tileEntity instanceof TileFirebox) + TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); + + if (tileEntity instanceof TileFirebox) + { + if (((TileFirebox) tileEntity).isBurning()) { - if (((TileFirebox) tileEntity).isBurning()) - { - return true; - } + return true; } } return false; } - @Override - public boolean canConnect(ForgeDirection direction) - { - return isElectrical() && super.canConnect(direction); - } - public boolean canSmelt(ItemStack stack) { return FurnaceRecipes.smelting().getSmeltingResult(stack) != null; diff --git a/src/main/resources/assets/resonantinduction/languages/en_US.properties b/src/main/resources/assets/resonantinduction/languages/en_US.properties index 60f396a6..a6a9e942 100644 --- a/src/main/resources/assets/resonantinduction/languages/en_US.properties +++ b/src/main/resources/assets/resonantinduction/languages/en_US.properties @@ -43,9 +43,9 @@ tile.resonantinduction\:millstone.name=Millstone tile.resonantinduction\:millstone.tooltip=Put some rubble in the millstone and start wrenching to grind rubble into dust. tile.resonantinduction\:imprinter.name=Imprinter tile.resonantinduction\:engineeringTable.name=Engineering Table -tile.resonantinduction\:firebox.name=Firebox -tile.resonantinduction\:hotPlate.0.name=Hot Plate -tile.resonantinduction\:hotPlate.1.name=Electric Hot Plate +tile.resonantinduction\:firebox.0.name=Firebox +tile.resonantinduction\:firebox.1.name=Electric Firebox +tile.resonantinduction\:hotPlate.name=Hot Plate ## Transport tile.resonantinduction\:turntable.name=Turntable