diff --git a/src/main/java/mekanism/api/MekanismConfig.java b/src/main/java/mekanism/api/MekanismConfig.java index d1e88cf34..e555e62a7 100644 --- a/src/main/java/mekanism/api/MekanismConfig.java +++ b/src/main/java/mekanism/api/MekanismConfig.java @@ -45,8 +45,6 @@ public class MekanismConfig public static boolean blacklistIC2; public static boolean blacklistRF; public static boolean destroyDisabledBlocks; - public static boolean enableAmbientLighting; - public static int ambientLightingLevel; public static boolean prefilledPortableTanks; public static double armoredJetpackDamageRatio; public static int armoredJetpackDamageMax; @@ -59,6 +57,10 @@ public class MekanismConfig public static int maxPumpRange; public static boolean pumpWaterSources; public static int maxPlenisherNodes; + public static double evaporationHeatDissipation = 0.02; + public static double evaporationTempMultiplier = 0.1; + public static double evaporationSolarMultiplier = 0.2; + public static double evaporationMaxTemp = 3000; } public static class client @@ -72,6 +74,8 @@ public class MekanismConfig public static boolean oldTransmitterRender = false; public static boolean replaceSoundsWhenResuming = true; public static boolean renderCTM = true; + public static boolean enableAmbientLighting; + public static int ambientLightingLevel; } public static class machines diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 04aff8781..3f72dab60 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -212,6 +212,8 @@ public class ClientProxy extends CommonProxy client.replaceSoundsWhenResuming = Mekanism.configuration.get("client", "ReplaceSoundsWhenResuming", true, "If true, will reduce lagging between player sounds. Setting to false will reduce GC load").getBoolean(); client.renderCTM = Mekanism.configuration.get("client", "CTMRenderer", true).getBoolean(); + client.enableAmbientLighting = Mekanism.configuration.get("general", "EnableAmbientLighting", true).getBoolean(); + client.ambientLightingLevel = Mekanism.configuration.get("general", "AmbientLightingLevel", 15).getInt(); if(Mekanism.configuration.hasChanged()) { diff --git a/src/main/java/mekanism/client/gui/GuiSolarEvaporationController.java b/src/main/java/mekanism/client/gui/GuiSolarEvaporationController.java index e4ce3a3b2..559bdbca1 100644 --- a/src/main/java/mekanism/client/gui/GuiSolarEvaporationController.java +++ b/src/main/java/mekanism/client/gui/GuiSolarEvaporationController.java @@ -1,18 +1,15 @@ package mekanism.client.gui; -import mekanism.api.gas.GasStack; import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; import mekanism.client.gui.element.GuiFluidGauge; -import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; -import mekanism.client.render.MekanismRenderer; +import mekanism.client.gui.element.GuiGauge; import mekanism.common.inventory.container.ContainerSolarEvaporationController; import mekanism.common.tile.TileEntitySolarEvaporationController; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import org.lwjgl.opengl.GL11; @@ -57,8 +54,8 @@ public class GuiSolarEvaporationController extends GuiMekanism fontRendererObj.drawString(getStruct(), 50, 21, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.height") + ": " + tileEntity.height, 50, 30, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.mult") + ": " + getTempMult(), 50, 39, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.max") + ": " + getMaxTemp(), 50, 48, 0x00CD00); + fontRendererObj.drawString(LangUtils.localize("gui.temp") + ": " + getTemp(), 50, 39, 0x00CD00); + renderScaledText(LangUtils.localize("gui.production") + ": " + Math.round(tileEntity.lastGain*100D)/100D + " mB/t", 50, 48, 0x00CD00, 76); if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { @@ -97,25 +94,11 @@ public class GuiSolarEvaporationController extends GuiMekanism private String getTemp() { - float temp = tileEntity.getTemperature()*200; + float temp = tileEntity.getTemperature(); return MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.AMBIENT); } - private String getMaxTemp() - { - float temp = tileEntity.getMaxTemperature()*200; - - return MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.AMBIENT); - } - - private String getTempMult() - { - float temp = (float)Math.round((tileEntity.getTempMultiplier())*10)/10F; - - return temp + "x"; - } - @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { diff --git a/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java b/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java index aa84186a0..2c4044d38 100644 --- a/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java +++ b/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java @@ -59,7 +59,7 @@ public class GuiEnergyInfo extends GuiElement info.add(s); } - info.add(LangUtils.localize("gui.energyType") + ": " + general.activeType); + info.add(LangUtils.localize("gui.unit") + ": " + general.activeType); displayTooltips(info, xAxis, yAxis); } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index e2bbede42..85f89e79d 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -270,6 +270,10 @@ public class CommonProxy implements IGuiProvider general.maxPumpRange = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPumpRange", 80).getInt(); general.pumpWaterSources = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PumpWaterSources", false).getBoolean(); general.maxPlenisherNodes = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPlenisherNodes", 4000).getInt(); + general.evaporationHeatDissipation = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationHeatDissipation", 0.02D).getDouble(); + general.evaporationTempMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationTempMultiplier", 0.1D).getDouble(); + general.evaporationSolarMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationSolarMultiplier", 0.2D).getDouble(); + general.evaporationMaxTemp = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationMaxTemp", 3000D).getDouble(); general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean(); general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean(); @@ -325,8 +329,7 @@ public class CommonProxy implements IGuiProvider general.laserRange = Mekanism.configuration.get("general", "LaserRange", 64).getInt(); general.laserEnergyNeededPerHardness = Mekanism.configuration.get("general", "LaserDiggingEnergy", 100000).getInt(); general.destroyDisabledBlocks = Mekanism.configuration.get("general", "DestroyDisabledBlocks", true).getBoolean(); - general.enableAmbientLighting = Mekanism.configuration.get("general", "EnableAmbientLighting", true).getBoolean(); - general.ambientLightingLevel = Mekanism.configuration.get("general", "AmbientLightingLevel", 15).getInt(); + for(MachineType type : MachineType.getValidMachines()) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index f0f87191f..02a75bace 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -377,7 +377,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - if(general.enableAmbientLighting) + if(client.enableAmbientLighting) { TileEntity tileEntity = world.getTileEntity(x, y, z); @@ -385,7 +385,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo { if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) { - return general.ambientLightingLevel; + return client.ambientLightingLevel; } } } diff --git a/src/main/java/mekanism/common/network/PacketConfigSync.java b/src/main/java/mekanism/common/network/PacketConfigSync.java index 0fe54b856..fd3621a7a 100644 --- a/src/main/java/mekanism/common/network/PacketConfigSync.java +++ b/src/main/java/mekanism/common/network/PacketConfigSync.java @@ -29,7 +29,6 @@ public class PacketConfigSync implements IMessageHandler= 1) { @@ -116,6 +128,9 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora partialOutput %= 1; } } + else { + lastGain = 0; + } if(structured) { @@ -183,8 +198,6 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora { inputTank.getFluid().amount = Math.min(inputTank.getFluid().amount, getMaxFluid()); } - - temperature = Math.min(getMaxTemperature(), getTemperature()); } else { clearStructure(); @@ -195,7 +208,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora public boolean canOperate(SolarEvaporationRecipe recipe) { - if(!structured || height < 3 || height > 18 || inputTank.getFluid() == null) + if(!structured || height < 3 || height > MAX_HEIGHT || inputTank.getFluid() == null) { return false; } @@ -308,35 +321,6 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora } private void updateTemperature() - { - float max = getMaxTemperature(); - float incr = (max/WARMUP)*getTempMultiplier(); - - if(getTempMultiplier() == 0) - { - temperature = Math.max(0, getTemperature()-(max/(WARMUP*16))); - } - else { - temperature = Math.min(max, getTemperature()+incr); - } - } - - public float getTemperature() - { - return temperature; - } - - public float getMaxTemperature() - { - if(!structured) - { - return 0; - } - - return 1 + (height-3)*(float)general.solarEvaporationSpeed; - } - - public float getTempMultiplier() { if(!temperatureSet) { @@ -344,7 +328,30 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora temperatureSet = true; } - return biomeTemp*((float)getActiveSolars()/MAX_SOLARS); + tempToAdd += getActiveSolars()*general.evaporationSolarMultiplier.getDouble(); + temperature += tempToAdd/(float)height; + + float biome = biomeTemp-0.5F; + float base = biome > 0 ? biome*20 : biomeTemp*40; + float incr = (float)Math.sqrt(Math.abs(temperature-base))*(float)general.evaporationHeatDissipation.getDouble(); + + if(temperature > base) + { + incr = -incr; + } + + System.out.println(incr + " " + biome + " " + base); + + temperature = (float)Math.min(general.evaporationMaxTemp.getDouble(), temperature + incr/(float)height); + + tempToAdd = 0; + + MekanismUtils.saveChunk(this); + } + + public float getTemperature() + { + return temperature; } public int getActiveSolars() @@ -402,7 +409,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora middlePointer = middlePointer.getFromSide(ForgeDirection.DOWN); } - if(height < 3 || height > 18) + if(height < 3 || height > MAX_HEIGHT) { height = 0; return false; @@ -587,7 +594,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora public int getScaledTempLevel(int i) { - return (int)(getMaxTemperature() == 0 ? 0 : getTemperature()*i/getMaxTemperature()); + return (int)(i*Math.min(1, getTemperature()/general.evaporationMaxTemp.getDouble())); } public Coord4D getRenderLocation() @@ -637,6 +644,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora temperature = dataStream.readFloat(); biomeTemp = dataStream.readFloat(); isLeftOnFace = dataStream.readBoolean(); + lastGain = dataStream.readFloat(); if(structured != prev) { @@ -690,6 +698,7 @@ public class TileEntitySolarEvaporationController extends TileEntitySolarEvapora data.add(temperature); data.add(biomeTemp); data.add(isLeftOnFace); + data.add(lastGain); return data; } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 6cb6dba1d..34b22e476 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1186,6 +1186,7 @@ public final class MekanismUtils public static String getTemperatureDisplay(double T, TemperatureUnit unit) { double TK = unit.convertToK(T); + switch(general.tempUnit) { case K: diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java index b82df8792..dace1b195 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -8,24 +8,23 @@ import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiEnergyInfo; -import mekanism.client.gui.element.GuiGasGauge; -import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; +import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGauge.Type; +import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.gui.element.GuiHeatTab; import mekanism.generators.client.gui.element.GuiStatTab; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; @@ -160,7 +159,7 @@ public class GuiReactorFuel extends GuiMekanism if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound("gui.button.press"); - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 10)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); } } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java index ee232ee98..ba1d16d8a 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -9,36 +9,37 @@ import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiEnergyGauge; -import mekanism.client.gui.element.GuiEnergyInfo; -import mekanism.client.gui.element.GuiFluidGauge; -import mekanism.client.gui.element.GuiNumberGauge; -import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiEnergyGauge.IEnergyInfoHandler; +import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; +import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; import mekanism.client.gui.element.GuiGauge.Type; +import mekanism.client.gui.element.GuiNumberGauge; import mekanism.client.gui.element.GuiNumberGauge.INumberInfoHandler; +import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.gui.element.GuiFuelTab; import mekanism.generators.client.gui.element.GuiStatTab; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; 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; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class GuiReactorHeat extends GuiMekanism { @@ -206,9 +207,8 @@ public class GuiReactorHeat extends GuiMekanism if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound("gui.button.press"); - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 10)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); } - } } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java index 1a31c6f4f..e746ce4b3 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java @@ -8,25 +8,26 @@ import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; +import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler; -import mekanism.client.gui.GuiMekanism; import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; import mekanism.common.inventory.container.ContainerNull; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.gui.element.GuiFuelTab; import mekanism.generators.client.gui.element.GuiHeatTab; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class GuiReactorStats extends GuiMekanism { @@ -113,7 +114,7 @@ public class GuiReactorStats extends GuiMekanism if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound("gui.button.press"); - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 10)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); } } }} diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java index 68d663b5f..81e5232bd 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java @@ -4,16 +4,16 @@ import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import codechicken.lib.vec.Rectangle4i; @SideOnly(Side.CLIENT) public class GuiFuelTab extends GuiElement @@ -74,7 +74,7 @@ public class GuiFuelTab extends GuiElement { if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 12)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 12)); SoundHandler.playSound("gui.button.press"); } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java index 5f926664b..a0de61479 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java @@ -4,16 +4,16 @@ import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import codechicken.lib.vec.Rectangle4i; @SideOnly(Side.CLIENT) public class GuiHeatTab extends GuiElement @@ -74,7 +74,7 @@ public class GuiHeatTab extends GuiElement { if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 11)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 11)); SoundHandler.playSound("gui.button.press"); } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java index 87e268ee5..e3c9784e9 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java @@ -4,16 +4,16 @@ import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; import mekanism.client.sound.SoundHandler; +import mekanism.common.Mekanism; +import mekanism.common.network.PacketSimpleGui.SimpleGuiMessage; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; +import codechicken.lib.vec.Rectangle4i; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import codechicken.lib.vec.Rectangle4i; @SideOnly(Side.CLIENT) public class GuiStatTab extends GuiElement @@ -74,7 +74,7 @@ public class GuiStatTab extends GuiElement { if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { - MekanismGenerators.packetHandler.sendToServer(new GeneratorsGuiMessage(Coord4D.get(tileEntity), 13)); + Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 13)); SoundHandler.playSound("gui.button.press"); } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java b/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java deleted file mode 100644 index 8ee96c4e7..000000000 --- a/src/main/java/mekanism/generators/common/GeneratorsPacketHandler.java +++ /dev/null @@ -1,183 +0,0 @@ -package mekanism.generators.common; - -import java.util.ArrayList; -import java.util.List; - -import mekanism.common.Mekanism; -import mekanism.generators.common.network.PacketGeneratorsGui; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Vec3; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import cpw.mods.fml.relauncher.Side; - -import io.netty.buffer.ByteBuf; - -/** - * Mekanism packet handler. As always, use packets sparingly! - * @author AidanBrady - * - */ -public class GeneratorsPacketHandler -{ - public SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel("MEKGEN"); - - public void initialize() - { - netHandler.registerMessage(PacketGeneratorsGui.class, GeneratorsGuiMessage.class, 0, Side.SERVER); - netHandler.registerMessage(PacketGeneratorsGui.class, GeneratorsGuiMessage.class, 0, Side.CLIENT); - } - - /** - * Encodes an Object[] of data into a DataOutputStream. - * @param dataValues - an Object[] of data to encode - * @param output - the output stream to write to - */ - public static void encode(Object[] dataValues, ByteBuf output) - { - try { - for(Object data : dataValues) - { - if(data instanceof Integer) - { - output.writeInt((Integer)data); - } - else if(data instanceof Boolean) - { - output.writeBoolean((Boolean)data); - } - else if(data instanceof Double) - { - output.writeDouble((Double)data); - } - else if(data instanceof Float) - { - output.writeFloat((Float)data); - } - else if(data instanceof String) - { - writeString(output, (String)data); - } - else if(data instanceof Byte) - { - output.writeByte((Byte)data); - } - else if(data instanceof int[]) - { - for(int i : (int[])data) - { - output.writeInt(i); - } - } - else if(data instanceof byte[]) - { - for(byte b : (byte[])data) - { - output.writeByte(b); - } - } - else if(data instanceof ArrayList) - { - encode(((ArrayList)data).toArray(), output); - } - } - } catch(Exception e) { - Mekanism.logger.error("Error while encoding packet data."); - e.printStackTrace(); - } - } - - public static void writeString(ByteBuf output, String s) - { - output.writeInt(s.getBytes().length); - output.writeBytes(s.getBytes()); - } - - public static String readString(ByteBuf input) - { - return new String(input.readBytes(input.readInt()).array()); - } - - public static EntityPlayer getPlayer(MessageContext context) - { - return Mekanism.proxy.getPlayer(context); - } - - /** - * Send this message to everyone. - * @param message - the message to send - */ - public void sendToAll(IMessage message) - { - netHandler.sendToAll(message); - } - - /** - * Send this message to the specified player. - * @param message - the message to send - * @param player - the player to send it to - */ - public void sendTo(IMessage message, EntityPlayerMP player) - { - netHandler.sendTo(message, player); - } - - /** - * Send this message to everyone within a certain range of a point. - * - * @param message - the message to send - * @param point - the TargetPoint around which to send - */ - public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) - { - netHandler.sendToAllAround(message, point); - } - - /** - * Send this message to everyone within the supplied dimension. - * @param message - the message to send - * @param dimensionId - the dimension id to target - */ - public void sendToDimension(IMessage message, int dimensionId) - { - netHandler.sendToDimension(message, dimensionId); - } - - /** - * Send this message to the server. - * @param message - the message to send - */ - public void sendToServer(IMessage message) - { - netHandler.sendToServer(message); - } - - /** - * Send this message to all players within a defined AABB cuboid. - * @param message - the message to send - * @param cuboid - the AABB cuboid to send the packet in - * @param dimId - the dimension the cuboid is in - */ - public void sendToCuboid(IMessage message, AxisAlignedBB cuboid, int dimId) - { - MinecraftServer server = MinecraftServer.getServer(); - - if(server != null && cuboid != null) - { - for(EntityPlayerMP player : (List)server.getConfigurationManager().playerEntityList) - { - if(player.dimension == dimId && cuboid.isVecInside(Vec3.createVectorHelper(player.posX, player.posY, player.posZ))) - { - sendTo(message, player); - } - } - } - } -} diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index ba1d2588a..7526b1f43 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -45,9 +45,6 @@ import cpw.mods.fml.common.network.NetworkRegistry; @Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "9.0.0", dependencies = "required-after:Mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory") public class MekanismGenerators implements IModule { - /** Mekanism Generators Packet Pipeline */ - public static GeneratorsPacketHandler packetHandler = new GeneratorsPacketHandler(); - @SidedProxy(clientSide = "mekanism.generators.client.GeneratorsClientProxy", serverSide = "mekanism.generators.common.GeneratorsCommonProxy") public static GeneratorsCommonProxy proxy; @@ -71,8 +68,6 @@ public class MekanismGenerators implements IModule { //Add this module to the core list Mekanism.modulesLoaded.add(this); - - packetHandler.initialize(); //Register this module's GUI handler in the simple packet protocol PacketSimpleGui.handlers.add(1, proxy); @@ -207,10 +202,17 @@ public class MekanismGenerators implements IModule dataStream.writeDouble(generators.heatGenerationLava); dataStream.writeDouble(generators.heatGenerationNether); dataStream.writeDouble(generators.solarGeneration); + dataStream.writeDouble(generators.windGenerationMin); dataStream.writeDouble(generators.windGenerationMax); + dataStream.writeInt(generators.windGenerationMinY); dataStream.writeInt(generators.windGenerationMaxY); + + dataStream.writeInt(generators.turbineBladesPerCoil); + dataStream.writeDouble(generators.turbineBaseEnergyPerSteam); + dataStream.writeDouble(generators.turbineVentGasFlow); + dataStream.writeDouble(generators.turbineDisperserGasFlow); } @Override @@ -222,10 +224,17 @@ public class MekanismGenerators implements IModule generators.heatGenerationLava = dataStream.readDouble(); generators.heatGenerationNether = dataStream.readDouble(); generators.solarGeneration = dataStream.readDouble(); + generators.windGenerationMin = dataStream.readDouble(); generators.windGenerationMax = dataStream.readDouble(); + generators.windGenerationMinY = dataStream.readInt(); generators.windGenerationMaxY = dataStream.readInt(); + + generators.turbineBladesPerCoil = dataStream.readInt(); + generators.turbineBaseEnergyPerSteam = dataStream.readDouble(); + generators.turbineVentGasFlow = dataStream.readDouble(); + generators.turbineDisperserGasFlow = dataStream.readDouble(); } @SubscribeEvent diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index f2725b45f..543528b55 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; import mekanism.common.CTMData; @@ -231,7 +232,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - if(general.enableAmbientLighting) + if(client.enableAmbientLighting) { TileEntity tileEntity = world.getTileEntity(x, y, z); @@ -239,7 +240,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IB { if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) { - return general.ambientLightingLevel; + return client.ambientLightingLevel; } } } diff --git a/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java b/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java deleted file mode 100644 index 21fe4fcc2..000000000 --- a/src/main/java/mekanism/generators/common/network/PacketGeneratorsGui.java +++ /dev/null @@ -1,115 +0,0 @@ -package mekanism.generators.common.network; - -import mekanism.api.Coord4D; -import mekanism.common.tile.TileEntityBasicBlock; -import mekanism.generators.common.GeneratorsPacketHandler; -import mekanism.generators.common.MekanismGenerators; -import mekanism.generators.common.network.PacketGeneratorsGui.GeneratorsGuiMessage; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import io.netty.buffer.ByteBuf; - -public class PacketGeneratorsGui implements IMessageHandler -{ - @Override - public IMessage onMessage(GeneratorsGuiMessage message, MessageContext context) - { - EntityPlayer player = GeneratorsPacketHandler.getPlayer(context); - - if(!player.worldObj.isRemote) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); - - if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock) - { - if(message.guiId == -1) - { - return null; - } - - GeneratorsGuiMessage.openServerGui(message.guiId, (EntityPlayerMP)player, player.worldObj, message.coord4D); - } - } - else { - FMLCommonHandler.instance().showGuiScreen(GeneratorsGuiMessage.getGui(message.guiId, player, player.worldObj, message.coord4D)); - player.openContainer.windowId = message.windowId; - } - - return null; - } - - public static class GeneratorsGuiMessage implements IMessage - { - public Coord4D coord4D; - - public int guiId; - - public int windowId; - - public GeneratorsGuiMessage() {} - - public GeneratorsGuiMessage(Coord4D coord, int gui) - { - coord4D = coord; - guiId = gui; - } - - public GeneratorsGuiMessage(Coord4D coord, int gui, int id) - { - this(coord, gui); - windowId = id; - } - - public static void openServerGui(int id, EntityPlayerMP playerMP, World world, Coord4D obj) - { - playerMP.closeContainer(); - playerMP.getNextWindowId(); - - int window = playerMP.currentWindowId; - - MekanismGenerators.packetHandler.sendTo(new GeneratorsGuiMessage(obj, id, window), playerMP); - - playerMP.openContainer = MekanismGenerators.proxy.getServerGui(id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord); - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - } - - @SideOnly(Side.CLIENT) - public static GuiScreen getGui(int id, EntityPlayer player, World world, Coord4D obj) - { - return (GuiScreen)MekanismGenerators.proxy.getClientGui(id, player, world, obj.xCoord, obj.yCoord, obj.zCoord); - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(guiId); - dataStream.writeInt(windowId); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - guiId = dataStream.readInt(); - windowId = dataStream.readInt(); - } - } -} diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index ff6ca90b0..a9292d522 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -497,7 +497,8 @@ gui.maxProduction=Max Production gui.limiting=Limiting gui.steamInput=Steam Input gui.capacity=Capacity -gui.energyType=Energy Type +gui.unit=Unit +gui.temp=Temp gui.reactor.injectionRate=Injection Rate