More work on Fusion Reactor

This commit is contained in:
Ben Spiers 2014-07-15 00:13:20 +01:00
parent cb2188580e
commit bdde617489
10 changed files with 209 additions and 16 deletions

View file

@ -6,7 +6,7 @@ import net.minecraftforge.fluids.FluidTank;
public interface IFusionReactor public interface IFusionReactor
{ {
public void addTemperature(double energyAdded); public void addTemperatureFromEnergyInput(double energyAdded);
public void simulate(); public void simulate();
@ -19,4 +19,6 @@ public interface IFusionReactor
public GasTank getTritiumTank(); public GasTank getTritiumTank();
public GasTank getFuelTank(); public GasTank getFuelTank();
public void formMultiblock();
} }

View file

@ -120,6 +120,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber;
import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityFactory;
import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.tile.TileEntityFluidicPlenisher;
import mekanism.common.tile.TileEntityGasTank; import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.tile.TileEntityLaser;
import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityLogisticalSorter;
import mekanism.common.tile.TileEntityMetallurgicInfuser; import mekanism.common.tile.TileEntityMetallurgicInfuser;
import mekanism.common.tile.TileEntityObsidianTNT; 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.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext; 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.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -303,6 +305,8 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderPressurizedReactionChamber()); ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderPressurizedReactionChamber());
ClientRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank", new RenderPortableTank()); ClientRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank", new RenderPortableTank());
ClientRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher", new RenderFluidicPlenisher()); ClientRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher", new RenderFluidicPlenisher());
//TODO needs a model, I think.
GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser");
} }
@Override @Override

View file

@ -74,7 +74,7 @@ public class MekanismRenderer
GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen")); GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen"));
GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen")); GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen"));
GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:WaterVapor")); 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("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurDioxide"));
GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide")); GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide"));
GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid")); GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid"));
@ -84,6 +84,11 @@ public class MekanismRenderer
GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:Ethene")); GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:Ethene"));
GasRegistry.getGas("brine").setIcon(event.map.registerIcon("mekanism:LiquidBrine")); GasRegistry.getGas("brine").setIcon(event.map.registerIcon("mekanism:LiquidBrine"));
GasRegistry.getGas("sodium").setIcon(event.map.registerIcon("mekanism:LiquidSodium")); 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()) for(Gas gas : GasRegistry.getRegisteredGasses())
{ {

View file

@ -64,6 +64,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber;
import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityFactory;
import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.tile.TileEntityFluidicPlenisher;
import mekanism.common.tile.TileEntityGasTank; import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.tile.TileEntityLaser;
import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.tile.TileEntityLogisticalSorter;
import mekanism.common.tile.TileEntityMetallurgicInfuser; import mekanism.common.tile.TileEntityMetallurgicInfuser;
import mekanism.common.tile.TileEntityObsidianTNT; import mekanism.common.tile.TileEntityObsidianTNT;
@ -136,6 +137,7 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber"); GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber");
GameRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank"); GameRegistry.registerTileEntity(TileEntityPortableTank.class, "PortableTank");
GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher"); GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher");
GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser");
} }
/** /**

View file

@ -105,6 +105,7 @@ import mekanism.common.tile.TileEntityBoundingBlock;
import mekanism.common.tile.TileEntityCardboardBox; import mekanism.common.tile.TileEntityCardboardBox;
import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.tile.TileEntityEnergizedSmelter; import mekanism.common.tile.TileEntityEnergizedSmelter;
import mekanism.common.tile.TileEntityLaser;
import mekanism.common.tile.TileEntitySalinationTank; import mekanism.common.tile.TileEntitySalinationTank;
import mekanism.common.tile.TileEntitySalinationValve; import mekanism.common.tile.TileEntitySalinationValve;
import mekanism.common.transporter.TransporterManager; import mekanism.common.transporter.TransporterManager;
@ -1335,6 +1336,11 @@ public class Mekanism
GasRegistry.register(new Gas("ethene").registerFluid()); GasRegistry.register(new Gas("ethene").registerFluid());
GasRegistry.register(new Gas("sodium").registerFluid()); GasRegistry.register(new Gas("sodium").registerFluid());
GasRegistry.register(new Gas("brine").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()) for(Resource resource : Resource.values())
{ {

View file

@ -180,19 +180,14 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
} }
else if(this == Mekanism.MachineBlock2) 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][0] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOff");
icons[3][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn"); icons[3][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn");
icons[3][2] = register.registerIcon("mekanism:SteelCasing"); icons[3][2] = register.registerIcon("mekanism:SteelCasing");
icons[5][0] = register.registerIcon("mekanism:PrecisionSawmillFrontOff"); icons[5][0] = register.registerIcon("mekanism:PrecisionSawmillFrontOff");
icons[5][1] = register.registerIcon("mekanism:PrecisionSawmillFrontOn"); icons[5][1] = register.registerIcon("mekanism:PrecisionSawmillFrontOn");
icons[5][2] = register.registerIcon("mekanism:SteelCasing"); icons[5][2] = register.registerIcon("mekanism:SteelCasing");
icons[9][0] = register.registerIcon("mekanism:SteelBlock"); icons[13][0] = register.registerIcon("mekanism:SteelCasing");
icons[9][1] = register.registerIcon("mekanism:SeismicVibrator"); icons[13][1] = register.registerIcon("mekanism:Laser");
icons[13][0] = register.registerIcon("Mekanism:SteelCasing");
icons[13][1] = register.registerIcon("Mekanism:Laser");
} }
} }

View file

@ -6,17 +6,25 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.api.Coord4D;
import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.api.lasers.ILaserReceptor;
import mekanism.api.reactor.IFusionReactor; import mekanism.api.reactor.IFusionReactor;
import mekanism.api.reactor.INeutronCapture; import mekanism.api.reactor.INeutronCapture;
import mekanism.api.reactor.IReactorBlock; import mekanism.api.reactor.IReactorBlock;
import mekanism.common.Mekanism;
import mekanism.generators.common.tile.reactor.TileEntityReactorController; 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.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
import static java.lang.Math.exp;
import static java.lang.Math.min; import static java.lang.Math.min;
import static java.lang.Math.max; import static java.lang.Math.max;
@ -43,9 +51,9 @@ public class FusionReactor implements IFusionReactor
public static double burnRatio = 1; public static double burnRatio = 1;
public static double tempPerFuel = 5*10^6; 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 waterRatio = 10^-14;
public static double inverseHeatCapacity = 1; public static double inverseHeatCapacity = 1;
@ -53,8 +61,15 @@ public class FusionReactor implements IFusionReactor
public boolean burning = false; public boolean burning = false;
public boolean hasHohlraum = false; public boolean hasHohlraum = false;
public boolean formed = false;
public FusionReactor(TileEntityReactorController c)
{
controller = c;
}
@Override @Override
public void addTemperature(double energyAdded) public void addTemperatureFromEnergyInput(double energyAdded)
{ {
temperature += energyAdded * inverseHeatCapacity; temperature += energyAdded * inverseHeatCapacity;
} }
@ -78,6 +93,8 @@ public class FusionReactor implements IFusionReactor
} }
boilWater(); boilWater();
ambientLoss(); ambientLoss();
if(temperature > 0)
Mekanism.logger.info("Reactor temperature: " + (int)temperature);
} }
public void vaporiseHohlraum() public void vaporiseHohlraum()
@ -128,6 +145,10 @@ public class FusionReactor implements IFusionReactor
public void ambientLoss() public void ambientLoss()
{ {
temperature -= coolingCoefficient*temperature; temperature -= coolingCoefficient*temperature;
if(temperature < 1E-6)
{
temperature = 0;
}
} }
@Override @Override
@ -159,4 +180,130 @@ public class FusionReactor implements IFusionReactor
{ {
return fuelTank; 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;
}
} }

View file

@ -129,6 +129,17 @@ public class BlockReactor extends BlockContainer
return i; 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 @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item i, CreativeTabs creativetabs, List list) public void getSubBlocks(Item i, CreativeTabs creativetabs, List list)

View file

@ -1,5 +1,8 @@
package mekanism.generators.common.tile.reactor; package mekanism.generators.common.tile.reactor;
import mekanism.common.Mekanism;
import mekanism.generators.common.FusionReactor;
public class TileEntityReactorController extends TileEntityReactorBlock public class TileEntityReactorController extends TileEntityReactorBlock
{ {
@Override @Override
@ -11,4 +14,23 @@ public class TileEntityReactorController extends TileEntityReactorBlock
public void radiateNeutrons(int neutrons) 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();
}
}
} }

View file

@ -7,8 +7,6 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock implements ILaserReceptor public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock implements ILaserReceptor
{ {
public IFusionReactor fusionReactor;
@Override @Override
public boolean isFrame() public boolean isFrame()
{ {
@ -18,7 +16,8 @@ public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock im
@Override @Override
public void receiveLaserEnergy(double energy, ForgeDirection side) public void receiveLaserEnergy(double energy, ForgeDirection side)
{ {
fusionReactor.addTemperature(energy); if(getReactor() != null)
getReactor().addTemperatureFromEnergyInput(energy);
} }
@Override @Override