More teleporter work. Getting pretty complicated, hopefully I can pull this off
This commit is contained in:
parent
855a5acf1d
commit
76b93bec65
9 changed files with 259 additions and 177 deletions
|
@ -123,6 +123,8 @@ public class GuiTeleporter extends GuiMekanism
|
|||
{
|
||||
super.updateScreen();
|
||||
|
||||
updateButtons();
|
||||
|
||||
frequencyField.updateCursorCounter();
|
||||
}
|
||||
|
||||
|
@ -189,7 +191,7 @@ public class GuiTeleporter extends GuiMekanism
|
|||
{
|
||||
|
||||
}
|
||||
else if(guibutton.id == 2)
|
||||
else if(guibutton.id == 3)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class CommonPlayerTickHandler
|
|||
ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem();
|
||||
ItemStack itemstack = player.getCurrentEquippedItem();
|
||||
|
||||
Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3));
|
||||
/*Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3));
|
||||
|
||||
if(Mekanism.teleporters.containsKey(teleCode))
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ public class CommonPlayerTickHandler
|
|||
item.setStatus(itemstack, 4);
|
||||
Mekanism.packetHandler.sendTo(new StatusUpdateMessage(4), (EntityPlayerMP)player);
|
||||
}
|
||||
}
|
||||
}TODO*/
|
||||
}
|
||||
|
||||
if(player.getEquipmentInSlot(1) != null && player.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners)
|
||||
|
|
|
@ -163,9 +163,6 @@ public class Mekanism
|
|||
/** Mekanism version number */
|
||||
public static Version versionNumber = new Version(8, 0, 0);
|
||||
|
||||
/** Map of Teleporters */
|
||||
public static Map<Teleporter.Code, ArrayList<Coord4D>> teleporters = new HashMap<Teleporter.Code, ArrayList<Coord4D>>();
|
||||
|
||||
/** MultiblockManagers for various structrures */
|
||||
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank", TankCache.class);
|
||||
public static MultiblockManager<SynchronizedMatrixData> matrixManager = new MultiblockManager<SynchronizedMatrixData>("inductionMatrix", MatrixCache.class);
|
||||
|
@ -173,7 +170,8 @@ public class Mekanism
|
|||
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
|
||||
|
||||
/** FrequencyManagers for various networks */
|
||||
public static FrequencyManager teleporterManager = new FrequencyManager(Frequency.class);
|
||||
public static FrequencyManager publicTeleporters = new FrequencyManager(Frequency.class);
|
||||
public static Map<String, FrequencyManager> privateTeleporters = new HashMap<String, FrequencyManager>();
|
||||
|
||||
/** Mekanism creative tab */
|
||||
public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism();
|
||||
|
@ -1064,7 +1062,6 @@ public class Mekanism
|
|||
}
|
||||
|
||||
//Clear all cache data
|
||||
teleporters.clear();
|
||||
jetpackOn.clear();
|
||||
gasmaskOn.clear();
|
||||
activeVibrators.clear();
|
||||
|
@ -1072,6 +1069,7 @@ public class Mekanism
|
|||
|
||||
//Reset consistent managers
|
||||
MultiblockManager.reset();
|
||||
FrequencyManager.reset();
|
||||
TransporterManager.reset();
|
||||
PathfinderCache.reset();
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
package mekanism.common;
|
||||
|
||||
public class Teleporter
|
||||
{
|
||||
/**
|
||||
* Code -- a way for teleporters to manage frequencies.
|
||||
* @author aidancbrady
|
||||
*
|
||||
*/
|
||||
public static final class Code
|
||||
{
|
||||
public int digitOne;
|
||||
public int digitTwo;
|
||||
public int digitThree;
|
||||
public int digitFour;
|
||||
|
||||
public Code(int one, int two, int three, int four)
|
||||
{
|
||||
digitOne = one;
|
||||
digitTwo = two;
|
||||
digitThree = three;
|
||||
digitFour = four;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + digitOne;
|
||||
code = 31 * code + digitTwo;
|
||||
code = 31 * code + digitThree;
|
||||
code = 31 * code + digitFour;
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object code)
|
||||
{
|
||||
return code instanceof Code && ((Code)code).digitOne == digitOne && ((Code)code).digitTwo == digitTwo && ((Code)code).digitThree == digitThree && ((Code)code).digitFour == digitFour;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,10 @@ package mekanism.common.frequency;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.PacketHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
@ -12,6 +15,12 @@ public class Frequency
|
|||
public String name;
|
||||
public String owner;
|
||||
|
||||
public boolean valid = true;
|
||||
|
||||
public boolean publicFreq;
|
||||
|
||||
public Set<Coord4D> activeCoords = new HashSet<Coord4D>();
|
||||
|
||||
public Frequency(String n, String o)
|
||||
{
|
||||
name = n;
|
||||
|
@ -28,28 +37,49 @@ public class Frequency
|
|||
read(dataStream);
|
||||
}
|
||||
|
||||
public Frequency setPublic(boolean isPublic)
|
||||
{
|
||||
publicFreq = isPublic;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPublic()
|
||||
{
|
||||
return publicFreq;
|
||||
}
|
||||
|
||||
public boolean isPrivate()
|
||||
{
|
||||
return !publicFreq;
|
||||
}
|
||||
|
||||
public void write(NBTTagCompound nbtTags)
|
||||
{
|
||||
nbtTags.setString("name", name);
|
||||
nbtTags.setString("owner", owner);
|
||||
nbtTags.setBoolean("publicFreq", publicFreq);
|
||||
}
|
||||
|
||||
protected void read(NBTTagCompound nbtTags)
|
||||
{
|
||||
name = nbtTags.getString("name");
|
||||
owner = nbtTags.getString("owner");
|
||||
publicFreq = nbtTags.getBoolean("publicFreq");
|
||||
}
|
||||
|
||||
public void write(ArrayList data)
|
||||
{
|
||||
data.add(name);
|
||||
data.add(owner);
|
||||
data.add(publicFreq);
|
||||
}
|
||||
|
||||
protected void read(ByteBuf dataStream)
|
||||
{
|
||||
name = PacketHandler.readString(dataStream);
|
||||
owner = PacketHandler.readString(dataStream);
|
||||
publicFreq = dataStream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,12 +87,15 @@ public class Frequency
|
|||
{
|
||||
int code = 1;
|
||||
code = 31 * code + name.hashCode();
|
||||
code = 31 * code + owner.hashCode();
|
||||
code = 31 * code + (publicFreq ? 1 : 0);
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof Frequency && ((Frequency)obj).name.equals(name);
|
||||
return obj instanceof Frequency && ((Frequency)obj).name.equals(name)
|
||||
&& ((Frequency)obj).owner.equals(owner) && ((Frequency)obj).publicFreq == publicFreq;
|
||||
}
|
||||
}
|
|
@ -4,8 +4,10 @@ import io.netty.buffer.ByteBuf;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -49,14 +51,47 @@ public class FrequencyManager
|
|||
}
|
||||
}
|
||||
|
||||
public void validateFrequency(Frequency freq)
|
||||
public Frequency update(String user, Coord4D coord, Frequency freq)
|
||||
{
|
||||
if(frequencies.contains(freq))
|
||||
for(Frequency iterFreq : frequencies)
|
||||
{
|
||||
return;
|
||||
if(freq.equals(iterFreq))
|
||||
{
|
||||
iterFreq.activeCoords.add(coord);
|
||||
return iterFreq;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deactivate(Coord4D coord)
|
||||
{
|
||||
for(Frequency freq : frequencies)
|
||||
{
|
||||
freq.activeCoords.remove(coord);
|
||||
}
|
||||
}
|
||||
|
||||
public Frequency validateFrequency(String user, Coord4D coord, Frequency freq)
|
||||
{
|
||||
for(Frequency iterFreq : frequencies)
|
||||
{
|
||||
if(freq.equals(iterFreq))
|
||||
{
|
||||
iterFreq.activeCoords.add(coord);
|
||||
return iterFreq;
|
||||
}
|
||||
}
|
||||
|
||||
if(user.equals(freq.owner))
|
||||
{
|
||||
freq.activeCoords.add(coord);
|
||||
frequencies.add(freq);
|
||||
return freq;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void createOrLoad(World world)
|
||||
|
@ -127,6 +162,17 @@ public class FrequencyManager
|
|||
return owner != null ? owner + "FrequencyHandler" : "FrequencyHandler";
|
||||
}
|
||||
|
||||
public static void reset()
|
||||
{
|
||||
for(FrequencyManager manager : managers)
|
||||
{
|
||||
manager.frequencies.clear();
|
||||
manager.dataHandler = null;
|
||||
}
|
||||
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
public static class FrequencyDataHandler extends WorldSavedData
|
||||
{
|
||||
public FrequencyManager manager;
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.network.PacketPortableTeleport.PortableTeleportMessage;
|
||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||
import mekanism.common.tile.TileEntityTeleporter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PacketPortableTeleport implements IMessageHandler<PortableTeleportMessage, IMessage>
|
||||
{
|
||||
@Override
|
||||
|
@ -39,7 +37,7 @@ public class PacketPortableTeleport implements IMessageHandler<PortableTeleportM
|
|||
|
||||
if(item.getStatus(itemstack) == 1)
|
||||
{
|
||||
Coord4D coords = MekanismUtils.getClosestCoords(new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)), player);
|
||||
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);
|
||||
|
||||
World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId);
|
||||
TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld);
|
||||
|
|
|
@ -13,10 +13,9 @@ import mekanism.api.EnumColor;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.network.PacketPortalFX.PortalFXMessage;
|
||||
import mekanism.common.frequency.FrequencyManager;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -47,9 +46,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
private MinecraftServer server = MinecraftServer.getServer();
|
||||
|
||||
/** This teleporter's frequency. */
|
||||
public Teleporter.Code code;
|
||||
|
||||
public AxisAlignedBB teleportBounds = null;
|
||||
|
||||
public Set<Entity> didTeleport = new HashSet<Entity>();
|
||||
|
@ -63,6 +59,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
public String owner;
|
||||
|
||||
public Frequency frequency;
|
||||
|
||||
public List<Frequency> publicCache = new ArrayList<Frequency>();
|
||||
public List<Frequency> privateCache = new ArrayList<Frequency>();
|
||||
|
||||
/** This teleporter's current status. */
|
||||
public byte status = 0;
|
||||
|
@ -71,7 +70,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
super("Teleporter", MachineType.TELEPORTER.baseEnergy);
|
||||
inventory = new ItemStack[1];
|
||||
code = new Teleporter.Code(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,22 +84,19 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(Mekanism.teleporters.containsKey(code))
|
||||
FrequencyManager manager = getManager(frequency);
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
if(!Mekanism.teleporters.get(code).contains(Coord4D.get(this)) && hasFrame())
|
||||
if(frequency != null && !frequency.valid)
|
||||
{
|
||||
Mekanism.teleporters.get(code).add(Coord4D.get(this));
|
||||
}
|
||||
else if(Mekanism.teleporters.get(code).contains(Coord4D.get(this)) && !hasFrame())
|
||||
{
|
||||
Mekanism.teleporters.get(code).remove(Coord4D.get(this));
|
||||
frequency = manager.validateFrequency(owner, Coord4D.get(this), frequency);
|
||||
}
|
||||
|
||||
frequency = manager.update(owner, Coord4D.get(this), frequency);
|
||||
}
|
||||
else if(hasFrame())
|
||||
{
|
||||
ArrayList<Coord4D> newCoords = new ArrayList<Coord4D>();
|
||||
newCoords.add(Coord4D.get(this));
|
||||
Mekanism.teleporters.put(code, newCoords);
|
||||
else {
|
||||
frequency = null;
|
||||
}
|
||||
|
||||
status = canTeleport();
|
||||
|
@ -131,6 +126,51 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
ChargeUtils.discharge(0, this);
|
||||
}
|
||||
|
||||
public void setFrequency(String name, boolean publicFreq)
|
||||
{
|
||||
FrequencyManager manager = getManager(new Frequency(name, null).setPublic(publicFreq));
|
||||
|
||||
for(Frequency freq : manager.getFrequencies())
|
||||
{
|
||||
if(freq.equals(frequency))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(freq.name.equals(name))
|
||||
{
|
||||
frequency = freq;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Frequency freq = new Frequency(name, owner).setPublic(publicFreq);
|
||||
freq.activeCoords.add(Coord4D.get(this));
|
||||
manager.addFrequency(freq);
|
||||
}
|
||||
|
||||
public FrequencyManager getManager(Frequency freq)
|
||||
{
|
||||
if(owner == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(freq.isPublic())
|
||||
{
|
||||
return Mekanism.publicTeleporters;
|
||||
}
|
||||
else {
|
||||
if(!Mekanism.privateTeleporters.containsKey(owner))
|
||||
{
|
||||
FrequencyManager manager = new FrequencyManager(Frequency.class, owner);
|
||||
Mekanism.privateTeleporters.put(owner, manager);
|
||||
manager.createOrLoad(worldObj);
|
||||
}
|
||||
|
||||
return Mekanism.privateTeleporters.get(owner);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStatusDisplay()
|
||||
{
|
||||
switch(status)
|
||||
|
@ -147,6 +187,38 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.noLink");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
super.onChunkUnload();
|
||||
|
||||
if(!worldObj.isRemote && frequency != null)
|
||||
{
|
||||
FrequencyManager manager = getManager(frequency);
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
manager.deactivate(Coord4D.get(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote && frequency != null)
|
||||
{
|
||||
FrequencyManager manager = getManager(frequency);
|
||||
|
||||
if(manager != null)
|
||||
{
|
||||
manager.deactivate(Coord4D.get(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanTeleportCache()
|
||||
{
|
||||
|
@ -197,26 +269,23 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
//TODO if no link return 3
|
||||
|
||||
if(!Mekanism.teleporters.containsKey(code) || Mekanism.teleporters.get(code).isEmpty())
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if(Mekanism.teleporters.get(code).size() == 2)
|
||||
if(true/*TODO if has link*/)
|
||||
{
|
||||
List<Entity> entitiesInPortal = getToTeleport();
|
||||
|
||||
Coord4D closestCoords = null;
|
||||
|
||||
for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
{
|
||||
if(!coords.equals(Coord4D.get(this)))
|
||||
{
|
||||
closestCoords = coords;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
int electricityNeeded = 0;
|
||||
|
||||
|
@ -244,14 +313,14 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
|
||||
Coord4D closestCoords = null;
|
||||
|
||||
for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
{
|
||||
if(!coords.equals(Coord4D.get(this)))
|
||||
{
|
||||
closestCoords = coords;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for(Entity entity : entitiesInPortal)
|
||||
{
|
||||
|
@ -271,10 +340,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
teleportEntityTo(entity, closestCoords, teleporter);
|
||||
}
|
||||
|
||||
for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
||||
{
|
||||
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D));
|
||||
}
|
||||
}*/
|
||||
|
||||
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
||||
|
||||
|
@ -367,28 +436,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(Mekanism.teleporters.containsKey(code))
|
||||
{
|
||||
if(Mekanism.teleporters.get(code).contains(Coord4D.get(this)))
|
||||
{
|
||||
Mekanism.teleporters.get(code).remove(Coord4D.get(this));
|
||||
}
|
||||
|
||||
if(Mekanism.teleporters.get(code).isEmpty())
|
||||
{
|
||||
Mekanism.teleporters.remove(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int calculateEnergyCost(Entity entity, Coord4D coords)
|
||||
{
|
||||
int energyCost = 1000;
|
||||
|
@ -428,11 +475,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
code.digitOne = nbtTags.getInteger("digitOne");
|
||||
code.digitTwo = nbtTags.getInteger("digitTwo");
|
||||
code.digitThree = nbtTags.getInteger("digitThree");
|
||||
code.digitFour = nbtTags.getInteger("digitFour");
|
||||
|
||||
if(nbtTags.hasKey("owner"))
|
||||
{
|
||||
|
@ -442,6 +484,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
if(nbtTags.hasKey("frequency"))
|
||||
{
|
||||
frequency = new Frequency(nbtTags);
|
||||
frequency.valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,11 +492,6 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("digitOne", code.digitOne);
|
||||
nbtTags.setInteger("digitTwo", code.digitTwo);
|
||||
nbtTags.setInteger("digitThree", code.digitThree);
|
||||
nbtTags.setInteger("digitFour", code.digitFour);
|
||||
|
||||
if(owner != null)
|
||||
{
|
||||
|
@ -471,33 +509,34 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(Mekanism.teleporters.containsKey(code))
|
||||
{
|
||||
if(Mekanism.teleporters.get(code).contains(Coord4D.get(this)))
|
||||
{
|
||||
Mekanism.teleporters.get(code).remove(Coord4D.get(this));
|
||||
}
|
||||
|
||||
if(Mekanism.teleporters.get(code).isEmpty()) Mekanism.teleporters.remove(code);
|
||||
}
|
||||
|
||||
int type = dataStream.readInt();
|
||||
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
code.digitOne = dataStream.readInt();
|
||||
String name = PacketHandler.readString(dataStream);
|
||||
boolean isPublic = dataStream.readBoolean();
|
||||
|
||||
setFrequency(name, isPublic);
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
code.digitTwo = dataStream.readInt();
|
||||
}
|
||||
else if(type == 2)
|
||||
{
|
||||
code.digitThree = dataStream.readInt();
|
||||
}
|
||||
else if(type == 3)
|
||||
{
|
||||
code.digitFour = dataStream.readInt();
|
||||
String freq = PacketHandler.readString(dataStream);
|
||||
boolean isPublic = dataStream.readBoolean();
|
||||
|
||||
FrequencyManager manager = getManager(new Frequency(freq, null).setPublic(isPublic));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -522,11 +561,24 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
}
|
||||
|
||||
status = dataStream.readByte();
|
||||
code.digitOne = dataStream.readInt();
|
||||
code.digitTwo = dataStream.readInt();
|
||||
code.digitThree = dataStream.readInt();
|
||||
code.digitFour = dataStream.readInt();
|
||||
shouldRender = dataStream.readBoolean();
|
||||
|
||||
publicCache.clear();
|
||||
privateCache.clear();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
publicCache.add(new Frequency(dataStream));
|
||||
}
|
||||
|
||||
amount = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < amount; i++)
|
||||
{
|
||||
privateCache.add(new Frequency(dataStream));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -553,11 +605,23 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
}
|
||||
|
||||
data.add(status);
|
||||
data.add(code.digitOne);
|
||||
data.add(code.digitTwo);
|
||||
data.add(code.digitThree);
|
||||
data.add(code.digitFour);
|
||||
data.add(shouldRender);
|
||||
|
||||
data.add(Mekanism.publicTeleporters.getFrequencies().size());
|
||||
|
||||
for(Frequency freq : Mekanism.publicTeleporters.getFrequencies())
|
||||
{
|
||||
freq.write(data);
|
||||
}
|
||||
|
||||
FrequencyManager manager = getManager(new Frequency(null, null).setPublic(false));
|
||||
|
||||
data.add(manager.getFrequencies().size());
|
||||
|
||||
for(Frequency freq : manager.getFrequencies())
|
||||
{
|
||||
freq.write(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -600,31 +664,17 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
|||
teleport();
|
||||
return new Object[] {"Attempted to teleport."};
|
||||
case 5:
|
||||
if(!(arguments[0] instanceof Double) || !(arguments[1] instanceof Double))
|
||||
if(!(arguments[0] instanceof String) || !(arguments[1] instanceof Boolean))
|
||||
{
|
||||
return new Object[] {"Invalid parameters."};
|
||||
}
|
||||
|
||||
int digit = ((Double)arguments[0]).intValue();
|
||||
int newDigit = ((Double)arguments[1]).intValue();
|
||||
|
||||
switch(digit)
|
||||
{
|
||||
case 0:
|
||||
code.digitOne = newDigit;
|
||||
break;
|
||||
case 1:
|
||||
code.digitTwo = newDigit;
|
||||
break;
|
||||
case 2:
|
||||
code.digitThree = newDigit;
|
||||
break;
|
||||
case 3:
|
||||
code.digitFour = newDigit;
|
||||
break;
|
||||
default:
|
||||
return new Object[] {"No digit found."};
|
||||
}
|
||||
|
||||
String freq = ((String)arguments[0]).trim();
|
||||
boolean isPublic = (Boolean)arguments[1];
|
||||
|
||||
setFrequency(freq, isPublic);
|
||||
|
||||
return new Object[] {"Frequency set."};
|
||||
default:
|
||||
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return new Object[] {"Unknown command."};
|
||||
|
|
|
@ -15,8 +15,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
|
@ -32,7 +30,6 @@ import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.OreDictCache;
|
||||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.Tier.InductionCellTier;
|
||||
|
@ -236,7 +233,7 @@ public final class MekanismUtils
|
|||
/**
|
||||
* Returns the closest teleporter between a selection of one or two.
|
||||
*/
|
||||
public static Coord4D getClosestCoords(Teleporter.Code teleCode, EntityPlayer player)
|
||||
/*public static Coord4D getClosestCoords(Teleporter.Code teleCode, EntityPlayer player)
|
||||
{
|
||||
if(Mekanism.teleporters.get(teleCode).size() == 1)
|
||||
{
|
||||
|
@ -284,7 +281,7 @@ public final class MekanismUtils
|
|||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}TODO*/
|
||||
|
||||
/**
|
||||
* Checks if the mod doesn't need an update.
|
||||
|
|
Loading…
Reference in a new issue