From cb2188580e9fae1f8d04e046271b061590eca77d Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Mon, 14 Jul 2014 20:39:34 +0100 Subject: [PATCH 1/5] More Laser and Reactor work. Lasers work now, and Heat Generators generate energy from incident lasers, in order to test lasers. This is probably only temporary. --- .../mekanism/api/lasers/LaserManager.java | 3 +- .../mekanism/common/block/BlockMachine.java | 17 ++++- .../mekanism/common/tile/TileEntityLaser.java | 5 ++ .../common/GeneratorsCommonProxy.java | 20 ++++++ .../generators/common/MekanismGenerators.java | 5 +- .../generators/common/block/BlockReactor.java | 68 ++++++++++++++++++ .../common/item/ItemBlockReactor.java | 61 ++++++++++++++++ .../common/tile/TileEntityHeatGenerator.java | 21 +++++- .../tile/reactor/TileEntityReactorPort.java | 9 ++- .../textures/blocks/ReactorControllerOff.png | Bin 0 -> 1378 bytes .../textures/blocks/ReactorControllerOn.png | Bin 0 -> 1456 bytes .../mekanism/textures/blocks/ReactorFrame.png | Bin 0 -> 1203 bytes .../mekanism/textures/blocks/ReactorGlass.png | Bin 0 -> 1230 bytes .../textures/blocks/ReactorLaserFocus.png | Bin 0 -> 1601 bytes .../mekanism/textures/blocks/ReactorPort.png | Bin 0 -> 1283 bytes 15 files changed, 202 insertions(+), 7 deletions(-) create mode 100644 src/main/java/mekanism/generators/common/item/ItemBlockReactor.java create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOn.png create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorGlass.png create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorLaserFocus.png create mode 100644 src/main/resources/assets/mekanism/textures/blocks/ReactorPort.png diff --git a/src/main/java/mekanism/api/lasers/LaserManager.java b/src/main/java/mekanism/api/lasers/LaserManager.java index e61db4776..1bfd1d134 100644 --- a/src/main/java/mekanism/api/lasers/LaserManager.java +++ b/src/main/java/mekanism/api/lasers/LaserManager.java @@ -15,8 +15,9 @@ public class LaserManager public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world) { + Coord4D rangeFrom = from.getFromSide(direction, 1); Coord4D to = from.getFromSide(direction, range); - MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xCoord, from.yCoord, from.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); + MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(rangeFrom.xCoord, rangeFrom.yCoord, rangeFrom.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord)); if(mop != null) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 550d18e3a..36091f6b8 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -191,7 +191,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer icons[5][2] = register.registerIcon("mekanism:SteelCasing"); icons[9][0] = register.registerIcon("mekanism:SteelBlock"); icons[9][1] = register.registerIcon("mekanism:SeismicVibrator"); - icons[13][0] = register.registerIcon("Mekanism:Laser"); + icons[13][0] = register.registerIcon("Mekanism:SteelCasing"); + icons[13][1] = register.registerIcon("Mekanism:Laser"); } } @@ -467,6 +468,16 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return icons[meta][0]; } } + else if(meta == 13) + { + if(side == 3) + { + return icons[meta][0]; + } + else { + return icons[meta][1]; + } + } } return null; @@ -600,7 +611,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return icons[metadata][2]; } } - else if(metadata == 9) + else if(metadata == 9 || metadata == 13) { if(side == tileEntity.facing) { @@ -834,7 +845,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer } @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index ca209fed6..e4981dca2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import mekanism.api.Coord4D; import mekanism.api.lasers.LaserManager; +import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityLaser extends TileEntityElectricBlock @@ -12,14 +13,18 @@ public class TileEntityLaser extends TileEntityElectricBlock public TileEntityLaser() { super("Laser", 100000); + inventory = new ItemStack[0]; } @Override public void onUpdate() { + super.onUpdate(); + if(getEnergy() >= LASER_ENERGY) { LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj); + setEnergy(getEnergy()-LASER_ENERGY); } } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index cb833cfb9..26c63f7c9 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -12,6 +12,13 @@ import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.TileEntityWindTurbine; +import mekanism.generators.common.tile.reactor.TileEntityReactorController; +import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; +import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; +import mekanism.generators.common.tile.reactor.TileEntityReactorLaserFocusMatrix; +import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture; +import mekanism.generators.common.tile.reactor.TileEntityReactorPort; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; @@ -25,6 +32,19 @@ import cpw.mods.fml.common.registry.GameRegistry; */ public class GeneratorsCommonProxy { + /** + * Register normal tile entities + */ + public void registerRegularTileEntities() + { + GameRegistry.registerTileEntity(TileEntityReactorController.class, "ReactorController"); + GameRegistry.registerTileEntity(TileEntityReactorFrame.class, "ReactorFrame"); + GameRegistry.registerTileEntity(TileEntityReactorGlass.class, "ReactorGlass"); + GameRegistry.registerTileEntity(TileEntityReactorLaserFocusMatrix.class, "ReactorLaserFocus"); + GameRegistry.registerTileEntity(TileEntityReactorNeutronCapture.class, "ReactorNeutronCapture"); + GameRegistry.registerTileEntity(TileEntityReactorPort.class, "ReactorPort"); + } + /** * Register tile entities that have special models. Overwritten in client to register TESRs. */ diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index 4df497504..496f9ca7b 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -15,6 +15,8 @@ import mekanism.common.recipe.MekanismRecipe; import mekanism.generators.common.block.BlockGenerator; import mekanism.generators.common.block.BlockReactor; import mekanism.generators.common.item.ItemBlockGenerator; +import mekanism.generators.common.item.ItemBlockReactor; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -96,6 +98,7 @@ public class MekanismGenerators implements IModule //Load the proxy proxy.loadConfiguration(); + proxy.registerRegularTileEntities(); proxy.registerSpecialTileEntities(); proxy.registerRenderInformation(); @@ -143,7 +146,7 @@ public class MekanismGenerators implements IModule Reactor = new BlockReactor().setBlockName("Reactor"); GameRegistry.registerBlock(Generator, ItemBlockGenerator.class, "Generator"); - GameRegistry.registerBlock(Reactor, "Reactor"); + GameRegistry.registerBlock(Reactor, ItemBlockReactor.class, "Reactor"); } public void addItems() diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index ddd522711..71b486c7f 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -16,6 +16,7 @@ import mekanism.common.util.MekanismUtils; import mekanism.generators.client.GeneratorsClientProxy; import mekanism.generators.common.MekanismGenerators; import mekanism.generators.common.tile.TileEntitySolarGenerator; +import mekanism.generators.common.tile.reactor.TileEntityReactorBlock; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import mekanism.generators.common.tile.reactor.TileEntityReactorFrame; import mekanism.generators.common.tile.reactor.TileEntityReactorGlass; @@ -34,6 +35,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; @@ -47,6 +49,8 @@ import buildcraft.api.tools.IToolWrench; public class BlockReactor extends BlockContainer { + public IIcon[][] icons = new IIcon[16][16]; + public BlockReactor() { super(Material.iron); @@ -55,6 +59,70 @@ public class BlockReactor extends BlockContainer setCreativeTab(Mekanism.tabMekanism); } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + if(this == MekanismGenerators.Reactor) + { + icons[0][0] = register.registerIcon("mekanism:ReactorControllerOff"); + icons[0][1] = register.registerIcon("mekanism:ReactorControllerOn"); + icons[0][2] = register.registerIcon("mekanism:ReactorFrame"); + icons[1][0] = register.registerIcon("mekanism:ReactorFrame"); + icons[2][0] = register.registerIcon("mekanism:ReactorGlass"); + icons[3][0] = register.registerIcon("mekanism:ReactorLaserFocus"); + icons[4][0] = register.registerIcon("mekanism:ReactorNeutronCapture"); + icons[5][0] = register.registerIcon("mekanism:ReactorPort"); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + if(this == MekanismGenerators.Reactor) + { + if(meta == 0) + { + return icons[0][side == 6 ? 0 : 2]; + } + else + { + return icons[meta][0]; + } + } + + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + TileEntityReactorBlock tileEntity = (TileEntityReactorBlock)world.getTileEntity(x, y, z); + + if(this == MekanismGenerators.Reactor) + { + if(metadata == 0) + { + if(side == 1) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; + } + else { + return icons[0][2]; + } + } + else + { + return icons[metadata][0]; + } + } + + return null; + } + @Override public int damageDropped(int i) { diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java new file mode 100644 index 000000000..af0fd857e --- /dev/null +++ b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java @@ -0,0 +1,61 @@ +package mekanism.generators.common.item; + +import java.util.List; + +import mekanism.api.EnumColor; +import mekanism.common.util.MekanismUtils; +import mekanism.generators.common.block.BlockReactor.ReactorBlockType; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.input.Keyboard; + +public class ItemBlockReactor extends ItemBlock +{ + public Block metaBlock; + + public ItemBlockReactor(Block block) + { + super(block); + metaBlock = block; + setHasSubtypes(true); + } + + @Override + public int getMetadata(int i) + { + return i; + } + + @Override + public IIcon getIconFromDamage(int i) + { + return metaBlock.getIcon(2, i); + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) + { + return getUnlocalizedName() + "." + ReactorBlockType.getFromMetadata(itemstack.getItemDamage()).name; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + ReactorBlockType type = ReactorBlockType.getFromMetadata(itemstack.getItemDamage()); + + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + list.add(MekanismUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.forDetails") + "."); + } + else { + list.addAll(MekanismUtils.splitLines(type.getDescription())); + } + } +} diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 92af05136..174e653f2 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import mekanism.api.lasers.ILaserReceptor; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.FluidContainerUtils; @@ -27,7 +28,7 @@ import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler +public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ILaserReceptor { /** The FluidTank for this generator. */ public FluidTank lavaTank = new FluidTank(24000); @@ -335,4 +336,22 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return new FluidTankInfo[] {lavaTank.getInfo()}; } + + @Override + public void receiveLaserEnergy(double energy, ForgeDirection side) + { + setEnergy(getEnergy()+energy); + } + + @Override + public boolean canLasersDig() + { + return false; + } + + @Override + public double energyToDig() + { + return 0; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index cc6d3ed32..1c1e4226e 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -4,6 +4,7 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.IGasHandler; +import mekanism.api.gas.ITubeConnection; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -12,7 +13,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandler, IGasHandler +public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandler, IGasHandler, ITubeConnection { @Override public boolean isFrame() @@ -118,4 +119,10 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { return (type == GasRegistry.getGas("steam")); } + + @Override + public boolean canTubeConnect(ForgeDirection side) + { + return true; + } } \ No newline at end of file diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorControllerOff.png new file mode 100644 index 0000000000000000000000000000000000000000..e2f20767eb9bedae0e4123acf044640108d33fe1 GIT binary patch literal 1378 zcmV-o1)chdP)4Tx0C?Jsl+SMzWf;dlyYtSh2{;E+0gJ(jKY)-zwqTG3L3g{$wouDv+hW_8 znCoMPiX1$ccrw9X5iY<%0|`MxY)DKvl=ve=5-x_+!%TMv zXvO#R%=3Pq@AvyW?~{Sd=T+Z#(-zEnp{kVf*7(GvmAOHhXIMiwYpQnO=gQ?FfU57i zJaX>+ObX!I_LcAd^Q@`Kz=qTlK(iLuvyeIlx@-F?1mhO4=V<7Mka-s9QsWbokjVmF z^(Za?T~kp!4s@x}No`@q40Cbh4CzWGcl~Ud+tLC)h%7op= zT>sBA>$aBlHUVpcnUO=lR!ALdsDVlxe_~gQBfyK0y6lJf3a}Ycf3#-Ca={irt|ajcdi^v~yrE#?Sk1c_{KG&Z<^rEXG`|s$wbP5r0c> zEaucV)T)I;zz)#&b0k$o(qsyWjmLc~DwN1$;iG6Wje|=GiHAhtq@H93XB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c> zEaucV)T)I;zz)#&b0k$o(qsyWjmLc~DwN1$;iG6Wje|=GiHAhtq@H93XBAu-iHhS6 zqK?F45ru=j3MNvx9b=key~v7PA}jWaA+b;F5q((VHSxOGFA5?n`o!LLZ8@QDQRjA> z=UrMzEGir!f4aN1wWD`Zz3tdnPThH+y7`D_x$Gx70Rm>)$nDAgFU^0qp~G=qoO|oq z+Dr2se%yTZTl%7YUB9K@&=)!g{a1ZKU(j!m!^NeJWEP2oha^ZiNcM06myjwhzv0nL z;2uz%_D*+qZtN?k?#TCs?+tUZr<2Y8lKnG#J^N|)Z1(quro7^mw2!o}wC}aAwQsZ^ zv9$Br1?>mzqV}csZQ`v~-;eg&lS_0f@m8F*#5MEgM)L);U_NKQWDa%s%=KokIbd!v z3+Bf5yCwCKy*NzZwx_zXR)ibF!{I0rML-o7kK+&Re_Sm#iC!`I(AMq|dqvx&Q8Wrh z4$IhP^clUzK_l1kXKXPFMxU|8C_b=t_9`971S;9*cBYU7%%E_XL*f!3LwPI&=x_SR zl~Zqo*3NA96)WfauCxX{dqXiclZbbzFn`}Q?OYsuvsp~Pr*6% z$IrnZe|>w$PxTc?gf8Gg3Alj&i!z+~IO5{ej79z~$bk{($-e>JO+tpwm$O0o8!|1L_Z`KcN1A`U59y<;W2Nd_W!m0000< KMNUMnLSTY}htF#O literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png b/src/main/resources/assets/mekanism/textures/blocks/ReactorFrame.png new file mode 100644 index 0000000000000000000000000000000000000000..dd31e613d0964452ba61fad026b6f4ad3b18ea0b GIT binary patch literal 1203 zcmV;k1WfyhP)4Tx0C?Jsl+SMzWf;dlyYtSh2{;E+0gJ(jKY)-zwqTG3L3g{$wouDv+hW_8 znCoMPiX1$ccrw9X5iY<%0|`MxY)DKvl=ve=5-x_+!%TMv zXvO#R%=3Pq@AvyW?~{Sd=T+Z#(-zEnp{kVf*7(GvmAOHhXIMiwYpQnO=gQ?FfU57i zJaX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fauCxX{dqcZJZLw?;SXg7R|Cb};LuSN>_x>d!SQXP+TXwjJ;EBZ{fB*sr zSPn2}H>fJCwO`kB&T|1{45%ucbBDE3%KRGufZjV&O1oN&kxh7$DcBN1IP}He0JYYS twO`|T8Q|(K9Gj2;0tg_$%y?eU Date: Tue, 15 Jul 2014 00:13:20 +0100 Subject: [PATCH 2/5] More work on Fusion Reactor --- .../mekanism/api/reactor/IFusionReactor.java | 4 +- .../java/mekanism/client/ClientProxy.java | 4 + .../client/render/MekanismRenderer.java | 9 +- .../java/mekanism/common/CommonProxy.java | 2 + src/main/java/mekanism/common/Mekanism.java | 6 + .../mekanism/common/block/BlockMachine.java | 9 +- .../generators/common/FusionReactor.java | 153 +++++++++++++++++- .../generators/common/block/BlockReactor.java | 11 ++ .../reactor/TileEntityReactorController.java | 22 +++ .../TileEntityReactorLaserFocusMatrix.java | 5 +- 10 files changed, 209 insertions(+), 16 deletions(-) diff --git a/src/main/java/mekanism/api/reactor/IFusionReactor.java b/src/main/java/mekanism/api/reactor/IFusionReactor.java index 6172c6075..16d8125a3 100644 --- a/src/main/java/mekanism/api/reactor/IFusionReactor.java +++ b/src/main/java/mekanism/api/reactor/IFusionReactor.java @@ -6,7 +6,7 @@ import net.minecraftforge.fluids.FluidTank; public interface IFusionReactor { - public void addTemperature(double energyAdded); + public void addTemperatureFromEnergyInput(double energyAdded); public void simulate(); @@ -19,4 +19,6 @@ public interface IFusionReactor public GasTank getTritiumTank(); public GasTank getFuelTank(); + + public void formMultiblock(); } diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index c80848efa..987c4f0d3 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -120,6 +120,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber; import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.tile.TileEntityGasTank; +import mekanism.common.tile.TileEntityLaser; import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityMetallurgicInfuser; import mekanism.common.tile.TileEntityObsidianTNT; @@ -147,6 +148,7 @@ import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -303,6 +305,8 @@ public class ClientProxy extends CommonProxy ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderPressurizedReactionChamber()); ClientRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank", new RenderPortableTank()); ClientRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher", new RenderFluidicPlenisher()); + //TODO needs a model, I think. + GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser"); } @Override diff --git a/src/main/java/mekanism/client/render/MekanismRenderer.java b/src/main/java/mekanism/client/render/MekanismRenderer.java index e02bd410b..c82a99d1b 100644 --- a/src/main/java/mekanism/client/render/MekanismRenderer.java +++ b/src/main/java/mekanism/client/render/MekanismRenderer.java @@ -74,7 +74,7 @@ public class MekanismRenderer GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen")); GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen")); GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:WaterVapor")); - GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:Chlorine")); + GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:LiquidChlorine")); GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurDioxide")); GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide")); GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid")); @@ -84,7 +84,12 @@ public class MekanismRenderer GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:Ethene")); GasRegistry.getGas("brine").setIcon(event.map.registerIcon("mekanism:LiquidBrine")); GasRegistry.getGas("sodium").setIcon(event.map.registerIcon("mekanism:LiquidSodium")); - + GasRegistry.getGas("deuterium").setIcon(event.map.registerIcon("mekanism:LiquidDeuterium")); + GasRegistry.getGas("tritium").setIcon(event.map.registerIcon("mekanism:LiquidTritium")); + GasRegistry.getGas("fusionFuelDD").setIcon(event.map.registerIcon("mekanism:LiquidDD")); + GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:liquidDT")); + GasRegistry.getGas("steam").setIcon(event.map.registerIcon("mekanism:LiquidSteam")); + for(Gas gas : GasRegistry.getRegisteredGasses()) { if(gas instanceof OreGas) diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index d740ce3ac..731062624 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -64,6 +64,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber; import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.tile.TileEntityGasTank; +import mekanism.common.tile.TileEntityLaser; import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityMetallurgicInfuser; import mekanism.common.tile.TileEntityObsidianTNT; @@ -136,6 +137,7 @@ public class CommonProxy GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber"); GameRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank"); GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher"); + GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser"); } /** diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 958dd3bd3..52232833b 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -105,6 +105,7 @@ import mekanism.common.tile.TileEntityBoundingBlock; import mekanism.common.tile.TileEntityCardboardBox; import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityEnergizedSmelter; +import mekanism.common.tile.TileEntityLaser; import mekanism.common.tile.TileEntitySalinationTank; import mekanism.common.tile.TileEntitySalinationValve; import mekanism.common.transporter.TransporterManager; @@ -1335,6 +1336,11 @@ public class Mekanism GasRegistry.register(new Gas("ethene").registerFluid()); GasRegistry.register(new Gas("sodium").registerFluid()); GasRegistry.register(new Gas("brine").registerFluid()); + GasRegistry.register(new Gas("deuterium")).registerFluid(); + GasRegistry.register(new Gas("tritium")).registerFluid(); + GasRegistry.register(new Gas("fusionFuelDD")).registerFluid(); + GasRegistry.register(new Gas("fusionFuelDT")).registerFluid(); + GasRegistry.register(new Gas("steam")).registerFluid(); for(Resource resource : Resource.values()) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 36091f6b8..b18ae4fc5 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -180,19 +180,14 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer } else if(this == Mekanism.MachineBlock2) { - icons[2][0] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOff"); - icons[2][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn"); - icons[2][2] = register.registerIcon("mekanism:SteelCasing"); icons[3][0] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOff"); icons[3][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn"); icons[3][2] = register.registerIcon("mekanism:SteelCasing"); icons[5][0] = register.registerIcon("mekanism:PrecisionSawmillFrontOff"); icons[5][1] = register.registerIcon("mekanism:PrecisionSawmillFrontOn"); icons[5][2] = register.registerIcon("mekanism:SteelCasing"); - icons[9][0] = register.registerIcon("mekanism:SteelBlock"); - icons[9][1] = register.registerIcon("mekanism:SeismicVibrator"); - icons[13][0] = register.registerIcon("Mekanism:SteelCasing"); - icons[13][1] = register.registerIcon("Mekanism:Laser"); + icons[13][0] = register.registerIcon("mekanism:SteelCasing"); + icons[13][1] = register.registerIcon("mekanism:Laser"); } } diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 7af256891..860b9adda 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -6,17 +6,25 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import mekanism.api.Coord4D; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; +import mekanism.api.lasers.ILaserReceptor; import mekanism.api.reactor.IFusionReactor; import mekanism.api.reactor.INeutronCapture; import mekanism.api.reactor.IReactorBlock; +import mekanism.common.Mekanism; import mekanism.generators.common.tile.reactor.TileEntityReactorController; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidTank; +import static java.lang.Math.exp; import static java.lang.Math.min; import static java.lang.Math.max; @@ -43,9 +51,9 @@ public class FusionReactor implements IFusionReactor public static double burnRatio = 1; public static double tempPerFuel = 5*10^6; - public int injectionRate; + public int injectionRate = 0; - public static double coolingCoefficient = 0.2; + public static double coolingCoefficient = 0.1; public static double waterRatio = 10^-14; public static double inverseHeatCapacity = 1; @@ -53,8 +61,15 @@ public class FusionReactor implements IFusionReactor public boolean burning = false; public boolean hasHohlraum = false; + public boolean formed = false; + + public FusionReactor(TileEntityReactorController c) + { + controller = c; + } + @Override - public void addTemperature(double energyAdded) + public void addTemperatureFromEnergyInput(double energyAdded) { temperature += energyAdded * inverseHeatCapacity; } @@ -78,6 +93,8 @@ public class FusionReactor implements IFusionReactor } boilWater(); ambientLoss(); + if(temperature > 0) + Mekanism.logger.info("Reactor temperature: " + (int)temperature); } public void vaporiseHohlraum() @@ -128,6 +145,10 @@ public class FusionReactor implements IFusionReactor public void ambientLoss() { temperature -= coolingCoefficient*temperature; + if(temperature < 1E-6) + { + temperature = 0; + } } @Override @@ -159,4 +180,130 @@ public class FusionReactor implements IFusionReactor { return fuelTank; } + + public void formMultiblock() + { + Coord4D controllerPosition = Coord4D.get(controller); + Coord4D centreOfReactor = controllerPosition.getFromSide(ForgeDirection.DOWN, 2); + + Mekanism.logger.info("Centre at " + centreOfReactor.toString()); + if(!createFrame(centreOfReactor)) + { + for(IReactorBlock block: reactorBlocks) + { + block.setReactor(null); + } + reactorBlocks.clear(); + return; + } + Mekanism.logger.info("Frame valid"); + if(!addSides(centreOfReactor)) + { + for(IReactorBlock block: reactorBlocks) + { + block.setReactor(null); + } + reactorBlocks.clear(); + neutronCaptors.clear(); + return; + } + Mekanism.logger.info("Side Blocks Valid"); + if(!centreIsClear(centreOfReactor)) + { + for(IReactorBlock block: reactorBlocks) + { + block.setReactor(null); + } + reactorBlocks.clear(); + neutronCaptors.clear(); + return; + } + Mekanism.logger.info("Centre is clear"); + formed = true; + } + + public boolean createFrame(Coord4D centre) + { + int[][] positions = new int[][] { + {+2, +2, +0}, {+2, +1, +1}, {+2, +0, +2}, {+2, -1, +1}, {+2, -2, +0}, {+2, -1, -1}, {+2, +0, -2}, {+2, +1, -1}, + {+1, +2, +1}, {+1, +1, +2}, {+1, -1, +2}, {+1, -2, +1}, {+1, -2, -1}, {+1, -1, -2}, {+1, +1, -2}, {+1, +2, -1}, + {+0, +2, +2}, {+0, -2, +2}, {+0, -2, -2}, {+0, +2, -2}, + {-1, +2, +1}, {-1, +1, +2}, {-1, -1, +2}, {-1, -2, +1}, {-1, -2, -1}, {-1, -1, -2}, {-1, +1, -2}, {-1, +2, -1}, + {-2, +2, +0}, {-2, +1, +1}, {-2, +0, +2}, {-2, -1, +1}, {-2, -2, +0}, {-2, -1, -1}, {-2, +0, -2}, {-2, +1, -1}, + }; + + for(int[] coords : positions) + { + TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorldObj()); + + if(tile instanceof IReactorBlock && ((IReactorBlock)tile).isFrame()) + { + reactorBlocks.add((IReactorBlock)tile); + ((IReactorBlock)tile).setReactor(this); + } + else { + return false; + } + } + + return true; + } + + public boolean addSides(Coord4D centre) + { + int[][] positions = new int[][] { + {+2, +0, +0}, {+2, +1, +0}, {+2, +0, +1}, {+2, -1, +0}, {+2, +0, -1}, //EAST + {-2, +0, +0}, {-2, +1, +0}, {-2, +0, +1}, {-2, -1, +0}, {-2, +0, -1}, //WEST + {+0, +2, +0}, {+1, +2, +0}, {+0, +2, +1}, {-1, +2, +0}, {+0, +2, -1}, //TOP + {+0, -2, +0}, {+1, -2, +0}, {+0, -2, +1}, {-1, -2, +0}, {+0, -2, -1}, //BOTTOM + {+0, +0, +2}, {+1, +0, +2}, {+0, +1, +2}, {-1, +0, +2}, {+0, -1, +2}, //SOUTH + {+0, +0, +2}, {+1, +0, +2}, {+0, +1, +2}, {-1, +0, +2}, {+0, -1, +2}, //NORTH + }; + + for(int[] coords : positions) + { + TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorldObj()); + + if(tile instanceof ILaserReceptor && !(coords[1] == 0 && (coords[0] == 0 || coords[2] == 0))) + { + return false; + } + + if(tile instanceof IReactorBlock) + { + reactorBlocks.add((IReactorBlock)tile); + ((IReactorBlock)tile).setReactor(this); + if(tile instanceof INeutronCapture) + { + neutronCaptors.add((INeutronCapture)tile); + } + } + else { + return false; + } + } + + return true; + } + + public boolean centreIsClear(Coord4D centre) + { + for(int x = -1; x <= 1; x++) + { + for(int y = -1; x <= 1; x++) + { + for(int z = -1; x <= 1; x++) + { + Block tile = centre.clone().translate(x, y, z).getBlock(controller.getWorldObj()); + + if(!tile.isAir(controller.getWorldObj(), x, y, z)) + { + return false; + } + } + } + } + + return true; + } } diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 71b486c7f..c8c768f65 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -129,6 +129,17 @@ public class BlockReactor extends BlockContainer return i; } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) + { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityReactorController) + { + ((TileEntityReactorController)tile).formMultiblock(); + } + return true; + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item i, CreativeTabs creativetabs, List list) diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index 32a98236a..c2419188a 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -1,5 +1,8 @@ package mekanism.generators.common.tile.reactor; +import mekanism.common.Mekanism; +import mekanism.generators.common.FusionReactor; + public class TileEntityReactorController extends TileEntityReactorBlock { @Override @@ -11,4 +14,23 @@ public class TileEntityReactorController extends TileEntityReactorBlock public void radiateNeutrons(int neutrons) { } + + public void formMultiblock() + { + if(getReactor() == null) + { + setReactor(new FusionReactor(this)); + } + Mekanism.logger.info("Attempting to form multiblock"); + getReactor().formMultiblock(); + } + + @Override + public void updateEntity() + { + if(getReactor() != null && !worldObj.isRemote) + { + getReactor().simulate(); + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java index 61404a41c..8fd162d35 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java @@ -7,8 +7,6 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock implements ILaserReceptor { - public IFusionReactor fusionReactor; - @Override public boolean isFrame() { @@ -18,7 +16,8 @@ public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock im @Override public void receiveLaserEnergy(double energy, ForgeDirection side) { - fusionReactor.addTemperature(energy); + if(getReactor() != null) + getReactor().addTemperatureFromEnergyInput(energy); } @Override From 445cb7a0a4e15dc59a50f4055846ec250ddd4a1b Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Tue, 15 Jul 2014 01:48:45 +0100 Subject: [PATCH 3/5] You are not using Wolfram|Alpha now, @unpairedbracket. --- src/main/java/mekanism/generators/common/FusionReactor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 860b9adda..3b5db9456 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -47,15 +47,15 @@ public class FusionReactor implements IFusionReactor public Set neutronCaptors = new HashSet(); public double temperature; - public static double burnTemperature = 10^8; + public static double burnTemperature = 1E8; public static double burnRatio = 1; - public static double tempPerFuel = 5*10^6; + public static double tempPerFuel = 5E6; public int injectionRate = 0; public static double coolingCoefficient = 0.1; - public static double waterRatio = 10^-14; + public static double waterRatio = 1E-14; public static double inverseHeatCapacity = 1; public boolean burning = false; From 62659afadb09c7252a479d7e2c3a06dd6542ccef Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 16 Jul 2014 02:48:02 +0100 Subject: [PATCH 4/5] Reactor Multiblock work --- .../generators/common/FusionReactor.java | 53 +++++++++++-------- .../tile/reactor/TileEntityReactorBlock.java | 23 ++++++++ .../tile/reactor/TileEntityReactorPort.java | 8 +-- 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 3b5db9456..e7aa9fdaa 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -19,12 +19,12 @@ import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -import static java.lang.Math.exp; import static java.lang.Math.min; import static java.lang.Math.max; @@ -99,7 +99,8 @@ public class FusionReactor implements IFusionReactor public void vaporiseHohlraum() { - fuelTank.receive(new GasStack(GasRegistry.getGas("fusionFuel"), 1000), true); + fuelTank.receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), 1000), true); + hasHohlraum = false; burning = true; } @@ -139,7 +140,10 @@ public class FusionReactor implements IFusionReactor public void boilWater() { - int waterToBoil = (int)min(waterTank.getFluidAmount(), temperature*temperature*waterRatio); + int waterToBoil = (int)min(waterTank.getFluidAmount(), temperature*1E-6); + int steamToGenerate = (int)(waterToBoil*temperature * 1E-6); + waterTank.drain(waterToBoil, true); + steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), steamToGenerate), true); } public void ambientLoss() @@ -181,41 +185,46 @@ public class FusionReactor implements IFusionReactor return fuelTank; } + public void unformMultiblock() + { + for(IReactorBlock block: reactorBlocks) + { + block.setReactor(null); + } + reactorBlocks.clear(); + neutronCaptors.clear(); + formed = false; + } + + @Override public void formMultiblock() { Coord4D controllerPosition = Coord4D.get(controller); Coord4D centreOfReactor = controllerPosition.getFromSide(ForgeDirection.DOWN, 2); + unformMultiblock(); + + reactorBlocks.add(controller); + Mekanism.logger.info("Centre at " + centreOfReactor.toString()); if(!createFrame(centreOfReactor)) { - for(IReactorBlock block: reactorBlocks) - { - block.setReactor(null); - } - reactorBlocks.clear(); + unformMultiblock(); + Mekanism.logger.info("Reactor failed: Frame not complete."); return; } Mekanism.logger.info("Frame valid"); if(!addSides(centreOfReactor)) { - for(IReactorBlock block: reactorBlocks) - { - block.setReactor(null); - } - reactorBlocks.clear(); - neutronCaptors.clear(); + unformMultiblock(); + Mekanism.logger.info("Reactor failed: Sides not complete."); return; } Mekanism.logger.info("Side Blocks Valid"); if(!centreIsClear(centreOfReactor)) { - for(IReactorBlock block: reactorBlocks) - { - block.setReactor(null); - } - reactorBlocks.clear(); - neutronCaptors.clear(); + unformMultiblock(); + Mekanism.logger.info("Blocks in chamber."); return; } Mekanism.logger.info("Centre is clear"); @@ -257,7 +266,7 @@ public class FusionReactor implements IFusionReactor {+0, +2, +0}, {+1, +2, +0}, {+0, +2, +1}, {-1, +2, +0}, {+0, +2, -1}, //TOP {+0, -2, +0}, {+1, -2, +0}, {+0, -2, +1}, {-1, -2, +0}, {+0, -2, -1}, //BOTTOM {+0, +0, +2}, {+1, +0, +2}, {+0, +1, +2}, {-1, +0, +2}, {+0, -1, +2}, //SOUTH - {+0, +0, +2}, {+1, +0, +2}, {+0, +1, +2}, {-1, +0, +2}, {+0, -1, +2}, //NORTH + {+0, +0, -2}, {+1, +0, -2}, {+0, +1, -2}, {-1, +0, -2}, {+0, -1, -2}, //NORTH }; for(int[] coords : positions) diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java index dbf6dd55d..dd5411ec9 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java @@ -8,10 +8,15 @@ import net.minecraft.tileentity.TileEntity; public abstract class TileEntityReactorBlock extends TileEntity implements IReactorBlock { public IFusionReactor fusionReactor; + public boolean changed; @Override public void setReactor(IFusionReactor reactor) { + if(reactor != fusionReactor) + { + changed = true; + } fusionReactor = reactor; } @@ -20,4 +25,22 @@ public abstract class TileEntityReactorBlock extends TileEntity implements IReac { return fusionReactor; } + + @Override + public void invalidate() + { + if(getReactor() != null) + { + getReactor().formMultiblock(); + } + } + + @Override + public void updateEntity() + { + if(changed) + { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index 1c1e4226e..2773d98d4 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -46,7 +46,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { if(getReactor() != null) { - getReactor().getSteamTank().drain(maxDrain, doDrain); + return getReactor().getSteamTank().drain(maxDrain, doDrain); } return null; } @@ -86,7 +86,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { return getReactor().getTritiumTank().receive(stack, true); } - else if(stack.getGas() == GasRegistry.getGas("fusionFuel")) + else if(stack.getGas() == GasRegistry.getGas("fusionFuelDT")) { return getReactor().getFuelTank().receive(stack, true); } @@ -111,7 +111,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public boolean canReceiveGas(ForgeDirection side, Gas type) { - return (type == GasRegistry.getGas("deuterium") || type == GasRegistry.getGas("tritium") || type == GasRegistry.getGas("fusionFuel")); + return (type == GasRegistry.getGas("deuterium") || type == GasRegistry.getGas("tritium") || type == GasRegistry.getGas("fusionFuelDT")); } @Override @@ -123,6 +123,6 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public boolean canTubeConnect(ForgeDirection side) { - return true; + return getReactor() != null; } } \ No newline at end of file From 86734401728371686d7548fc6e5c39f21b4ae4ca Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 16 Jul 2014 02:53:32 +0100 Subject: [PATCH 5/5] Reactor Logic work. More complex now, and more realistic, taking some cues from BigReactors' example. Plasma conducts temperature to the casing, which then conducts to coolant or the environment. Energy from passive cooling is stored in an internal buffer. --- .../generators/common/FusionReactor.java | 112 ++++++++++++------ .../reactor/TileEntityReactorController.java | 1 - 2 files changed, 75 insertions(+), 38 deletions(-) diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index e7aa9fdaa..31429f93f 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -46,20 +46,31 @@ public class FusionReactor implements IFusionReactor public Set reactorBlocks = new HashSet(); public Set neutronCaptors = new HashSet(); - public double temperature; - public static double burnTemperature = 1E8; + //Current stores of energy + public double plasmaTemperature; + public double caseTemperature; + public double energyBuffer; + //Reaction characteristics + public static double burnTemperature = 1E8; public static double burnRatio = 1; public static double tempPerFuel = 5E6; public int injectionRate = 0; - - public static double coolingCoefficient = 0.1; - - public static double waterRatio = 1E-14; - public static double inverseHeatCapacity = 1; + + //Thermal characteristics + public static double plasmaHeatCapacity = 1; + public static double caseHeatCapacity = 1; + public static double enthalpyOfVaporization = 10; + public static double thermocoupleEfficiency = 0.01; + + //Heat transfer metrics + public static double plasmaCaseConductivity = 0.2; + public static double caseWaterConductivity = 0.3; + public static double caseAirConductivity = 0.1; public boolean burning = false; public boolean hasHohlraum = false; + public boolean activelyCooled = true; public boolean formed = false; @@ -71,35 +82,45 @@ public class FusionReactor implements IFusionReactor @Override public void addTemperatureFromEnergyInput(double energyAdded) { - temperature += energyAdded * inverseHeatCapacity; + plasmaTemperature += energyAdded / plasmaHeatCapacity; } @Override public void simulate() { - if(temperature >= burnTemperature) + //Only thermal transfer happens unless we're hot enough to burn. + if(plasmaTemperature >= burnTemperature) { + //If we're not burning yet we need a hohlraum to ignite if(!burning && hasHohlraum) { vaporiseHohlraum(); } - injectFuel(); + //Only inject fuel if we're burning + if(burning) + { + injectFuel(); - int fuelBurned = burnFuel(); - neutronFlux(fuelBurned); + int fuelBurned = burnFuel(); + neutronFlux(fuelBurned); + } } else { burning = false; } - boilWater(); - ambientLoss(); - if(temperature > 0) - Mekanism.logger.info("Reactor temperature: " + (int)temperature); + + //Perform the heat transfer calculations + transferHeat(); + + if(plasmaTemperature > 1E-6 || caseTemperature > 1E-6) + { + Mekanism.logger.info("Reactor temperatures: Plasma: " + (int) plasmaTemperature + ", Casing: " + (int) caseTemperature); + } } public void vaporiseHohlraum() { - fuelTank.receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), 1000), true); + fuelTank.receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), 10), true); hasHohlraum = false; burning = true; } @@ -117,9 +138,9 @@ public class FusionReactor implements IFusionReactor public int burnFuel() { - int fuelBurned = (int)min(fuelTank.getStored(), max(0, temperature-burnTemperature)*burnRatio); + int fuelBurned = (int)min(fuelTank.getStored(), max(0, plasmaTemperature - burnTemperature)*burnRatio); fuelTank.draw(fuelBurned, true); - temperature += tempPerFuel * fuelBurned; + plasmaTemperature += tempPerFuel * fuelBurned; return fuelBurned; } @@ -138,21 +159,34 @@ public class FusionReactor implements IFusionReactor controller.radiateNeutrons(neutronsRemaining); } - public void boilWater() + public void transferHeat() { - int waterToBoil = (int)min(waterTank.getFluidAmount(), temperature*1E-6); - int steamToGenerate = (int)(waterToBoil*temperature * 1E-6); - waterTank.drain(waterToBoil, true); - steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), steamToGenerate), true); - } + //Transfer from plasma to casing + double plasmaCaseHeat = plasmaCaseConductivity * (plasmaTemperature - caseTemperature); + plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity; + caseTemperature += plasmaCaseHeat / caseHeatCapacity; - public void ambientLoss() - { - temperature -= coolingCoefficient*temperature; - if(temperature < 1E-6) + //Transfer from casing to water if necessary + if(activelyCooled) { - temperature = 0; + double caseWaterHeat = caseWaterConductivity * caseTemperature; + int waterToVaporize = (int)(caseWaterHeat / enthalpyOfVaporization); + Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water"); + waterToVaporize = min(waterToVaporize, min(waterTank.getFluidAmount(), steamTank.getCapacity() - steamTank.getFluidAmount())); + if(waterToVaporize > 0) + { + Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water"); + waterTank.drain(waterToVaporize, true); + steamTank.fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true); + } + caseWaterHeat = waterToVaporize * enthalpyOfVaporization; + caseTemperature -= caseWaterHeat / caseHeatCapacity; } + + //Transfer from casing to environment + double caseAirHeat = caseAirConductivity * caseTemperature; + caseTemperature -= caseAirHeat / caseHeatCapacity; + energyBuffer += caseAirHeat * thermocoupleEfficiency; } @Override @@ -191,6 +225,8 @@ public class FusionReactor implements IFusionReactor { block.setReactor(null); } + //Don't remove from controller + controller.setReactor(this); reactorBlocks.clear(); neutronCaptors.clear(); formed = false; @@ -199,6 +235,8 @@ public class FusionReactor implements IFusionReactor @Override public void formMultiblock() { + Mekanism.logger.trace("Attempting to form multiblock"); + Coord4D controllerPosition = Coord4D.get(controller); Coord4D centreOfReactor = controllerPosition.getFromSide(ForgeDirection.DOWN, 2); @@ -206,28 +244,28 @@ public class FusionReactor implements IFusionReactor reactorBlocks.add(controller); - Mekanism.logger.info("Centre at " + centreOfReactor.toString()); + Mekanism.logger.trace("Centre at " + centreOfReactor.toString()); if(!createFrame(centreOfReactor)) { unformMultiblock(); - Mekanism.logger.info("Reactor failed: Frame not complete."); + Mekanism.logger.trace("Reactor failed: Frame not complete."); return; } - Mekanism.logger.info("Frame valid"); + Mekanism.logger.trace("Frame valid"); if(!addSides(centreOfReactor)) { unformMultiblock(); - Mekanism.logger.info("Reactor failed: Sides not complete."); + Mekanism.logger.trace("Reactor failed: Sides not complete."); return; } - Mekanism.logger.info("Side Blocks Valid"); + Mekanism.logger.trace("Side Blocks Valid"); if(!centreIsClear(centreOfReactor)) { unformMultiblock(); - Mekanism.logger.info("Blocks in chamber."); + Mekanism.logger.trace("Blocks in chamber."); return; } - Mekanism.logger.info("Centre is clear"); + Mekanism.logger.trace("Centre is clear"); formed = true; } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index c2419188a..1c98189e4 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -21,7 +21,6 @@ public class TileEntityReactorController extends TileEntityReactorBlock { setReactor(new FusionReactor(this)); } - Mekanism.logger.info("Attempting to form multiblock"); getReactor().formMultiblock(); }