Merge branch '1.8' of https://github.com/aidancbrady/Mekanism into 1.8
This commit is contained in:
commit
00abd47b84
19 changed files with 702 additions and 26 deletions
|
@ -24,6 +24,14 @@ public interface IFusionReactor
|
|||
|
||||
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 void formMultiblock();
|
||||
|
|
|
@ -73,7 +73,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("water").setIcon(event.map.registerIcon("mekanism:LiquidSteam"));
|
||||
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"));
|
||||
|
@ -81,13 +81,13 @@ public class MekanismRenderer
|
|||
GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride"));
|
||||
GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium"));
|
||||
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("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("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:LiquidDT"));
|
||||
GasRegistry.getGas("steam").setIcon(event.map.registerIcon("mekanism:LiquidSteam"));
|
||||
|
||||
for(Gas gas : GasRegistry.getRegisteredGasses())
|
||||
|
|
|
@ -3,6 +3,8 @@ package mekanism.generators.client;
|
|||
import mekanism.generators.client.gui.GuiBioGenerator;
|
||||
import mekanism.generators.client.gui.GuiHeatGenerator;
|
||||
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.GuiWindTurbine;
|
||||
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.TileEntitySolarGenerator;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -69,6 +74,10 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy
|
|||
return new GuiBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity);
|
||||
case 5:
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -34,21 +34,26 @@ public class FusionReactor implements IFusionReactor
|
|||
public Set<IReactorBlock> reactorBlocks = new HashSet<IReactorBlock>();
|
||||
public Set<INeutronCapture> neutronCaptors = new HashSet<INeutronCapture>();
|
||||
|
||||
//Current stores of energy
|
||||
//Current stores of temperature
|
||||
public double plasmaTemperature;
|
||||
public double caseTemperature;
|
||||
|
||||
//Last values of temperature
|
||||
public double lastPlasmaTemperature;
|
||||
public double lastCaseTemperature;
|
||||
|
||||
//Reaction characteristics
|
||||
public static double burnTemperature = 1E8;
|
||||
public static double burnRatio = 1;
|
||||
public static double tempPerFuel = 5E6;
|
||||
public static double energyPerFuel = 5E6;
|
||||
public int injectionRate = 0;
|
||||
|
||||
//Thermal characteristics
|
||||
public static double plasmaHeatCapacity = 1;
|
||||
public static double plasmaHeatCapacity = 100;
|
||||
public static double caseHeatCapacity = 1;
|
||||
public static double enthalpyOfVaporization = 10;
|
||||
public static double thermocoupleEfficiency = 0.01;
|
||||
public static double steamTransferEfficiency = 0.1;
|
||||
|
||||
//Heat transfer metrics
|
||||
public static double plasmaCaseConductivity = 0.2;
|
||||
|
@ -75,6 +80,12 @@ public class FusionReactor implements IFusionReactor
|
|||
@Override
|
||||
public void simulate()
|
||||
{
|
||||
if(controller.getWorldObj().isRemote)
|
||||
{
|
||||
lastPlasmaTemperature = plasmaTemperature;
|
||||
lastCaseTemperature = caseTemperature;
|
||||
return;
|
||||
}
|
||||
//Only thermal transfer happens unless we're hot enough to burn.
|
||||
if(plasmaTemperature >= burnTemperature)
|
||||
{
|
||||
|
@ -99,10 +110,8 @@ public class FusionReactor implements IFusionReactor
|
|||
//Perform the heat transfer calculations
|
||||
transferHeat();
|
||||
|
||||
if(plasmaTemperature > 1E-6 || caseTemperature > 1E-6)
|
||||
{
|
||||
Mekanism.logger.info("Reactor temperatures: Plasma: " + (int) plasmaTemperature + ", Casing: " + (int) caseTemperature);
|
||||
}
|
||||
lastPlasmaTemperature = plasmaTemperature < 1E-1 ? 0 : plasmaTemperature;
|
||||
lastCaseTemperature = caseTemperature < 1E-1 ? 0 : caseTemperature;
|
||||
}
|
||||
|
||||
public void vaporiseHohlraum()
|
||||
|
@ -125,9 +134,9 @@ public class FusionReactor implements IFusionReactor
|
|||
|
||||
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);
|
||||
plasmaTemperature += tempPerFuel * fuelBurned;
|
||||
plasmaTemperature += energyPerFuel * fuelBurned / plasmaHeatCapacity;
|
||||
return fuelBurned;
|
||||
}
|
||||
|
||||
|
@ -149,29 +158,29 @@ public class FusionReactor implements IFusionReactor
|
|||
public void transferHeat()
|
||||
{
|
||||
//Transfer from plasma to casing
|
||||
double plasmaCaseHeat = plasmaCaseConductivity * (plasmaTemperature - caseTemperature);
|
||||
double plasmaCaseHeat = plasmaCaseConductivity * (lastPlasmaTemperature - lastCaseTemperature);
|
||||
plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity;
|
||||
caseTemperature += plasmaCaseHeat / caseHeatCapacity;
|
||||
|
||||
//Transfer from casing to water if necessary
|
||||
if(activelyCooled)
|
||||
{
|
||||
double caseWaterHeat = caseWaterConductivity * caseTemperature;
|
||||
int waterToVaporize = (int)(caseWaterHeat / enthalpyOfVaporization);
|
||||
Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water");
|
||||
double caseWaterHeat = caseWaterConductivity * lastCaseTemperature;
|
||||
int waterToVaporize = (int)(steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization);
|
||||
//Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water");
|
||||
waterToVaporize = min(waterToVaporize, min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount()));
|
||||
if(waterToVaporize > 0)
|
||||
{
|
||||
Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water");
|
||||
//Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water");
|
||||
getWaterTank().drain(waterToVaporize, true);
|
||||
getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true);
|
||||
}
|
||||
caseWaterHeat = waterToVaporize * enthalpyOfVaporization;
|
||||
caseWaterHeat = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency;
|
||||
caseTemperature -= caseWaterHeat / caseHeatCapacity;
|
||||
}
|
||||
|
||||
//Transfer from casing to environment
|
||||
double caseAirHeat = caseAirConductivity * caseTemperature;
|
||||
double caseAirHeat = caseAirConductivity * lastCaseTemperature;
|
||||
caseTemperature -= caseAirHeat / caseHeatCapacity;
|
||||
setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency);
|
||||
}
|
||||
|
@ -218,6 +227,30 @@ public class FusionReactor implements IFusionReactor
|
|||
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
|
||||
public double getBufferSize()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,8 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.generators.common.inventory.container.ContainerBioGenerator;
|
||||
import mekanism.generators.common.inventory.container.ContainerHeatGenerator;
|
||||
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.ContainerWindTurbine;
|
||||
import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator;
|
||||
|
@ -119,6 +121,10 @@ public class GeneratorsCommonProxy
|
|||
return new ContainerBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity);
|
||||
case 5:
|
||||
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;
|
||||
|
|
|
@ -132,14 +132,71 @@ public class BlockReactor extends BlockContainer
|
|||
@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)
|
||||
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
||||
{
|
||||
((TileEntityReactorController)tile).formMultiblock();
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item i, CreativeTabs creativetabs, List list)
|
||||
|
@ -210,7 +267,7 @@ public class BlockReactor extends BlockContainer
|
|||
public int guiId;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -57,6 +57,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp
|
|||
if(changed)
|
||||
{
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
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.common.IActiveState;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.generators.common.FusionReactor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
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;
|
||||
|
||||
|
@ -24,6 +35,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock
|
|||
public TileEntityReactorController()
|
||||
{
|
||||
super("ReactorController", 1000000000);
|
||||
inventory = new ItemStack[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,9 +62,83 @@ public class TileEntityReactorController extends TileEntityReactorBlock
|
|||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(getReactor() != null && !worldObj.isRemote)
|
||||
if(getReactor() != null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
|
|||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.util.CableUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
@ -23,7 +24,9 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
|
|||
public TileEntityReactorPort()
|
||||
{
|
||||
super("name", 1);
|
||||
inventory = new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrame()
|
||||
{
|
||||
|
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 10
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue