From 9c21621c062398c88203d24371e9dc5f1188155b Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Thu, 12 Mar 2015 17:30:40 -0500 Subject: [PATCH] Just about finished! Teleporter & Portable Teleporter work with the new frequency system perfectly. --- .../java/mekanism/client/ClientProxy.java | 2 + .../mekanism/client/gui/GuiTeleporter.java | 37 +++++++++++++-- .../common/frequency/FrequencyManager.java | 15 ++++++ .../network/PacketPortableTeleporter.java | 44 +++++++++++------- .../common/tile/TileEntityTeleporter.java | 22 +++------ .../mekanism/gui/GuiPortableTeleporter.png | Bin 4567 -> 5497 bytes 6 files changed, 83 insertions(+), 37 deletions(-) diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 849c178ee..af8f0db44 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -527,6 +527,8 @@ public class ClientProxy extends CommonProxy teleporter.clientFreq = message.frequency; teleporter.clientPublicCache = message.publicCache; teleporter.clientPrivateCache = message.privateCache; + + teleporter.updateButtons(); } } diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index b57c9a4bf..2b3ffdea7 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -54,6 +54,8 @@ public class GuiTeleporter extends GuiMekanism public GuiButton setButton; public GuiButton deleteButton; + public GuiButton teleportButton; + public GuiScrollList scrollList; public GuiTextField frequencyField; @@ -113,7 +115,7 @@ public class GuiTeleporter extends GuiMekanism }, resource, 158, 26)); guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - ySize = 147; + ySize = 175; } @Override @@ -132,6 +134,11 @@ public class GuiTeleporter extends GuiMekanism 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")); + if(itemStack != null) + { + teleportButton = new GuiButton(4, guiWidth + 42, guiHeight + 140, 92, 20, MekanismUtils.localize("gui.teleport")); + } + frequencyField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); frequencyField.setMaxStringLength(MAX_LENGTH); frequencyField.setEnableBackgroundDrawing(false); @@ -143,6 +150,11 @@ public class GuiTeleporter extends GuiMekanism buttonList.add(setButton); buttonList.add(deleteButton); + if(itemStack != null) + { + buttonList.add(teleportButton); + } + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, clientFreq)); } @@ -233,6 +245,17 @@ public class GuiTeleporter extends GuiMekanism setButton.enabled = false; deleteButton.enabled = false; } + + if(itemStack != null) + { + if(clientFreq != null && clientStatus == 1) + { + teleportButton.enabled = true; + } + else { + teleportButton.enabled = false; + } + } } @Override @@ -341,6 +364,14 @@ public class GuiTeleporter extends GuiMekanism scrollList.selected = -1; } } + else if(guibutton.id == 4) + { + if(clientFreq != null && clientStatus == 1) + { + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, clientFreq)); + mc.setIngameFocus(); + } + } updateButtons(); } @@ -352,7 +383,7 @@ public class GuiTeleporter extends GuiMekanism int yAxis = (mouseY-(height-ySize)/2); fontRendererObj.drawString(getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(MekanismUtils.localize("gui.owner") + ": " + (getOwner() != null ? getOwner() : MekanismUtils.localize("gui.none")), 8, (ySize-96)+4, 0x404040); + fontRendererObj.drawString(MekanismUtils.localize("gui.owner") + ": " + (getOwner() != null ? getOwner() : MekanismUtils.localize("gui.none")), 8, itemStack != null ? ySize-12 : (ySize-96)+4, 0x404040); fontRendererObj.drawString(MekanismUtils.localize("gui.freq") + ":", 32, 81, 0x404040); fontRendererObj.drawString(MekanismUtils.localize("gui.security") + ":", 32, 91, 0x404040); @@ -405,8 +436,6 @@ public class GuiTeleporter extends GuiMekanism super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); frequencyField.drawTextBox(); - - System.out.println(xSize + " " + ySize); } public String getStatusDisplay() diff --git a/src/main/java/mekanism/common/frequency/FrequencyManager.java b/src/main/java/mekanism/common/frequency/FrequencyManager.java index 73204d394..23bfa579e 100644 --- a/src/main/java/mekanism/common/frequency/FrequencyManager.java +++ b/src/main/java/mekanism/common/frequency/FrequencyManager.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; import mekanism.api.Coord4D; @@ -67,6 +68,20 @@ public class FrequencyManager return null; } + public void remove(String name, String owner) + { + for(Iterator iter = getFrequencies().iterator(); iter.hasNext();) + { + Frequency iterFreq = iter.next(); + + if(iterFreq.name.equals(name) && iterFreq.owner.equals(owner)) + { + iter.remove(); + dataHandler.markDirty(); + } + } + } + public void deactivate(Coord4D coord) { for(Frequency freq : frequencies) diff --git a/src/main/java/mekanism/common/network/PacketPortableTeleporter.java b/src/main/java/mekanism/common/network/PacketPortableTeleporter.java index 77c848192..a79f272c7 100644 --- a/src/main/java/mekanism/common/network/PacketPortableTeleporter.java +++ b/src/main/java/mekanism/common/network/PacketPortableTeleporter.java @@ -3,7 +3,6 @@ package mekanism.common.network; import io.netty.buffer.ByteBuf; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import mekanism.api.Coord4D; @@ -73,20 +72,28 @@ public class PacketPortableTeleporter implements IMessageHandler iter = manager.getFrequencies().iterator(); iter.hasNext();) - { - Frequency iterFreq = iter.next(); - - if(iterFreq.name.equals(message.frequency.name) && iterFreq.owner.equals(player.getCommandSenderName())) - { - iter.remove(); - } - } + manager.remove(message.frequency.name, player.getCommandSenderName()); break; case TELEPORT: - Coord4D coords = null;//TODO MekanismUtils.getClosestCoords(new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)), player); + FrequencyManager manager2 = getManager(message.frequency.isPublic() ? null : player.getCommandSenderName(), world); + Frequency found = null; + + for(Frequency freq : manager2.getFrequencies()) + { + if(message.frequency.name.equals(freq.name)) + { + found = freq; + break; + } + } + + if(found == null) + { + break; + } + + Coord4D coords = found.getClosestCoords(new Coord4D(player)); World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId); TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld); @@ -104,12 +111,8 @@ public class PacketPortableTeleporter implements IMessageHandler iter = manager.getFrequencies().iterator(); iter.hasNext();) - { - Frequency iterFreq = iter.next(); - - if(iterFreq.name.equals(freq) && iterFreq.owner.equals(owner)) - { - iter.remove(); - } - } + manager.remove(freq, owner); } } diff --git a/src/main/resources/assets/mekanism/gui/GuiPortableTeleporter.png b/src/main/resources/assets/mekanism/gui/GuiPortableTeleporter.png index 18668ef5559a0ecd758b269c507b8016cabf4f5b..6db1c29f9b0487657b8d42536e35a783fec8441b 100644 GIT binary patch delta 4519 zcmcIoXH-+!7QVR&B&a|lQU@?}LYoNEMJ?qzXf*A$igH^ZvZG-dk(luY1b8e5qhMHWgjg^Jq z4yhdg00w1Yw5;@TOa2+JMUfY{^LFb`DlNhH*}cm6Z7^` zZq;xm@7vl)sxPZcsfeOT15K{OZb}F+E-tRGz%DODkJ{r36)Lt0 z_wgw>>&*wIC~Nt(#ht90efzOklw|`Ir&X7gCAYP;dA7E;UaMp=yPa$6Lre^H?!Oa~ z&3YG(IH?I4hR=N4>#?>tq?wyIe*iS(ZPtiH0wGj#d`cxM&cG zw~@ljm;H|1&weK)EwQ?B`*>5SqPLdBuH|6Pys}nZxOh0WERz!dV#Yso;qn^P0?S_u z*cc66-li}3|FdPlOd(5=Nz}H+O)M@GyLM)DUbW5Mu6&xwk~DdaDuMOJI>~U zVc(4rH;N;N)m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