Just about finished! Teleporter & Portable Teleporter work with the new frequency system perfectly.
This commit is contained in:
parent
6d36926866
commit
9c21621c06
6 changed files with 83 additions and 37 deletions
|
@ -527,6 +527,8 @@ public class ClientProxy extends CommonProxy
|
|||
teleporter.clientFreq = message.frequency;
|
||||
teleporter.clientPublicCache = message.publicCache;
|
||||
teleporter.clientPrivateCache = message.privateCache;
|
||||
|
||||
teleporter.updateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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<Frequency> 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)
|
||||
|
|
|
@ -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<PortableTelepor
|
|||
break;
|
||||
case DEL_FREQ:
|
||||
FrequencyManager manager = getManager(message.frequency.isPublic() ? null : player.getCommandSenderName(), world);
|
||||
|
||||
for(Iterator<Frequency> 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<PortableTelepor
|
|||
MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount);
|
||||
}
|
||||
|
||||
if(world.provider.dimensionId != coords.dimensionId)
|
||||
{
|
||||
((EntityPlayerMP)player).travelToDimension(coords.dimensionId);
|
||||
}
|
||||
|
||||
((EntityPlayerMP)player).playerNetServerHandler.setPlayerLocation(coords.xCoord+0.5, coords.yCoord+1, coords.zCoord+0.5, player.rotationYaw, player.rotationPitch);
|
||||
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(new Coord4D(player)), coords.getTargetPoint(40D));
|
||||
TileEntityTeleporter.teleportPlayerTo((EntityPlayerMP)player, coords, teleporter);
|
||||
|
||||
world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
Mekanism.packetHandler.sendToReceivers(new PortalFXMessage(coords), new Range4D(coords));
|
||||
|
@ -305,6 +308,11 @@ public class PacketPortableTeleporter implements IMessageHandler<PortableTelepor
|
|||
PacketHandler.writeString(buffer, frequency.name);
|
||||
buffer.writeBoolean(frequency.publicFreq);
|
||||
}
|
||||
else if(packetType == PortableTeleporterPacketType.TELEPORT)
|
||||
{
|
||||
PacketHandler.writeString(buffer, frequency.name);
|
||||
buffer.writeBoolean(frequency.publicFreq);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -335,14 +335,14 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
}
|
||||
}
|
||||
|
||||
public void teleportPlayerTo(EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter)
|
||||
public static void teleportPlayerTo(EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter)
|
||||
{
|
||||
if(player.dimension != coord.dimensionId)
|
||||
{
|
||||
int id = player.dimension;
|
||||
WorldServer oldWorld = server.worldServerForDimension(player.dimension);
|
||||
WorldServer oldWorld = player.mcServer.worldServerForDimension(player.dimension);
|
||||
player.dimension = coord.dimensionId;
|
||||
WorldServer newWorld = server.worldServerForDimension(player.dimension);
|
||||
WorldServer newWorld = player.mcServer.worldServerForDimension(player.dimension);
|
||||
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
|
||||
oldWorld.removePlayerEntityDangerously(player);
|
||||
player.isDead = false;
|
||||
|
@ -355,11 +355,11 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
player.setWorld(newWorld);
|
||||
}
|
||||
|
||||
server.getConfigurationManager().func_72375_a(player, oldWorld);
|
||||
player.mcServer.getConfigurationManager().func_72375_a(player, oldWorld);
|
||||
player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch);
|
||||
player.theItemInWorldManager.setWorld(newWorld);
|
||||
server.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld);
|
||||
server.getConfigurationManager().syncPlayerInventory(player);
|
||||
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld);
|
||||
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
|
||||
Iterator iterator = player.getActivePotionEffects().iterator();
|
||||
|
||||
while(iterator.hasNext())
|
||||
|
@ -512,15 +512,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
if(manager != null)
|
||||
{
|
||||
for(Iterator<Frequency> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 5.4 KiB |
Loading…
Reference in a new issue