This commit is contained in:
Aidan C. Brady 2014-07-19 02:34:13 -04:00
commit 00abd47b84
19 changed files with 702 additions and 26 deletions

View file

@ -24,6 +24,14 @@ public interface IFusionReactor
public void setBufferedEnergy(double energy); public void setBufferedEnergy(double energy);
public double getPlasmaTemp();
public void setPlasmaTemp(double temp);
public double getCaseTemp();
public void setCaseTemp(double temp);
public double getBufferSize(); public double getBufferSize();
public void formMultiblock(); public void formMultiblock();

View file

@ -73,7 +73,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:LiquidSteam"));
GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:LiquidChlorine")); 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"));
@ -81,13 +81,13 @@ public class MekanismRenderer
GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride")); GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride"));
GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium")); GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium"));
GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:LiquidStone")); GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:LiquidStone"));
GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:Ethene")); GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:LiquidEthene"));
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("deuterium").setIcon(event.map.registerIcon("mekanism:LiquidDeuterium"));
GasRegistry.getGas("tritium").setIcon(event.map.registerIcon("mekanism:LiquidTritium")); GasRegistry.getGas("tritium").setIcon(event.map.registerIcon("mekanism:LiquidTritium"));
GasRegistry.getGas("fusionFuelDD").setIcon(event.map.registerIcon("mekanism:LiquidDD")); GasRegistry.getGas("fusionFuelDD").setIcon(event.map.registerIcon("mekanism:LiquidDD"));
GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:liquidDT")); GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:LiquidDT"));
GasRegistry.getGas("steam").setIcon(event.map.registerIcon("mekanism:LiquidSteam")); GasRegistry.getGas("steam").setIcon(event.map.registerIcon("mekanism:LiquidSteam"));
for(Gas gas : GasRegistry.getRegisteredGasses()) for(Gas gas : GasRegistry.getRegisteredGasses())

View file

@ -3,6 +3,8 @@ package mekanism.generators.client;
import mekanism.generators.client.gui.GuiBioGenerator; import mekanism.generators.client.gui.GuiBioGenerator;
import mekanism.generators.client.gui.GuiHeatGenerator; import mekanism.generators.client.gui.GuiHeatGenerator;
import mekanism.generators.client.gui.GuiGasGenerator; import mekanism.generators.client.gui.GuiGasGenerator;
import mekanism.generators.client.gui.GuiNeutronCapture;
import mekanism.generators.client.gui.GuiReactorController;
import mekanism.generators.client.gui.GuiSolarGenerator; import mekanism.generators.client.gui.GuiSolarGenerator;
import mekanism.generators.client.gui.GuiWindTurbine; import mekanism.generators.client.gui.GuiWindTurbine;
import mekanism.generators.client.render.RenderAdvancedSolarGenerator; import mekanism.generators.client.render.RenderAdvancedSolarGenerator;
@ -18,6 +20,9 @@ import mekanism.generators.common.tile.TileEntityHeatGenerator;
import mekanism.generators.common.tile.TileEntityGasGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator;
import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.TileEntityWindTurbine; import mekanism.generators.common.tile.TileEntityWindTurbine;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -69,6 +74,10 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy
return new GuiBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity); return new GuiBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity);
case 5: case 5:
return new GuiWindTurbine(player.inventory, (TileEntityWindTurbine)tileEntity); return new GuiWindTurbine(player.inventory, (TileEntityWindTurbine)tileEntity);
case 10:
return new GuiReactorController(player.inventory, (TileEntityReactorController)tileEntity);
case 11:
return new GuiNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity);
} }
return null; return null;

View file

