Work on new teleporter system - still a lot to do
This commit is contained in:
parent
605532adab
commit
5e5975bc58
16 changed files with 442 additions and 162 deletions
|
@ -63,7 +63,6 @@ public class GuiDigitalMiner extends GuiMekanism
|
||||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 151, 5).with(SlotOverlay.POWER));
|
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 151, 5).with(SlotOverlay.POWER));
|
||||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 143, 26));
|
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 143, 26));
|
||||||
|
|
||||||
|
|
||||||
ySize+=64;
|
ySize+=64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism
|
||||||
int xAxis = (mouseX - (width - xSize) / 2);
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
int yAxis = (mouseY - (height - ySize) / 2);
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 26, 4, 0x404040);
|
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040);
|
||||||
fontRendererObj.drawString(tileEntity.mode == 0 ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040);
|
fontRendererObj.drawString(tileEntity.mode == 0 ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040);
|
||||||
|
|
||||||
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
|
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
|
||||||
|
|
|
@ -1,37 +1,200 @@
|
||||||
package mekanism.client.gui;
|
package mekanism.client.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import mekanism.api.EnumColor;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import mekanism.api.Coord4D;
|
|
||||||
import mekanism.client.gui.element.GuiPowerBar;
|
import mekanism.client.gui.element.GuiPowerBar;
|
||||||
|
import mekanism.client.gui.element.GuiScrollList;
|
||||||
import mekanism.client.gui.element.GuiSlot;
|
import mekanism.client.gui.element.GuiSlot;
|
||||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||||
import mekanism.client.sound.SoundHandler;
|
import mekanism.client.sound.SoundHandler;
|
||||||
import mekanism.common.Mekanism;
|
|
||||||
import mekanism.common.inventory.container.ContainerTeleporter;
|
import mekanism.common.inventory.container.ContainerTeleporter;
|
||||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
|
||||||
import mekanism.common.tile.TileEntityTeleporter;
|
import mekanism.common.tile.TileEntityTeleporter;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class GuiTeleporter extends GuiMekanism
|
public class GuiTeleporter extends GuiMekanism
|
||||||
{
|
{
|
||||||
|
public static int MAX_LENGTH = 16;
|
||||||
|
|
||||||
public TileEntityTeleporter tileEntity;
|
public TileEntityTeleporter tileEntity;
|
||||||
|
|
||||||
|
public GuiButton publicButton;
|
||||||
|
public GuiButton privateButton;
|
||||||
|
|
||||||
|
public GuiButton setButton;
|
||||||
|
public GuiButton deleteButton;
|
||||||
|
|
||||||
|
public GuiScrollList scrollList;
|
||||||
|
|
||||||
|
public GuiTextField frequencyField;
|
||||||
|
|
||||||
|
public boolean privateMode;
|
||||||
|
|
||||||
public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity)
|
public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity)
|
||||||
{
|
{
|
||||||
super(tentity, new ContainerTeleporter(inventory, tentity));
|
super(tentity, new ContainerTeleporter(inventory, tentity));
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
|
|
||||||
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 164, 15));
|
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 158, 26));
|
||||||
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 26, 13).with(SlotOverlay.POWER));
|
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 152, 6).with(SlotOverlay.POWER));
|
||||||
|
guiElements.add(scrollList = new GuiScrollList(this, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"), 28, 37, 120, 4));
|
||||||
|
|
||||||
|
ySize+=64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui()
|
||||||
|
{
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int guiWidth = (width - xSize) / 2;
|
||||||
|
int guiHeight = (height - ySize) / 2;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
|
||||||
|
publicButton = new GuiButton(0, guiWidth + 27, guiHeight + 14, 60, 20, MekanismUtils.localize("gui.public"));
|
||||||
|
privateButton = new GuiButton(1, guiWidth + 89, guiHeight + 14, 60, 20, MekanismUtils.localize("gui.private"));
|
||||||
|
|
||||||
|
setButton = new GuiButton(2, guiWidth + 27, guiHeight + 116, 60, 20, MekanismUtils.localize("gui.set"));
|
||||||
|
deleteButton = new GuiButton(3, guiWidth + 89, guiHeight + 116, 60, 20, MekanismUtils.localize("gui.delete"));
|
||||||
|
|
||||||
|
frequencyField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11);
|
||||||
|
frequencyField.setMaxStringLength(MAX_LENGTH);
|
||||||
|
frequencyField.setEnableBackgroundDrawing(false);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
|
buttonList.add(publicButton);
|
||||||
|
buttonList.add(privateButton);
|
||||||
|
buttonList.add(setButton);
|
||||||
|
buttonList.add(deleteButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrequency()
|
||||||
|
{
|
||||||
|
String text = frequencyField.getText();
|
||||||
|
|
||||||
|
if(text.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecurity()
|
||||||
|
{
|
||||||
|
return privateMode ? EnumColor.DARK_RED + MekanismUtils.localize("gui.private") : MekanismUtils.localize("gui.public");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateButtons()
|
||||||
|
{
|
||||||
|
if(privateMode)
|
||||||
|
{
|
||||||
|
publicButton.enabled = true;
|
||||||
|
privateButton.enabled = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
publicButton.enabled = false;
|
||||||
|
privateButton.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scrollList.hasSelection())
|
||||||
|
{
|
||||||
|
setButton.enabled = true;
|
||||||
|
deleteButton.enabled = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setButton.enabled = false;
|
||||||
|
deleteButton.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateScreen()
|
||||||
|
{
|
||||||
|
super.updateScreen();
|
||||||
|
|
||||||
|
frequencyField.updateCursorCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||||
|
{
|
||||||
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
|
frequencyField.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
if(button == 0)
|
||||||
|
{
|
||||||
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
|
if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114)
|
||||||
|
{
|
||||||
|
setFrequency();
|
||||||
|
SoundHandler.playSound("gui.button.press");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(char c, int i)
|
||||||
|
{
|
||||||
|
if(!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE)
|
||||||
|
{
|
||||||
|
super.keyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == Keyboard.KEY_RETURN)
|
||||||
|
{
|
||||||
|
if(frequencyField.isFocused())
|
||||||
|
{
|
||||||
|
setFrequency();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Character.isDigit(c) || Character.isLetter(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT)
|
||||||
|
{
|
||||||
|
frequencyField.textboxKeyTyped(c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void actionPerformed(GuiButton guibutton)
|
||||||
|
{
|
||||||
|
super.actionPerformed(guibutton);
|
||||||
|
|
||||||
|
if(guibutton.id == 0)
|
||||||
|
{
|
||||||
|
privateMode = false;
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 1)
|
||||||
|
{
|
||||||
|
privateMode = true;
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(guibutton.id == 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,90 +203,32 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
int xAxis = (mouseX-(width-xSize)/2);
|
int xAxis = (mouseX-(width-xSize)/2);
|
||||||
int yAxis = (mouseY-(height-ySize)/2);
|
int yAxis = (mouseY-(height-ySize)/2);
|
||||||
|
|
||||||
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
|
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040);
|
||||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize-96)+2, 0x404040);
|
fontRendererObj.drawString(MekanismUtils.localize("gui.owner") + ": " + tileEntity.owner != null ? tileEntity.owner : MekanismUtils.localize("gui.none"), 8, (ySize-96)+4, 0x404040);
|
||||||
fontRendererObj.drawString(tileEntity.getStatusDisplay(), 66, 19, 0x00CD00);
|
|
||||||
|
|
||||||
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
fontRendererObj.drawString(MekanismUtils.localize("gui.freq") + ":", 32, 81, 0x404040);
|
||||||
|
fontRendererObj.drawString(MekanismUtils.localize("gui.security") + ":", 32, 91, 0x404040);
|
||||||
|
|
||||||
|
fontRendererObj.drawString(" " + (tileEntity.frequency != null ? tileEntity.frequency.name : EnumColor.DARK_RED + MekanismUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.freq") + ":"), 81, 0x797979);
|
||||||
|
fontRendererObj.drawString(" " + getSecurity(), 32 + fontRendererObj.getStringWidth(MekanismUtils.localize("gui.security") + ":"), 91, 0x797979);
|
||||||
|
|
||||||
|
String str = MekanismUtils.localize("gui.set") + ":";
|
||||||
|
renderScaledText(str, 27, 104, 0x404040, 20);
|
||||||
|
|
||||||
|
if(xAxis >= 6 && xAxis <= 24 && yAxis >= 6 && yAxis <= 24)
|
||||||
{
|
{
|
||||||
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
if(tileEntity.frequency == null)
|
||||||
|
{
|
||||||
|
drawCreativeTabHoveringText(EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noFreq"), xAxis, yAxis);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawCreativeTabHoveringText(tileEntity.getStatusDisplay(), xAxis, yAxis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked(int x, int y, int button)
|
|
||||||
{
|
|
||||||
super.mouseClicked(x, y, button);
|
|
||||||
|
|
||||||
int xAxis = (x-(width-xSize)/2);
|
|
||||||
int yAxis = (y-(height-ySize)/2);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
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));
|
|
||||||
setButton(buttonIndex, incrementedNumber);
|
|
||||||
SoundHandler.playSound("gui.button.press");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setButton(int index, int number)
|
|
||||||
{
|
|
||||||
if(index == 0)
|
|
||||||
{
|
|
||||||
tileEntity.code.digitOne = number;
|
|
||||||
}
|
|
||||||
if(index == 1)
|
|
||||||
{
|
|
||||||
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
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
|
@ -132,40 +237,25 @@ public class GuiTeleporter extends GuiMekanism
|
||||||
int guiWidth = (width-xSize)/2;
|
int guiWidth = (width-xSize)/2;
|
||||||
int guiHeight = (height-ySize)/2;
|
int guiHeight = (height-ySize)/2;
|
||||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||||
int displayInt;
|
|
||||||
|
|
||||||
displayInt = tileEntity.getScaledEnergyLevel(52);
|
int xAxis = (mouseX - (width - xSize) / 2);
|
||||||
drawTexturedModalRect(guiWidth+165, guiHeight+17+52-displayInt, 176+13, 52-displayInt, 4, displayInt);
|
int yAxis = (mouseY - (height - ySize) / 2);
|
||||||
|
|
||||||
displayInt = getYAxisForNumber(tileEntity.code.digitOne);
|
if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114)
|
||||||
drawTexturedModalRect(guiWidth+23, guiHeight+44, 176, displayInt, 13, 13);
|
{
|
||||||
|
drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11);
|
||||||
|
}
|
||||||
|
|
||||||
displayInt = getYAxisForNumber(tileEntity.code.digitTwo);
|
int y = tileEntity.frequency == null ? 94 : (tileEntity.status == 2 ? 22 : (tileEntity.status == 3 ? 40 :
|
||||||
drawTexturedModalRect(guiWidth+62, guiHeight+44, 176, displayInt, 13, 13);
|
(tileEntity.status == 4 ? 58 : 76)));
|
||||||
|
|
||||||
displayInt = getYAxisForNumber(tileEntity.code.digitThree);
|
drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, y, 18, 18);
|
||||||
drawTexturedModalRect(guiWidth+101, guiHeight+44, 176, displayInt, 13, 13);
|
|
||||||
|
|
||||||
displayInt = getYAxisForNumber(tileEntity.code.digitFour);
|
|
||||||
drawTexturedModalRect(guiWidth+140, guiHeight+44, 176, displayInt, 13, 13);
|
|
||||||
|
|
||||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||||
}
|
|
||||||
|
|
||||||
public int getUpdatedNumber(int i, int mouseButton)
|
frequencyField.drawTextBox();
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return i*13;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package mekanism.client.gui.element;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import mekanism.client.gui.IGuiWrapper;
|
import mekanism.client.gui.IGuiWrapper;
|
||||||
import mekanism.common.ObfuscatedNames;
|
import mekanism.common.ObfuscatedNames;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
@ -94,6 +96,28 @@ public abstract class GuiElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void renderScaledText(String text, int x, int y, int color, int maxX)
|
||||||
|
{
|
||||||
|
int length = getFontRenderer().getStringWidth(text);
|
||||||
|
|
||||||
|
if(length <= maxX)
|
||||||
|
{
|
||||||
|
getFontRenderer().drawString(text, x, y, color);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float scale = (float)maxX/length;
|
||||||
|
float reverse = 1/scale;
|
||||||
|
float yAdd = 4-(scale*8)/2F;
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
GL11.glScalef(scale, scale, scale);
|
||||||
|
getFontRenderer().drawString(text, (int)(x*reverse), (int)((y*reverse)+yAdd), color);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FontRenderer getFontRenderer()
|
public FontRenderer getFontRenderer()
|
||||||
{
|
{
|
||||||
return guiObj.getFont();
|
return guiObj.getFont();
|
||||||
|
|
|
@ -7,12 +7,12 @@ import mekanism.client.gui.IGuiWrapper;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import codechicken.lib.vec.Rectangle4i;
|
import codechicken.lib.vec.Rectangle4i;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class GuiScrollList extends GuiElement
|
public class GuiScrollList extends GuiElement
|
||||||
|
@ -27,6 +27,8 @@ public class GuiScrollList extends GuiElement
|
||||||
|
|
||||||
public int dragOffset = 0;
|
public int dragOffset = 0;
|
||||||
|
|
||||||
|
public int selected = -1;
|
||||||
|
|
||||||
public float scroll;
|
public float scroll;
|
||||||
|
|
||||||
public boolean isDragging;
|
public boolean isDragging;
|
||||||
|
@ -42,6 +44,16 @@ public class GuiScrollList extends GuiElement
|
||||||
size = sizeY;
|
size = sizeY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasSelection()
|
||||||
|
{
|
||||||
|
return selected != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelection()
|
||||||
|
{
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
public void setText(List<String> text)
|
public void setText(List<String> text)
|
||||||
{
|
{
|
||||||
scroll = 0;
|
scroll = 0;
|
||||||
|
@ -52,6 +64,11 @@ public class GuiScrollList extends GuiElement
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(selected > text.size()-1)
|
||||||
|
{
|
||||||
|
selected = -1;
|
||||||
|
}
|
||||||
|
|
||||||
textEntries = text;
|
textEntries = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +84,7 @@ public class GuiScrollList extends GuiElement
|
||||||
mc.renderEngine.bindTexture(RESOURCE);
|
mc.renderEngine.bindTexture(RESOURCE);
|
||||||
|
|
||||||
drawBlack(guiWidth, guiHeight);
|
drawBlack(guiWidth, guiHeight);
|
||||||
|
drawSelected(guiWidth, guiHeight, selected);
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(defaultLocation);
|
mc.renderEngine.bindTexture(defaultLocation);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +103,22 @@ public class GuiScrollList extends GuiElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawSelected(int guiWidth, int guiHeight, int index)
|
||||||
|
{
|
||||||
|
int scroll = getScrollIndex();
|
||||||
|
|
||||||
|
if(selected != -1 && index >= scroll && index <= scroll+size-1)
|
||||||
|
{
|
||||||
|
int xDisplays = xSize/10 + (xSize%10 > 0 ? 1 : 0);
|
||||||
|
|
||||||
|
for(int xIter = 0; xIter < xDisplays; xIter++)
|
||||||
|
{
|
||||||
|
int width = (xSize%10 > 0 && xIter == xDisplays ? xSize%10 : 10);
|
||||||
|
guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (index-scroll)*10, 0, 10, width, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void drawScroll()
|
public void drawScroll()
|
||||||
{
|
{
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
GL11.glColor4f(1, 1, 1, 1);
|
||||||
|
@ -134,7 +168,7 @@ public class GuiScrollList extends GuiElement
|
||||||
|
|
||||||
if(index <= textEntries.size()-1)
|
if(index <= textEntries.size()-1)
|
||||||
{
|
{
|
||||||
guiObj.getFont().drawString(textEntries.get(index), xPosition + 1, yPosition + 1 + (10*i), 0x00CD00);
|
renderScaledText(textEntries.get(index), xPosition + 1, yPosition + 1 + (10*i), 0x00CD00, xSize-6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +198,23 @@ public class GuiScrollList extends GuiElement
|
||||||
isDragging = true;
|
isDragging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(xAxis >= xPosition && xAxis <= xPosition + xSize-6 && yAxis >= yPosition && yAxis <= yPosition+size*10)
|
||||||
|
{
|
||||||
|
int index = getScrollIndex();
|
||||||
|
selected = -1;
|
||||||
|
|
||||||
|
for(int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if(index+i <= textEntries.size()-1)
|
||||||
|
{
|
||||||
|
if(yAxis >= (yPosition + i*10) && yAxis <= (yPosition + i*10 + 10))
|
||||||
|
{
|
||||||
|
selected = index+i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,10 +234,13 @@ public class GuiScrollList extends GuiElement
|
||||||
{
|
{
|
||||||
super.mouseMovedOrUp(xAxis, yAxis, type);
|
super.mouseMovedOrUp(xAxis, yAxis, type);
|
||||||
|
|
||||||
if(type == 0 && isDragging)
|
if(type == 0)
|
||||||
|
{
|
||||||
|
if(isDragging)
|
||||||
{
|
{
|
||||||
dragOffset = 0;
|
dragOffset = 0;
|
||||||
isDragging = false;
|
isDragging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ import mekanism.common.entity.EntityBalloon;
|
||||||
import mekanism.common.entity.EntityFlame;
|
import mekanism.common.entity.EntityFlame;
|
||||||
import mekanism.common.entity.EntityObsidianTNT;
|
import mekanism.common.entity.EntityObsidianTNT;
|
||||||
import mekanism.common.entity.EntityRobit;
|
import mekanism.common.entity.EntityRobit;
|
||||||
|
import mekanism.common.frequency.Frequency;
|
||||||
|
import mekanism.common.frequency.FrequencyManager;
|
||||||
import mekanism.common.integration.MekanismHooks;
|
import mekanism.common.integration.MekanismHooks;
|
||||||
import mekanism.common.integration.OreDictManager;
|
import mekanism.common.integration.OreDictManager;
|
||||||
import mekanism.common.multiblock.MultiblockManager;
|
import mekanism.common.multiblock.MultiblockManager;
|
||||||
|
@ -170,6 +172,9 @@ public class Mekanism
|
||||||
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine", TurbineCache.class);
|
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine", TurbineCache.class);
|
||||||
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
|
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
|
||||||
|
|
||||||
|
/** FrequencyManagers for various networks */
|
||||||
|
public static FrequencyManager teleporterManager = new FrequencyManager(Frequency.class);
|
||||||
|
|
||||||
/** Mekanism creative tab */
|
/** Mekanism creative tab */
|
||||||
public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism();
|
public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism();
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,13 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mekanism.api.Coord4D;
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.MekanismConfig.client;
|
import mekanism.api.MekanismConfig.client;
|
||||||
import mekanism.api.MekanismConfig.general;
|
import mekanism.api.MekanismConfig.general;
|
||||||
import mekanism.api.MekanismConfig.machines;
|
import mekanism.api.MekanismConfig.machines;
|
||||||
import mekanism.api.MekanismConfig.usage;
|
import mekanism.api.MekanismConfig.usage;
|
||||||
import mekanism.api.energy.IEnergizedItem;
|
import mekanism.api.energy.IEnergizedItem;
|
||||||
import mekanism.api.energy.IStrictEnergyStorage;
|
import mekanism.api.energy.IStrictEnergyStorage;
|
||||||
import mekanism.api.transmitters.TransmissionType;
|
|
||||||
import mekanism.client.ClientProxy;
|
import mekanism.client.ClientProxy;
|
||||||
import mekanism.common.ItemAttacher;
|
import mekanism.common.ItemAttacher;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
|
@ -23,8 +23,8 @@ import mekanism.common.base.IBoundingBlock;
|
||||||
import mekanism.common.base.IElectricChest;
|
import mekanism.common.base.IElectricChest;
|
||||||
import mekanism.common.base.IFactory;
|
import mekanism.common.base.IFactory;
|
||||||
import mekanism.common.base.IFactory.RecipeType;
|
import mekanism.common.base.IFactory.RecipeType;
|
||||||
import mekanism.common.base.ISideConfiguration;
|
|
||||||
import mekanism.common.base.IRedstoneControl;
|
import mekanism.common.base.IRedstoneControl;
|
||||||
|
import mekanism.common.base.ISideConfiguration;
|
||||||
import mekanism.common.base.ISpecialBounds;
|
import mekanism.common.base.ISpecialBounds;
|
||||||
import mekanism.common.base.ISustainedData;
|
import mekanism.common.base.ISustainedData;
|
||||||
import mekanism.common.base.ISustainedInventory;
|
import mekanism.common.base.ISustainedInventory;
|
||||||
|
@ -90,6 +90,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
@ -271,6 +272,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(tileEntity instanceof TileEntityTeleporter)
|
||||||
|
{
|
||||||
|
TileEntityTeleporter teleporter = (TileEntityTeleporter)tileEntity;
|
||||||
|
teleporter.owner = entityliving.getCommandSenderName();
|
||||||
|
}
|
||||||
|
|
||||||
tileEntity.setFacing((short)change);
|
tileEntity.setFacing((short)change);
|
||||||
tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
|
tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||||
|
@ -637,6 +643,26 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
case LOGISTICAL_SORTER:
|
case LOGISTICAL_SORTER:
|
||||||
LogisticalSorterGuiMessage.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP)entityplayer, Coord4D.get(tileEntity), -1);
|
LogisticalSorterGuiMessage.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP)entityplayer, Coord4D.get(tileEntity), -1);
|
||||||
return true;
|
return true;
|
||||||
|
case TELEPORTER:
|
||||||
|
if(!entityplayer.isSneaking())
|
||||||
|
{
|
||||||
|
TileEntityTeleporter teleporter = (TileEntityTeleporter)tileEntity;
|
||||||
|
|
||||||
|
if(teleporter.owner == null)
|
||||||
|
{
|
||||||
|
teleporter.owner = entityplayer.getCommandSenderName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(teleporter.owner.equals(entityplayer.getCommandSenderName()) || MekanismUtils.isOp((EntityPlayerMP)entityplayer))
|
||||||
|
{
|
||||||
|
entityplayer.openGui(Mekanism.instance, type.guiId, world, x, y, z);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("gui.teleporter.noAccess")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if(!entityplayer.isSneaking() && type.guiId != -1)
|
if(!entityplayer.isSneaking() && type.guiId != -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class BlockPlastic extends Block
|
||||||
setHardness(this == MekanismBlocks.ReinforcedPlasticBlock ? 50F : 5F);
|
setHardness(this == MekanismBlocks.ReinforcedPlasticBlock ? 50F : 5F);
|
||||||
setResistance(this == MekanismBlocks.ReinforcedPlasticBlock ? 2000F : 10F);
|
setResistance(this == MekanismBlocks.ReinforcedPlasticBlock ? 2000F : 10F);
|
||||||
setCreativeTab(Mekanism.tabMekanism);
|
setCreativeTab(Mekanism.tabMekanism);
|
||||||
|
|
||||||
if(this == MekanismBlocks.SlickPlasticBlock)
|
if(this == MekanismBlocks.SlickPlasticBlock)
|
||||||
{
|
{
|
||||||
slipperiness = 0.98F;
|
slipperiness = 0.98F;
|
||||||
|
@ -100,7 +101,6 @@ public class BlockPlastic extends Block
|
||||||
{
|
{
|
||||||
EnumColor colour = EnumColor.DYES[meta];
|
EnumColor colour = EnumColor.DYES[meta];
|
||||||
return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255);
|
return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,14 +114,17 @@ public class BlockPlastic extends Block
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
||||||
{
|
{
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
if(meta != (15 - colour))
|
if(meta != (15 - colour))
|
||||||
{
|
{
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 15-colour, 3);
|
world.setBlockMetadataWithNotify(x, y, z, 15-colour, 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,16 @@ public class Frequency
|
||||||
owner = o;
|
owner = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Frequency(NBTTagCompound nbtTags)
|
||||||
|
{
|
||||||
|
read(nbtTags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Frequency(ByteBuf dataStream)
|
||||||
|
{
|
||||||
|
read(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
nbtTags.setString("name", name);
|
nbtTags.setString("name", name);
|
||||||
|
|
|
@ -49,6 +49,16 @@ public class FrequencyManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateFrequency(Frequency freq)
|
||||||
|
{
|
||||||
|
if(frequencies.contains(freq))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void createOrLoad(World world)
|
public void createOrLoad(World world)
|
||||||
{
|
{
|
||||||
if(dataHandler == null)
|
if(dataHandler == null)
|
||||||
|
|
|
@ -17,21 +17,21 @@ public class ContainerTeleporter extends Container
|
||||||
public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity)
|
public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity)
|
||||||
{
|
{
|
||||||
tileEntity = tentity;
|
tileEntity = tentity;
|
||||||
addSlotToContainer(new SlotDischarge(tentity, 0, 27, 14));
|
addSlotToContainer(new SlotDischarge(tentity, 0, 153, 7));
|
||||||
|
|
||||||
int slotY;
|
int slotX;
|
||||||
|
|
||||||
for(slotY = 0; slotY < 3; slotY++)
|
for(slotX = 0; slotX < 3; slotX++)
|
||||||
{
|
{
|
||||||
for(int slotX = 0; slotX < 9; slotX++)
|
for(int slotY = 0; slotY < 9; slotY++)
|
||||||
{
|
{
|
||||||
addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18));
|
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(slotY = 0; slotY < 9; slotY++)
|
for(slotX = 0; slotX < 9; slotX++)
|
||||||
{
|
{
|
||||||
addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142));
|
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206));
|
||||||
}
|
}
|
||||||
|
|
||||||
tileEntity.open(inventory.player);
|
tileEntity.open(inventory.player);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mekanism.common.tile;
|
package mekanism.common.tile;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -10,13 +12,14 @@ import mekanism.api.Coord4D;
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
import mekanism.common.MekanismBlocks;
|
import mekanism.common.MekanismBlocks;
|
||||||
|
import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.Teleporter;
|
import mekanism.common.Teleporter;
|
||||||
import mekanism.common.block.BlockMachine.MachineType;
|
import mekanism.common.block.BlockMachine.MachineType;
|
||||||
|
import mekanism.common.frequency.Frequency;
|
||||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||||
import mekanism.common.util.ChargeUtils;
|
import mekanism.common.util.ChargeUtils;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
import net.minecraft.entity.EntityList;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -34,9 +37,6 @@ import cpw.mods.fml.common.Optional.Interface;
|
||||||
import cpw.mods.fml.common.Optional.Method;
|
import cpw.mods.fml.common.Optional.Method;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
@ -60,6 +60,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
|
|
||||||
public boolean prevShouldRender;
|
public boolean prevShouldRender;
|
||||||
|
|
||||||
|
public String owner;
|
||||||
|
|
||||||
|
public Frequency frequency;
|
||||||
|
|
||||||
/** This teleporter's current status. */
|
/** This teleporter's current status. */
|
||||||
public byte status = 0;
|
public byte status = 0;
|
||||||
|
|
||||||
|
@ -138,11 +142,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
case 3:
|
case 3:
|
||||||
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
|
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
|
||||||
case 4:
|
case 4:
|
||||||
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.exceeds");
|
|
||||||
case 5:
|
|
||||||
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.needsEnergy");
|
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.needsEnergy");
|
||||||
case 6:
|
|
||||||
return EnumColor.DARK_GREEN + MekanismUtils.localize("gui.idle");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
|
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
|
||||||
|
@ -188,9 +188,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
* 1: yes
|
* 1: yes
|
||||||
* 2: no frame
|
* 2: no frame
|
||||||
* 3: no link found
|
* 3: no link found
|
||||||
* 4: too many links
|
* 4: not enough electricity
|
||||||
* 5: not enough electricity
|
|
||||||
* 6: nothing to teleport
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public byte canTeleport()
|
public byte canTeleport()
|
||||||
|
@ -205,11 +203,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Mekanism.teleporters.get(code).size() > 2)
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Mekanism.teleporters.get(code).size() == 2)
|
if(Mekanism.teleporters.get(code).size() == 2)
|
||||||
{
|
{
|
||||||
List<Entity> entitiesInPortal = getToTeleport();
|
List<Entity> entitiesInPortal = getToTeleport();
|
||||||
|
@ -232,20 +225,15 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
electricityNeeded += calculateEnergyCost(entity, closestCoords);
|
electricityNeeded += calculateEnergyCost(entity, closestCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entitiesInPortal.size() == 0)
|
|
||||||
{
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getEnergy() < electricityNeeded)
|
if(getEnergy() < electricityNeeded)
|
||||||
{
|
{
|
||||||
return 5;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 3;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleport()
|
public void teleport()
|
||||||
|
@ -445,6 +433,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
code.digitTwo = nbtTags.getInteger("digitTwo");
|
code.digitTwo = nbtTags.getInteger("digitTwo");
|
||||||
code.digitThree = nbtTags.getInteger("digitThree");
|
code.digitThree = nbtTags.getInteger("digitThree");
|
||||||
code.digitFour = nbtTags.getInteger("digitFour");
|
code.digitFour = nbtTags.getInteger("digitFour");
|
||||||
|
|
||||||
|
if(nbtTags.hasKey("owner"))
|
||||||
|
{
|
||||||
|
owner = nbtTags.getString("owner");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nbtTags.hasKey("frequency"))
|
||||||
|
{
|
||||||
|
frequency = new Frequency(nbtTags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -456,6 +454,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
nbtTags.setInteger("digitTwo", code.digitTwo);
|
nbtTags.setInteger("digitTwo", code.digitTwo);
|
||||||
nbtTags.setInteger("digitThree", code.digitThree);
|
nbtTags.setInteger("digitThree", code.digitThree);
|
||||||
nbtTags.setInteger("digitFour", code.digitFour);
|
nbtTags.setInteger("digitFour", code.digitFour);
|
||||||
|
|
||||||
|
if(owner != null)
|
||||||
|
{
|
||||||
|
nbtTags.setString("owner", owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frequency != null)
|
||||||
|
{
|
||||||
|
frequency.write(nbtTags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -497,6 +505,22 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
|
|
||||||
super.handlePacketData(dataStream);
|
super.handlePacketData(dataStream);
|
||||||
|
|
||||||
|
if(dataStream.readBoolean())
|
||||||
|
{
|
||||||
|
owner = PacketHandler.readString(dataStream);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataStream.readBoolean())
|
||||||
|
{
|
||||||
|
frequency = new Frequency(dataStream);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
frequency = null;
|
||||||
|
}
|
||||||
|
|
||||||
status = dataStream.readByte();
|
status = dataStream.readByte();
|
||||||
code.digitOne = dataStream.readInt();
|
code.digitOne = dataStream.readInt();
|
||||||
code.digitTwo = dataStream.readInt();
|
code.digitTwo = dataStream.readInt();
|
||||||
|
@ -510,6 +534,24 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
{
|
{
|
||||||
super.getNetworkedData(data);
|
super.getNetworkedData(data);
|
||||||
|
|
||||||
|
if(owner != null)
|
||||||
|
{
|
||||||
|
data.add(true);
|
||||||
|
data.add(owner);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frequency != null)
|
||||||
|
{
|
||||||
|
data.add(true);
|
||||||
|
frequency.write(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.add(false);
|
||||||
|
}
|
||||||
|
|
||||||
data.add(status);
|
data.add(status);
|
||||||
data.add(code.digitOne);
|
data.add(code.digitOne);
|
||||||
data.add(code.digitTwo);
|
data.add(code.digitTwo);
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
import mekanism.api.Chunk3D;
|
import mekanism.api.Chunk3D;
|
||||||
import mekanism.api.Coord4D;
|
import mekanism.api.Coord4D;
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
|
@ -1350,6 +1352,11 @@ public final class MekanismUtils
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isOp(EntityPlayerMP player)
|
||||||
|
{
|
||||||
|
return player.mcServer.getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||||
|
}
|
||||||
|
|
||||||
public static String getMod(ItemStack stack)
|
public static String getMod(ItemStack stack)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.4 KiB |
|
@ -432,6 +432,14 @@ gui.structure=Structure
|
||||||
gui.dynamicTank=Dynamic Tank
|
gui.dynamicTank=Dynamic Tank
|
||||||
gui.visuals=Visuals
|
gui.visuals=Visuals
|
||||||
gui.noEject=Can't Eject
|
gui.noEject=Can't Eject
|
||||||
|
gui.undefined=Undefined
|
||||||
|
gui.owner=Owner
|
||||||
|
gui.public=Public
|
||||||
|
gui.private=Private
|
||||||
|
gui.add=Add
|
||||||
|
gui.set=Set
|
||||||
|
gui.freq=Freq
|
||||||
|
gui.security=Security
|
||||||
|
|
||||||
gui.reactor.injectionRate=Injection Rate
|
gui.reactor.injectionRate=Injection Rate
|
||||||
|
|
||||||
|
@ -525,6 +533,8 @@ gui.teleporter.noFrame=No frame
|
||||||
gui.teleporter.noLink=No link
|
gui.teleporter.noLink=No link
|
||||||
gui.teleporter.exceeds=Links > 2
|
gui.teleporter.exceeds=Links > 2
|
||||||
gui.teleporter.needsEnergy=Needs energy
|
gui.teleporter.needsEnergy=Needs energy
|
||||||
|
gui.teleporter.noAccess=You don't have access to this teleporter.
|
||||||
|
gui.teleporter.noFreq=No frequency
|
||||||
|
|
||||||
gui.digitalMinerConfig=Digital Miner Config
|
gui.digitalMinerConfig=Digital Miner Config
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue