More Reactor GUI work

This commit is contained in:
Ben Spiers 2014-07-23 01:25:10 +01:00
parent 775ba68482
commit 84daf186ca
10 changed files with 173 additions and 37 deletions

View file

@ -35,4 +35,6 @@ public interface IFusionReactor
public double getBufferSize();
public void formMultiblock();
public boolean isFormed();
}

View file

@ -0,0 +1,48 @@
package mekanism.client.gui;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import static java.lang.Math.min;
public class GuiNumberGauge extends GuiGauge
{
INumberInfoHandler infoHandler;
public GuiNumberGauge(INumberInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y)
{
super(type, gui, def, x, y);
infoHandler = handler;
}
@Override
public int getScaledLevel()
{
return (int)((height-2) * min(infoHandler.getLevel() / infoHandler.getMaxLevel(), 1));
}
@Override
public IIcon getIcon()
{
return infoHandler.getIcon();
}
@Override
public String getTooltipText()
{
return infoHandler.getText(infoHandler.getLevel());
}
public static interface INumberInfoHandler
{
public IIcon getIcon();
public double getLevel();
public double getMaxLevel();
public String getText(double level);
}
}

View file

@ -14,13 +14,13 @@ import io.netty.buffer.ByteBuf;
public class TileEntityLaser extends TileEntityElectricBlock
{
public static final double LASER_ENERGY = 50000;
public static final double LASER_ENERGY = 1E10;
public boolean on;
public TileEntityLaser()
{
super("Laser", 100000);
super("Laser", 2*LASER_ENERGY);
inventory = new ItemStack[0];
}
@ -45,6 +45,7 @@ public class TileEntityLaser extends TileEntityElectricBlock
on = true;
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D));
}
LaserManager.fireLaser(Coord4D.get(this), ForgeDirection.getOrientation(facing), LASER_ENERGY, worldObj);
setEnergy(getEnergy() - LASER_ENERGY);
}

View file

@ -12,20 +12,19 @@ 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.GuiNumberGauge;
import mekanism.client.gui.GuiNumberGauge.INumberInfoHandler;
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.block.BlockStaticLiquid;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -49,7 +48,7 @@ public class GuiReactorController extends GuiMekanism
"Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()),
"Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t");
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
@ -57,7 +56,7 @@ public class GuiReactorController extends GuiMekanism
{
return tentity.deuteriumTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 16));
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 6));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
@ -65,7 +64,7 @@ public class GuiReactorController extends GuiMekanism
{
return tentity.tritiumTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 124, 46));
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 124, 36));
guiElements.add(new GuiGasGauge(new IGasInfoHandler()
{
@Override
@ -73,7 +72,7 @@ public class GuiReactorController extends GuiMekanism
{
return tentity.fuelTank;
}
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 144, 16));
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 6));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()
{
@Override
@ -81,7 +80,7 @@ public class GuiReactorController extends GuiMekanism
{
return tentity.waterTank;
}
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 78, 46));
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 78, 46));
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()
{
@Override
@ -89,9 +88,61 @@ public class GuiReactorController extends GuiMekanism
{
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));
}, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 46));
guiElements.add(new GuiNumberGauge(new INumberInfoHandler()
{
@Override
public IIcon getIcon()
{
return BlockStaticLiquid.getLiquidIcon("lava_still");
}
@Override
public double getLevel()
{
return tileEntity.getPlasmaTemp();
}
@Override
public double getMaxLevel()
{
return 5E8;
}
@Override
public String getText(double level)
{
return "Plasma: " + (int)(level+23) + "C";
}
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall"), 124, 76));
guiElements.add(new GuiNumberGauge(new INumberInfoHandler()
{
@Override
public IIcon getIcon()
{
return BlockStaticLiquid.getLiquidIcon("lava_still");
}
@Override
public double getLevel()
{
return tileEntity.getCaseTemp();
}
@Override
public double getMaxLevel()
{
return 5E8;
}
@Override
public String getText(double level)
{
return "Case: " + (int)(level+23) + "C";
}
}, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 144, 76));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 164, 15));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 98, 26));
}
@Override
@ -99,24 +150,21 @@ public class GuiReactorController extends GuiMekanism
{
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(tileEntity.getInventoryName(), 6, 6, 0x404040);
if(tileEntity.getActive())
{
fontRendererObj.drawString(MekanismUtils.localize("container.reactor.notFormed"), 8, 16, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("container.reactor.formed"), 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);
fontRendererObj.drawString(MekanismUtils.localize("container.reactor.notFormed"), 8, 16, 0x404040);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;

View file

@ -15,9 +15,11 @@ import mekanism.api.reactor.IFusionReactor;
import mekanism.api.reactor.INeutronCapture;
import mekanism.api.reactor.IReactorBlock;
import mekanism.common.Mekanism;
import mekanism.generators.common.item.ItemHohlraum;
import mekanism.generators.common.tile.reactor.TileEntityReactorController;
import net.minecraft.block.Block;
import net.minecraft.item.ItemCoal;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -61,7 +63,6 @@ public class FusionReactor implements IFusionReactor
public static double caseAirConductivity = 0.1;
public boolean burning = false;
public boolean hasHohlraum = false;
public boolean activelyCooled = true;
public boolean formed = false;
@ -77,6 +78,11 @@ public class FusionReactor implements IFusionReactor
plasmaTemperature += energyAdded / plasmaHeatCapacity;
}
public boolean hasHohlraum()
{
return controller != null && controller.inventory[0] != null && controller.inventory[0].getItem() instanceof ItemCoal;
}
@Override
public void simulate()
{
@ -90,7 +96,7 @@ public class FusionReactor implements IFusionReactor
if(plasmaTemperature >= burnTemperature)
{
//If we're not burning yet we need a hohlraum to ignite
if(!burning && hasHohlraum)
if(!burning && hasHohlraum())
{
vaporiseHohlraum();
}
@ -117,7 +123,11 @@ public class FusionReactor implements IFusionReactor
public void vaporiseHohlraum()
{
getFuelTank().receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), 10), true);
hasHohlraum = false;
controller.inventory[0].stackSize -= 1;
if(controller.inventory[0].stackSize == 0)
{
controller.inventory[0] = null;
}
burning = true;
}
@ -391,4 +401,10 @@ public class FusionReactor implements IFusionReactor
return true;
}
public boolean isFormed()
{
return formed;
}
}

View file

@ -21,14 +21,6 @@ public class ContainerReactorController extends Container
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));

View file

@ -0,0 +1,7 @@
package mekanism.generators.common.item;
import mekanism.common.item.ItemMekanism;
public class ItemHohlraum extends ItemMekanism
{
}

View file

@ -57,12 +57,30 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
getReactor().formMultiblock();
}
public double getPlasmaTemp()
{
if(getReactor() == null || !getReactor().isFormed())
{
return 0;
}
return getReactor().getPlasmaTemp();
}
public double getCaseTemp()
{
if(getReactor() == null || !getReactor().isFormed())
{
return 0;
}
return getReactor().getCaseTemp();
}
@Override
public void onUpdate()
{
super.onUpdate();
if(getReactor() != null)
if(getReactor() != null && getReactor().isFormed())
{
getReactor().simulate();
}
@ -73,7 +91,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
{
super.getNetworkedData(data);
data.add(getReactor() != null);
data.add(getReactor() != null && getReactor().isFormed());
if(getReactor() != null)
{
data.add(getReactor().getPlasmaTemp());
@ -100,6 +118,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
setReactor(new FusionReactor(this));
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
((FusionReactor)getReactor()).formed = true;
getReactor().setPlasmaTemp(dataStream.readDouble());
getReactor().setCaseTemp(dataStream.readDouble());
fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()));
@ -118,7 +137,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen
@Override
public boolean getActive()
{
return getReactor() != null;
return getReactor() != null && getReactor().isFormed();
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -655,6 +655,9 @@ tile.Generator.BioGenerator.name=Bio-Generator
tile.Generator.AdvancedSolarGenerator.name=Advanced Solar Generator
tile.Generator.WindTurbine.name=Wind Turbine
//Reactor Blocks
tile.Reactor.ReactorController.name=Reactor Controller
//Gui text
gui.heatGenerator.fuel=Fuel
gui.solarGenerator.sun=Sun