@ -0,0 +1,71 @@
package mekanism.generators.client.gui;
import java.util.List;
import mekanism.api.ListUtils;
import mekanism.client.gui.GuiEnergyInfo;
import mekanism.client.gui.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.GuiSlot;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.common.inventory.container.ContainerNeutronCapture;
import mekanism.generators.common.inventory.container.ContainerReactorController;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture;
import net.minecraft.entity.player.InventoryPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiNeutronCapture extends GuiMekanism
{
public TileEntityReactorNeutronCapture tileEntity;
public GuiNeutronCapture(InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity)
{
super(new ContainerNeutronCapture(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiEnergyInfo(new IInfoHandler()
{
@Override
public List<String> getInfo()
{
return ListUtils.asList(
"Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()),
"Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 164, 15));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 142, 34).with(SlotOverlay.POWER));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRendererObj.drawString(tileEntity.getInventoryName(), 30, 6, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
}

View file

@ -0,0 +1,127 @@
package mekanism.generators.client.gui;
import java.util.List;
import mekanism.api.ListUtils;
import mekanism.api.gas.GasTank;
import mekanism.client.gui.GuiEnergyInfo;
import mekanism.client.gui.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.GuiFluidGauge;
import mekanism.client.gui.GuiFluidGauge.IFluidInfoHandler;
import mekanism.client.gui.GuiGasGauge;
import mekanism.client.gui.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.GuiGauge.Type;
import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiRedstoneControl;
import mekanism.client.gui.GuiSlot;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.inventory.container.ContainerReactorController;
import mekanism.generators.common.inventory.container.ContainerSolarGenerator;
import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiReactorController extends GuiMekanism
{
public TileEntityReactorController tileEntity;
public GuiReactorController(InventoryPlayer inventory, final TileEntityReactorController tentity)
{
super(new ContainerReactorController(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiEnergyInfo(new IInfoHandler()
{
@Override
public List<String> getInfo()
{
return ListUtils.asList(
"Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()),
"Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
public GasTank getTank()
{
return tentity.deuteriumTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 16));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
public GasTank getTank()
{
return tentity.tritiumTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 46));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
public GasTank getTank()
{
return tentity.fuelTank;
}
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 144, 16));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()
{
@Override
public FluidTank getTank()
{
return tentity.waterTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 78, 46));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()
{
@Override
public FluidTank getTank()
{
return tentity.steamTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 98, 46));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 164, 15));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 98, 26));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRendererObj.drawString(tileEntity.getInventoryName(), 30, 6, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
if(tileEntity.getReactor() == null)
{
fontRendererObj.drawString(MekanismUtils.localize("container.reactor.notFormed"), 8, 16, 0x404040);
}
else
{
fontRendererObj.drawString(MekanismUtils.localize("container.reactor.formed"), 8, 16, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("plasma") + ": " + (int)(tileEntity.getReactor().getPlasmaTemp()+23)+"C", 8, 26, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("casing") + ": " + (int)(tileEntity.getReactor().getCaseTemp()+23)+"C", 8, 36, 0x404040);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
}

View file

@ -34,21 +34,26 @@ public class FusionReactor implements IFusionReactor
public Set<IReactorBlock> reactorBlocks = new HashSet<IReactorBlock>(); public Set<IReactorBlock> reactorBlocks = new HashSet<IReactorBlock>();
public Set<INeutronCapture> neutronCaptors = new HashSet<INeutronCapture>(); public Set<INeutronCapture> neutronCaptors = new HashSet<INeutronCapture>();
//Current stores of energy //Current stores of temperature
public double plasmaTemperature; public double plasmaTemperature;
public double caseTemperature; public double caseTemperature;
//Last values of temperature
public double lastPlasmaTemperature;
public double lastCaseTemperature;
//Reaction characteristics //Reaction characteristics
public static double burnTemperature = 1E8; public static double burnTemperature = 1E8;
public static double burnRatio = 1; public static double burnRatio = 1;
public static double tempPerFuel = 5E6; public static double energyPerFuel = 5E6;
public int injectionRate = 0; public int injectionRate = 0;
//Thermal characteristics //Thermal characteristics
public static double plasmaHeatCapacity = 1; public static double plasmaHeatCapacity = 100;
public static double caseHeatCapacity = 1; public static double caseHeatCapacity = 1;
public static double enthalpyOfVaporization = 10; public static double enthalpyOfVaporization = 10;
public static double thermocoupleEfficiency = 0.01; public static double thermocoupleEfficiency = 0.01;
public static double steamTransferEfficiency = 0.1;
//Heat transfer metrics //Heat transfer metrics
public static double plasmaCaseConductivity = 0.2; public static double plasmaCaseConductivity = 0.2;
@ -75,6 +80,12 @@ public class FusionReactor implements IFusionReactor
@Override @Override
public void simulate() public void simulate()
{ {
if(controller.getWorldObj().isRemote)
{
lastPlasmaTemperature = plasmaTemperature;
lastCaseTemperature = caseTemperature;
return;
}
//Only thermal transfer happens unless we're hot enough to burn. //Only thermal transfer happens unless we're hot enough to burn.
if(plasmaTemperature >= burnTemperature) if(plasmaTemperature >= burnTemperature)
{ {
@ -99,10 +110,8 @@ public class FusionReactor implements IFusionReactor
//Perform the heat transfer calculations //Perform the heat transfer calculations
transferHeat(); transferHeat();
if(plasmaTemperature > 1E-6 || caseTemperature > 1E-6) lastPlasmaTemperature = plasmaTemperature < 1E-1 ? 0 : plasmaTemperature;
{ lastCaseTemperature = caseTemperature < 1E-1 ? 0 : caseTemperature;
Mekanism.logger.info("Reactor temperatures: Plasma: " + (int) plasmaTemperature + ", Casing: " + (int) caseTemperature);
}
} }
public void vaporiseHohlraum() public void vaporiseHohlraum()
@ -125,9 +134,9 @@ public class FusionReactor implements IFusionReactor
public int burnFuel() public int burnFuel()
{ {
int fuelBurned = (int)min(getFuelTank().getStored(), max(0, plasmaTemperature - burnTemperature)*burnRatio); int fuelBurned = (int)min(getFuelTank().getStored(), max(0, lastPlasmaTemperature - burnTemperature)*burnRatio);
getFuelTank().draw(fuelBurned, true); getFuelTank().draw(fuelBurned, true);
plasmaTemperature += tempPerFuel * fuelBurned; plasmaTemperature += energyPerFuel * fuelBurned / plasmaHeatCapacity;
return fuelBurned; return fuelBurned;
} }
@ -149,29 +158,29 @@ public class FusionReactor implements IFusionReactor
public void transferHeat() public void transferHeat()
{ {
//Transfer from plasma to casing //Transfer from plasma to casing
double plasmaCaseHeat = plasmaCaseConductivity * (plasmaTemperature - caseTemperature); double plasmaCaseHeat = plasmaCaseConductivity * (lastPlasmaTemperature - lastCaseTemperature);
plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity; plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity;
caseTemperature += plasmaCaseHeat / caseHeatCapacity; caseTemperature += plasmaCaseHeat / caseHeatCapacity;
//Transfer from casing to water if necessary //Transfer from casing to water if necessary
if(activelyCooled) if(activelyCooled)
{ {
double caseWaterHeat = caseWaterConductivity * caseTemperature; double caseWaterHeat = caseWaterConductivity * lastCaseTemperature;
int waterToVaporize = (int)(caseWaterHeat / enthalpyOfVaporization); int waterToVaporize = (int)(steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization);
Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water"); //Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water");
waterToVaporize = min(waterToVaporize, min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount())); waterToVaporize = min(waterToVaporize, min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount()));
if(waterToVaporize > 0) if(waterToVaporize > 0)
{ {
Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water"); //Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water");
getWaterTank().drain(waterToVaporize, true); getWaterTank().drain(waterToVaporize, true);
getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true); getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true);
} }
caseWaterHeat = waterToVaporize * enthalpyOfVaporization; caseWaterHeat = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency;
caseTemperature -= caseWaterHeat / caseHeatCapacity; caseTemperature -= caseWaterHeat / caseHeatCapacity;
} }
//Transfer from casing to environment //Transfer from casing to environment
double caseAirHeat = caseAirConductivity * caseTemperature; double caseAirHeat = caseAirConductivity * lastCaseTemperature;
caseTemperature -= caseAirHeat / caseHeatCapacity; caseTemperature -= caseAirHeat / caseHeatCapacity;
setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency); setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency);
} }
@ -218,6 +227,30 @@ public class FusionReactor implements IFusionReactor
controller.setEnergy(energy); controller.setEnergy(energy);
} }
@Override
public double getPlasmaTemp()
{
return lastPlasmaTemperature;
}
@Override
public void setPlasmaTemp(double temp)
{
plasmaTemperature = temp;
}
@Override
public double getCaseTemp()
{
return lastCaseTemperature;
}
@Override
public void setCaseTemp(double temp)
{
caseTemperature = temp;
}
@Override @Override
public double getBufferSize() public double getBufferSize()
{ {

View file

@ -4,6 +4,8 @@ import mekanism.common.Mekanism;
import mekanism.generators.common.inventory.container.ContainerBioGenerator; import mekanism.generators.common.inventory.container.ContainerBioGenerator;
import mekanism.generators.common.inventory.container.ContainerHeatGenerator; import mekanism.generators.common.inventory.container.ContainerHeatGenerator;
import mekanism.generators.common.inventory.container.ContainerGasGenerator; import mekanism.generators.common.inventory.container.ContainerGasGenerator;
import mekanism.generators.common.inventory.container.ContainerNeutronCapture;
import mekanism.generators.common.inventory.container.ContainerReactorController;
import mekanism.generators.common.inventory.container.ContainerSolarGenerator; import mekanism.generators.common.inventory.container.ContainerSolarGenerator;
import mekanism.generators.common.inventory.container.ContainerWindTurbine; import mekanism.generators.common.inventory.container.ContainerWindTurbine;
import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator; import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator;
@ -119,6 +121,10 @@ public class GeneratorsCommonProxy
return new ContainerBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity); return new ContainerBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity);
case 5: case 5:
return new ContainerWindTurbine(player.inventory, (TileEntityWindTurbine)tileEntity); return new ContainerWindTurbine(player.inventory, (TileEntityWindTurbine)tileEntity);
case 10:
return new ContainerReactorController(player.inventory, (TileEntityReactorController)tileEntity);
case 11:
return new ContainerNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity);
} }
return null; return null;

