mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-21 20:42:17 +00:00
Merge branch 'development' into 1.8 (hopefully I didn't miss anything)
Conflicts: src/main/java/mekanism/client/gui/GuiGasTank.java src/main/java/mekanism/client/gui/GuiPortableTeleporter.java src/main/java/mekanism/client/gui/GuiTeleporter.java src/main/java/mekanism/common/CommonProxy.java src/main/java/mekanism/common/Mekanism.java src/main/java/mekanism/common/content/transporter/TransporterStack.java
This commit is contained in:
commit
9bf4baab49
19 files changed
+980
-136
No files matched your search
@@ -75,6 +75,7 @@ public class MekanismConfig
|
||||
public static double pressurizedReactionBaseUsage;
|
||||
public static double fluidicPlenisherUsage;
|
||||
public static double laserUsage;
|
||||
public static double salinationPlantWaterUsage;
|
||||
}
|
||||
|
||||
public static class generators
|
||||
|
||||
@@ -226,7 +226,10 @@ public class GasTank
|
||||
stored = GasStack.readFromNBT(nbtTags.getCompoundTag("stored"));
|
||||
}
|
||||
|
||||
maxGas = nbtTags.getInteger("maxGas");
|
||||
if(nbtTags.hasKey("maxGas"))
|
||||
{
|
||||
maxGas = nbtTags.getInteger("maxGas");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
@@ -10,11 +12,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
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)
|
||||
@@ -37,17 +35,18 @@ public class GuiGasTank extends GuiMekanism
|
||||
|
||||
String capacityInfo = tileEntity.gasTank.getStored() + "/" + tileEntity.MAX_GAS;
|
||||
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
|
||||
fontRendererObj.drawString(capacityInfo, 45, 40, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : MekanismUtils.localize("gui.none")), 45, 49, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
String name = tileEntity.dumping ? MekanismUtils.localize("gui.dumping") + "..." : MekanismUtils.localize("gui.idle");
|
||||
fontRendererObj.drawString(name, 156-fontRendererObj.getStringWidth(name), 73, 0x404040);
|
||||
String name = chooseByMode(tileEntity.dumping, MekanismUtils.localize("gui.idle"), MekanismUtils.localize("gui.dumping"), MekanismUtils.localize("gui.dumping_excess"));
|
||||
fontRendererObj.drawString(name, 156 - fontRendererObj.getStringWidth(name), 73, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
@@ -59,7 +58,7 @@ public class GuiGasTank extends GuiMekanism
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int displayInt = tileEntity.dumping ? 18 : 10;
|
||||
int displayInt = chooseByMode(tileEntity.dumping, 10, 18, 26);
|
||||
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8);
|
||||
|
||||
if(tileEntity.gasTank.getGas() != null)
|
||||
@@ -86,4 +85,21 @@ public class GuiGasTank extends GuiMekanism
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T chooseByMode(TileEntityGasTank.Mode dumping, T idleOption, T dumpingOption, T dumpingExcessOption)
|
||||
{
|
||||
if(dumping.equals(TileEntityGasTank.Mode.IDLE))
|
||||
{
|
||||
return idleOption;
|
||||
}
|
||||
if(dumping.equals(TileEntityGasTank.Mode.DUMPING))
|
||||
{
|
||||
return dumpingOption;
|
||||
}
|
||||
if(dumping.equals(TileEntityGasTank.Mode.DUMPING_EXCESS))
|
||||
{
|
||||
return dumpingExcessOption;
|
||||
}
|
||||
return idleOption; //should not happen;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package mekanism.client.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
@@ -7,14 +9,10 @@ import mekanism.common.network.PacketDigitUpdate.DigitUpdateMessage;
|
||||
import mekanism.common.network.PacketPortableTeleport.PortableTeleportMessage;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -49,23 +47,23 @@ public class GuiPortableTeleporter extends GuiScreen
|
||||
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
int guiWidth = (width-xSize)/2;
|
||||
int guiHeight = (height-ySize)/2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int displayInt;
|
||||
|
||||
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0));
|
||||
drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+23, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1));
|
||||
drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+62, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2));
|
||||
drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+101, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3));
|
||||
drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+140, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem();
|
||||
|
||||
@@ -93,41 +91,37 @@ public class GuiPortableTeleporter extends GuiScreen
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
int xAxis = (mouseX-(width-xSize)/2);
|
||||
int yAxis = (mouseY-(height-ySize)/2);
|
||||
|
||||
if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58)
|
||||
handleButtonClick(xAxis, yAxis, button, 0, 23, 37, 44, 58);
|
||||
handleButtonClick(xAxis, yAxis, button, 1, 62, 76, 44, 58);
|
||||
handleButtonClick(xAxis, yAxis, button, 2, 101, 115, 44, 58);
|
||||
handleButtonClick(xAxis, yAxis, button, 3, 140, 154, 44, 58);
|
||||
}
|
||||
|
||||
private void handleButtonClick(int xAxis, int yAxis, int mouseButton, int clickedButtonIndex, int xmin, int xmax, int ymin, int ymax)
|
||||
{
|
||||
if(xAxis > xmin && xAxis < xmax && yAxis > ymin && yAxis < ymax)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0))));
|
||||
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)));
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1))));
|
||||
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1)));
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2))));
|
||||
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2)));
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58)
|
||||
{
|
||||
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3))));
|
||||
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3)));
|
||||
int currentDigit = ((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, clickedButtonIndex);
|
||||
int updatedDigit = getUpdatedNumber(currentDigit, mouseButton);
|
||||
Mekanism.packetHandler.sendToServer(new DigitUpdateMessage(clickedButtonIndex, updatedDigit));
|
||||
((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, clickedButtonIndex, updatedDigit);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
}
|
||||
|
||||
public int getIncrementedNumber(int i)
|
||||
public int getUpdatedNumber(int i, int mouseButton)
|
||||
{
|
||||
if(i < 9) i++;
|
||||
else if(i == 9) i=0;
|
||||
|
||||
return i;
|
||||
if(mouseButton == 1) //right click
|
||||
{
|
||||
return (i-1+10)%10; //add 10 to ensure postive result
|
||||
}
|
||||
else
|
||||
{
|
||||
return (i+1)%10;
|
||||
}
|
||||
}
|
||||
|
||||
public int getYAxisForNumber(int i)
|
||||
|
||||
@@ -2,6 +2,8 @@ package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.gui.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.GuiSlot.SlotType;
|
||||
@@ -12,11 +14,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
|
||||
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)
|
||||
@@ -36,11 +34,11 @@ public class GuiTeleporter extends GuiMekanism
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
int xAxis = (mouseX-(width-xSize)/2);
|
||||
int yAxis = (mouseY-(height-ySize)/2);
|
||||
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize-96)+2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getStatusDisplay(), 66, 19, 0x00CD00);
|
||||
|
||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
||||
@@ -56,47 +54,71 @@ public class GuiTeleporter extends GuiMekanism
|
||||
{
|
||||
super.mouseClicked(x, y, button);
|
||||
|
||||
int xAxis = (x - (width - xSize) / 2);
|
||||
int yAxis = (y - (height - ySize) / 2);
|
||||
int xAxis = (x-(width-xSize)/2);
|
||||
int yAxis = (y-(height-ySize)/2);
|
||||
|
||||
ArrayList data = new ArrayList();
|
||||
handleButtonClick(xAxis, yAxis, button, 23, 37, 44, 58, 0);
|
||||
handleButtonClick(xAxis, yAxis, button, 62, 76, 44, 58, 1);
|
||||
handleButtonClick(xAxis, yAxis, button, 101, 115, 44, 58, 2);
|
||||
handleButtonClick(xAxis, yAxis, button, 140, 154, 44, 58, 3);
|
||||
}
|
||||
|
||||
if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58)
|
||||
private void handleButtonClick(int xAxis, int yAxis, int mouseButton, int xmin, int xmax, int ymin, int ymax, int buttonIndex)
|
||||
{
|
||||
if(xAxis > xmin && xAxis < xmax && yAxis > ymin && yAxis < ymax)
|
||||
{
|
||||
data.add(0);
|
||||
data.add(getIncrementedNumber(tileEntity.code.digitOne));
|
||||
ArrayList data = new ArrayList();
|
||||
|
||||
int incrementedNumber = getUpdatedNumber(getButtonValue(buttonIndex), mouseButton);
|
||||
|
||||
data.add(buttonIndex);
|
||||
data.add(incrementedNumber);
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
tileEntity.code.digitOne = getIncrementedNumber(tileEntity.code.digitOne);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
setButton(buttonIndex, incrementedNumber);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58)
|
||||
{
|
||||
data.add(1);
|
||||
data.add(getIncrementedNumber(tileEntity.code.digitTwo));
|
||||
}
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
tileEntity.code.digitTwo = getIncrementedNumber(tileEntity.code.digitTwo);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58)
|
||||
public void setButton(int index, int number)
|
||||
{
|
||||
if(index == 0)
|
||||
{
|
||||
data.add(2);
|
||||
data.add(getIncrementedNumber(tileEntity.code.digitThree));
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
tileEntity.code.digitThree = getIncrementedNumber(tileEntity.code.digitThree);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
tileEntity.code.digitOne = number;
|
||||
}
|
||||
else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58)
|
||||
if(index == 1)
|
||||
{
|
||||
data.add(3);
|
||||
data.add(getIncrementedNumber(tileEntity.code.digitFour));
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
tileEntity.code.digitFour = getIncrementedNumber(tileEntity.code.digitFour);
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
tileEntity.code.digitTwo = number;
|
||||
}
|
||||
if(index == 2)
|
||||
{
|
||||
tileEntity.code.digitThree = number;
|
||||
}
|
||||
if(index == 3)
|
||||
{
|
||||
tileEntity.code.digitFour = number;
|
||||
}
|
||||
}
|
||||
|
||||
public int getButtonValue(int index)
|
||||
{
|
||||
if(index == 0)
|
||||
{
|
||||
return tileEntity.code.digitOne;
|
||||
}
|
||||
if(index == 1)
|
||||
{
|
||||
return tileEntity.code.digitTwo;
|
||||
}
|
||||
if(index == 2)
|
||||
{
|
||||
return tileEntity.code.digitThree;
|
||||
}
|
||||
if(index == 3)
|
||||
{
|
||||
return tileEntity.code.digitFour;
|
||||
}
|
||||
return 0;//should never happen
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,41 +126,39 @@ public class GuiTeleporter extends GuiMekanism
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
int guiWidth = (width-xSize)/2;
|
||||
int guiHeight = (height-ySize)/2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
int displayInt;
|
||||
|
||||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
||||
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 13, 52 - displayInt, 4, displayInt);
|
||||
drawTexturedModalRect(guiWidth+165, guiHeight+17+52-displayInt, 176+13, 52-displayInt, 4, displayInt);
|
||||
|
||||
displayInt = getYAxisForNumber(tileEntity.code.digitOne);
|
||||
drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+23, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(tileEntity.code.digitTwo);
|
||||
drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+62, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(tileEntity.code.digitThree);
|
||||
drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+101, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
displayInt = getYAxisForNumber(tileEntity.code.digitFour);
|
||||
drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13);
|
||||
drawTexturedModalRect(guiWidth+140, guiHeight+44, 176, displayInt, 13, 13);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public int getIncrementedNumber(int i)
|
||||
public int getUpdatedNumber(int i, int mouseButton)
|
||||
{
|
||||
if(i < 9)
|
||||
if(mouseButton == 1) //right click
|
||||
{
|
||||
i++;
|
||||
return (i-1+10)%10; //add 10 to ensure postive result
|
||||
}
|
||||
else if(i == 9)
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
return (i+1)%10;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getYAxisForNumber(int i)
|
||||
|
||||
@@ -210,7 +210,7 @@ public class CommonProxy
|
||||
general.TO_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D).getDouble(.1D);
|
||||
general.FROM_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToMJ", 25D).getDouble(25D);
|
||||
general.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04D).getDouble(.04D);
|
||||
general.FROM_H2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HydrogenEnergyDensity", 200D, "THIS DETERMINES ELECTROLYTIC SEPARATOR USAGE").getDouble(200D);
|
||||
general.FROM_H2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HydrogenEnergyDensity", 200D, "Determines Electrolytic Separator usage").getDouble(200D);
|
||||
general.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D);
|
||||
general.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535).getInt();
|
||||
//If this is less than 1, upgrades make machines worse. If less than 0, I don't even know.
|
||||
@@ -266,6 +266,7 @@ public class CommonProxy
|
||||
usage.pressurizedReactionBaseUsage = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D).getDouble(5D);
|
||||
usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D);
|
||||
usage.laserUsage = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(5000D);
|
||||
usage.salinationPlantWaterUsage = Mekanism.configuration.get("usage", "SalinationPlantSpeed", 40.0, "Millibuckets of water turned into brine by the plant per tick", 1.0, 9000.0).getDouble();
|
||||
|
||||
if(Mekanism.configuration.hasChanged())
|
||||
{
|
||||
|
||||
@@ -219,6 +219,19 @@ public class BlockGasTank extends BlockContainer
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int par5)
|
||||
{
|
||||
TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z);
|
||||
return tileEntity.getRedstoneLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection[] getValidRotations(World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ public class TransporterManager
|
||||
testInv[i] = toInsert;
|
||||
return;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -188,7 +188,7 @@ public class TransporterManager
|
||||
testInv[slotID] = toInsert;
|
||||
return;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -288,7 +288,7 @@ public class TransporterManager
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -326,7 +326,7 @@ public class TransporterManager
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package mekanism.common.content.transporter;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.content.transporter.TransporterPathfinder.Destination;
|
||||
import mekanism.common.tile.TileEntityLogisticalSorter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TransporterStack
|
||||
{
|
||||
public ItemStack itemStack;
|
||||
@@ -66,9 +64,7 @@ public class TransporterStack
|
||||
|
||||
getPrev(tileEntity).write(data);
|
||||
|
||||
data.add(MekanismUtils.getID(itemStack));
|
||||
data.add(itemStack.stackSize);
|
||||
data.add(itemStack.getItemDamage());
|
||||
data.add(itemStack);
|
||||
}
|
||||
|
||||
public void read(ByteBuf dataStream)
|
||||
@@ -94,7 +90,7 @@ public class TransporterStack
|
||||
|
||||
clientPrev = Coord4D.read(dataStream);
|
||||
|
||||
itemStack = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt());
|
||||
itemStack = PacketHandler.readStack(dataStream);
|
||||
}
|
||||
|
||||
public void write(NBTTagCompound nbtTags)
|
||||
|
||||
@@ -69,6 +69,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeDouble(usage.chemicalCrystallizerUsage);
|
||||
dataStream.writeDouble(usage.seismicVibratorUsage);
|
||||
dataStream.writeDouble(usage.fluidicPlenisherUsage);
|
||||
dataStream.writeDouble(usage.salinationPlantWaterUsage);
|
||||
|
||||
try {
|
||||
for(IModule module : Mekanism.modulesLoaded)
|
||||
@@ -127,6 +128,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
usage.chemicalCrystallizerUsage = dataStream.readDouble();
|
||||
usage.seismicVibratorUsage = dataStream.readDouble();
|
||||
usage.fluidicPlenisherUsage = dataStream.readDouble();
|
||||
usage.salinationPlantWaterUsage = dataStream.readDouble();
|
||||
|
||||
try {
|
||||
for(IModule module : Mekanism.modulesLoaded)
|
||||
|
||||
@@ -2,6 +2,7 @@ package mekanism.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
@@ -21,12 +22,20 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
IDLE,
|
||||
DUMPING,
|
||||
DUMPING_EXCESS
|
||||
}
|
||||
|
||||
/** The type of gas stored in this tank. */
|
||||
public GasTank gasTank = new GasTank(MAX_GAS);
|
||||
|
||||
@@ -35,7 +44,9 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
/** How fast this tank can output gas. */
|
||||
public int output = 256;
|
||||
|
||||
public boolean dumping;
|
||||
public Mode dumping;
|
||||
|
||||
public int currentGasAmount;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
@@ -44,6 +55,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
{
|
||||
super("GasTank");
|
||||
inventory = new ItemStack[2];
|
||||
dumping = Mode.IDLE;
|
||||
controlType = RedstoneControl.DISABLED;
|
||||
}
|
||||
|
||||
@@ -75,10 +87,26 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && dumping)
|
||||
if(!worldObj.isRemote && dumping.equals(Mode.DUMPING))
|
||||
{
|
||||
gasTank.draw(8, true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && dumping.equals(Mode.DUMPING_EXCESS) && gasTank.getNeeded() < output)
|
||||
{
|
||||
gasTank.draw(output, true);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
int newGasAmount = gasTank.getStored();
|
||||
|
||||
if(newGasAmount != this.currentGasAmount)
|
||||
{
|
||||
markDirty();
|
||||
this.currentGasAmount = newGasAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,7 +119,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
else if(slotID == 0)
|
||||
{
|
||||
return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null &&
|
||||
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack));
|
||||
((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -115,7 +143,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
return side == 1 ? new int[] {0} : new int[] {1};
|
||||
return side == 1 ? new int[]{0} : new int[]{1};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +184,8 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
dumping = !dumping;
|
||||
int index = (dumping.ordinal() + 1)%dumping.values().length;
|
||||
dumping = Mode.values()[index];
|
||||
}
|
||||
|
||||
for(EntityPlayer player : playersUsing)
|
||||
@@ -173,11 +202,12 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
{
|
||||
gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
gasTank.setGas(null);
|
||||
}
|
||||
|
||||
dumping = dataStream.readBoolean();
|
||||
dumping = Mode.values()[dataStream.readInt()];
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
@@ -189,7 +219,22 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
dumping = nbtTags.getBoolean("dumping");
|
||||
if(nbtTags.hasKey("dumpingMode"))
|
||||
{
|
||||
dumping = Mode.valueOf(nbtTags.getString("dumpingMode"));
|
||||
}
|
||||
else //For backwards compatibility
|
||||
{
|
||||
boolean dumpingBool = nbtTags.getBoolean("dumping");
|
||||
if(dumpingBool)
|
||||
{
|
||||
dumping = Mode.DUMPING;
|
||||
}
|
||||
else
|
||||
{
|
||||
dumping = Mode.IDLE;
|
||||
}
|
||||
}
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
}
|
||||
|
||||
@@ -199,7 +244,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound()));
|
||||
nbtTags.setBoolean("dumping", dumping);
|
||||
nbtTags.setString("dumpingMode", dumping.name());
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
}
|
||||
|
||||
@@ -214,11 +259,12 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
data.add(gasTank.getGas().getGas().getID());
|
||||
data.add(gasTank.getStored());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
data.add(false);
|
||||
}
|
||||
|
||||
data.add(dumping);
|
||||
data.add(dumping.ordinal());
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
@@ -236,6 +282,15 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRedstoneLevel()
|
||||
{
|
||||
int stored = gasTank.getStored();
|
||||
|
||||
if(stored == 0) return 0;
|
||||
|
||||
return MathHelper.floor_float((float)stored / (float)MAX_GAS * 14.0f + 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.ISalinationSolar;
|
||||
import mekanism.api.MekanismConfig.usage;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.content.tank.TankUpdateProtocol;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -26,14 +28,11 @@ import net.minecraftforge.fluids.FluidTank;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntitySalinationController extends TileEntitySalinationBlock implements IActiveState
|
||||
{
|
||||
public static final int MAX_BRINE = 10000;
|
||||
public static final int MAX_SOLARS = 4;
|
||||
public static final int WARMUP = 10000;
|
||||
public static final double WATER_USAGE = 40;
|
||||
|
||||
public FluidTank waterTank = new FluidTank(0);
|
||||
public FluidTank brineTank = new FluidTank(MAX_BRINE);
|
||||
@@ -92,14 +91,14 @@ public class TileEntitySalinationController extends TileEntitySalinationBlock im
|
||||
int brineNeeded = brineTank.getCapacity()-brineTank.getFluidAmount();
|
||||
int waterStored = waterTank.getFluidAmount();
|
||||
|
||||
partialWater += Math.min(waterTank.getFluidAmount(), getTemperature()*WATER_USAGE);
|
||||
partialWater += Math.min(waterTank.getFluidAmount(), getTemperature()*usage.salinationPlantWaterUsage);
|
||||
|
||||
if(partialWater >= 1)
|
||||
{
|
||||
int waterInt = (int)Math.floor(partialWater);
|
||||
waterTank.drain(waterInt, true);
|
||||
partialWater %= 1;
|
||||
partialBrine += ((double)waterInt)/WATER_USAGE;
|
||||
partialBrine += ((double)waterInt)/usage.salinationPlantWaterUsage;
|
||||
}
|
||||
|
||||
if(partialBrine >= 1)
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class InventoryUtils
|
||||
inventory.setInventorySlotContents(i, toInsert);
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -151,7 +151,7 @@ public final class InventoryUtils
|
||||
inventory.setInventorySlotContents(slotID, toInsert);
|
||||
return null;
|
||||
}
|
||||
else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -182,7 +182,11 @@ public final class InventoryUtils
|
||||
return toInsert;
|
||||
}
|
||||
|
||||
public static InvStack takeTopItem(IInventory inventory, int side)
|
||||
public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot) {
|
||||
return inSlot.isItemEqual(toInsert) && ItemStack.areItemStackTagsEqual(inSlot, toInsert);
|
||||
}
|
||||
|
||||
public static InvStack takeTopItem(IInventory inventory, int side)
|
||||
{
|
||||
inventory = checkChestInv(inventory);
|
||||
|
||||
@@ -394,7 +398,7 @@ public final class InventoryUtils
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
@@ -440,7 +444,7 @@ public final class InventoryUtils
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize())
|
||||
{
|
||||
if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
|
||||
{
|
||||
|
||||
@@ -293,6 +293,9 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank"));
|
||||
if(itemStack.stackTagCompound.hasKey("fuelTank"))
|
||||
{
|
||||
fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user