View file

@ -132,12 +132,69 @@ public class BlockReactor extends BlockContainer
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) 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(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
if(tile instanceof TileEntityReactorController)
{ {
((TileEntityReactorController)tile).formMultiblock(); return false;
} }
return true;
if(world.isRemote)
{
return true;
}
TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
if(entityplayer.getCurrentEquippedItem() != null)
{
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench"))
{
if(entityplayer.isSneaking())
{
dismantleBlock(world, x, y, z, false);
return true;
}
((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z);
int change = 0;
switch(tileEntity.facing)
{
case 3:
change = 5;
break;
case 5:
change = 2;
break;
case 2:
change = 4;
break;
case 4:
change = 3;
break;
}
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
}
}
if(tileEntity instanceof TileEntityReactorController)
{
if(!entityplayer.isSneaking())
{
entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.getFromMetadata(metadata).guiId, world, x, y, z);
}
else
{
((TileEntityReactorController)tileEntity).formMultiblock();
}
return true;
}
return false;
} }
@Override @Override
@ -210,7 +267,7 @@ public class BlockReactor extends BlockContainer
public int guiId; public int guiId;
public Class<? extends TileEntity> tileEntityClass; public Class<? extends TileEntity> tileEntityClass;
private ReactorBlockType(int i, String s, int j, Class<? extends TileEntity> tileClass) private ReactorBlockType(int i, String s, int j, Class<? extends TileEntityElectricBlock> tileClass)
{ {
meta = i; meta = i;
name = s; name = s;
@ -256,4 +313,24 @@ public class BlockReactor extends BlockContainer
} }
} }
public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock)
{
ItemStack itemStack = getPickBlock(null, world, x, y, z);
world.setBlockToAir(x, y, z);
if(!returnBlock)
{
float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack);
world.spawnEntityInWorld(entityItem);
}
return itemStack;
}
} }

View file

@ -0,0 +1,125 @@
package mekanism.generators.common.inventory.container;
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.util.ChargeUtils;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerNeutronCapture extends Container
{
private TileEntityReactorNeutronCapture tileEntity;
public ContainerNeutronCapture(InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotCharge(tentity, 0, 143, 35));
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
{
for(int slotY = 0; slotY < 9; ++slotY)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openInventory();
tileEntity.open(inventory.player);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeInventory();
tileEntity.close(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot currentSlot = (Slot)inventorySlots.get(slotID);
if(currentSlot != null && currentSlot.getHasStack())
{
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(ChargeUtils.canBeCharged(slotStack))
{
if(slotID != 0)
{
if(!mergeItemStack(slotStack, 0, 1, false))
{
return null;
}
}
else if(slotID == 0)
{
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false))
{
return null;
}
}
}
else {
if(slotID >= 1 && slotID <= 27)
{
if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 27)
{
if(!mergeItemStack(slotStack, 1, 27, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true))
{
return null;
}
}
}
if(slotStack.stackSize == 0)
{
currentSlot.putStack((ItemStack)null);
}
else {
currentSlot.onSlotChanged();
}
if(slotStack.stackSize == stack.stackSize)
{
return null;
}
currentSlot.onPickupFromSlot(player, slotStack);
}
return stack;
}
}

View file

@ -0,0 +1,125 @@
package mekanism.generators.common.inventory.container;
import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.util.ChargeUtils;
import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerReactorController extends Container
{
private TileEntityReactorController tileEntity;
public ContainerReactorController(InventoryPlayer inventory, TileEntityReactorController tentity)
{
tileEntity = tentity;
addSlotToContainer(new Slot(tentity, 0, 99, 27));
int slotX;
for(slotX = 0; slotX < 3; ++slotX)
{
for(int slotY = 0; slotY < 9; ++slotY)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.openInventory();
tileEntity.open(inventory.player);
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.closeInventory();
tileEntity.close(entityplayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot currentSlot = (Slot)inventorySlots.get(slotID);
if(currentSlot != null && currentSlot.getHasStack())
{
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(ChargeUtils.canBeCharged(slotStack))
{
if(slotID != 0)
{
if(!mergeItemStack(slotStack, 0, 1, false))
{
return null;
}
}
else if(slotID == 0)
{
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false))
{
return null;
}
}
}
else {
if(slotID >= 1 && slotID <= 27)
{
if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 27)
{
if(!mergeItemStack(slotStack, 1, 27, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true))
{
return null;
}
}
}
if(slotStack.stackSize == 0)
{
currentSlot.putStack((ItemStack)null);
}
else {
currentSlot.onSlotChanged();
}
if(slotStack.stackSize == stack.stackSize)
{
return null;
}
currentSlot.onPickupFromSlot(player, slotStack);
}
return stack;
}
}

View file

@ -57,6 +57,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp
if(changed) if(changed)
{ {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
changed = false;
} }
} }

View file

@ -1,13 +1,24 @@
package mekanism.generators.common.tile.reactor; package mekanism.generators.common.tile.reactor;
import java.util.ArrayList;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.common.IActiveState;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.FusionReactor; import mekanism.generators.common.FusionReactor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
public class TileEntityReactorController extends TileEntityReactorBlock import io.netty.buffer.ByteBuf;
public class TileEntityReactorController extends TileEntityReactorBlock implements IActiveState
{ {
public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME; public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME;
@ -24,6 +35,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock
public TileEntityReactorController() public TileEntityReactorController()
{ {
super("ReactorController", 1000000000); super("ReactorController", 1000000000);
inventory = new ItemStack[1];
} }
@Override @Override
@ -50,9 +62,83 @@ public class TileEntityReactorController extends TileEntityReactorBlock
{ {
super.onUpdate(); super.onUpdate();
if(getReactor() != null && !worldObj.isRemote) if(getReactor() != null)
{ {
getReactor().simulate(); getReactor().simulate();
} }
} }
@Override
public ArrayList getNetworkedData(ArrayList data)
{
super.getNetworkedData(data);
data.add(getReactor() != null);
if(getReactor() != null)
{
data.add(getReactor().getPlasmaTemp());
data.add(getReactor().getCaseTemp());
data.add(fuelTank.getStored());
data.add(deuteriumTank.getStored());
data.add(tritiumTank.getStored());
data.add(waterTank.getFluidAmount());
data.add(steamTank.getFluidAmount());
}
return data;
}
@Override
public void handlePacketData(ByteBuf dataStream)
{
super.handlePacketData(dataStream);
boolean formed = dataStream.readBoolean();
if(formed)
{
if(getReactor() == null)
{
setReactor(new FusionReactor(this));
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
getReactor().setPlasmaTemp(dataStream.readDouble());
getReactor().setCaseTemp(dataStream.readDouble());
fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()));
deuteriumTank.setGas(new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt()));
tritiumTank.setGas(new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt()));
waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt()));
steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt()));
}
else if(getReactor() != null)
{
setReactor(null);
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
@Override
public boolean getActive()
{
return getReactor() != null;
}
@Override
public void setActive(boolean active)
{
if(active == (getReactor() == null))
{
setReactor(active ? new FusionReactor(this) : null);
}
}
@Override
public boolean renderUpdate()
{
return true;
}
@Override
public boolean lightUpdate()
{
return false;
}
} }

View file

@ -11,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection; import mekanism.api.gas.ITubeConnection;
import mekanism.common.util.CableUtils; import mekanism.common.util.CableUtils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
@ -23,7 +24,9 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
public TileEntityReactorPort() public TileEntityReactorPort()
{ {
super("name", 1); super("name", 1);
inventory = new ItemStack[0];
} }
@Override @Override
public boolean isFrame() public boolean isFrame()
{ {

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 10
}
}