Teleporting works! Tomorrow I'll try and implement the Portable Teleporter.
This commit is contained in:
parent
cefd4ba107
commit
d16a6f06ee
|
@ -54,6 +54,47 @@ public class Frequency
|
||||||
return !publicFreq;
|
return !publicFreq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Coord4D getClosestCoords(Coord4D coord)
|
||||||
|
{
|
||||||
|
Coord4D closest = null;
|
||||||
|
|
||||||
|
for(Coord4D iterCoord : activeCoords)
|
||||||
|
{
|
||||||
|
if(iterCoord.equals(coord))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(closest == null)
|
||||||
|
{
|
||||||
|
closest = iterCoord;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coord.dimensionId != closest.dimensionId && coord.dimensionId == iterCoord.dimensionId)
|
||||||
|
{
|
||||||
|
closest = iterCoord;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if(coord.dimensionId == closest.dimensionId && coord.dimensionId != iterCoord.dimensionId)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(coord.distanceTo(closest) > coord.distanceTo(iterCoord))
|
||||||
|
{
|
||||||
|
closest = iterCoord;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
public void write(NBTTagCompound nbtTags)
|
public void write(NBTTagCompound nbtTags)
|
||||||
{
|
{
|
||||||
nbtTags.setString("name", name);
|
nbtTags.setString("name", name);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.block.BlockMachine.MachineType;
|
import mekanism.common.block.BlockMachine.MachineType;
|
||||||
import mekanism.common.frequency.Frequency;
|
import mekanism.common.frequency.Frequency;
|
||||||
import mekanism.common.frequency.FrequencyManager;
|
import mekanism.common.frequency.FrequencyManager;
|
||||||
|
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;
|
||||||
|
@ -126,6 +127,16 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
ChargeUtils.discharge(0, this);
|
ChargeUtils.discharge(0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Coord4D getClosest()
|
||||||
|
{
|
||||||
|
if(frequency != null)
|
||||||
|
{
|
||||||
|
return frequency.getClosestCoords(Coord4D.get(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFrequency(String name, boolean publicFreq)
|
public void setFrequency(String name, boolean publicFreq)
|
||||||
{
|
{
|
||||||
if(name.equals(frequency))
|
if(name.equals(frequency))
|
||||||
|
@ -275,22 +286,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO if no link return 3
|
if(getClosest() == null)
|
||||||
|
|
||||||
if(true/*TODO if has link*/)
|
|
||||||
{
|
{
|
||||||
List<Entity> entitiesInPortal = getToTeleport();
|
return 3;
|
||||||
|
|
||||||
Coord4D closestCoords = null;
|
|
||||||
|
|
||||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
|
||||||
{
|
|
||||||
if(!coords.equals(Coord4D.get(this)))
|
|
||||||
{
|
|
||||||
closestCoords = coords;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
List<Entity> entitiesInPortal = getToTeleport();
|
||||||
|
Coord4D closestCoords = getClosest();
|
||||||
|
|
||||||
int electricityNeeded = 0;
|
int electricityNeeded = 0;
|
||||||
|
|
||||||
|
@ -307,25 +309,18 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void teleport()
|
public void teleport()
|
||||||
{
|
{
|
||||||
if(worldObj.isRemote) return;
|
if(worldObj.isRemote) return;
|
||||||
|
|
||||||
List<Entity> entitiesInPortal = getToTeleport();
|
List<Entity> entitiesInPortal = getToTeleport();
|
||||||
|
|
||||||
Coord4D closestCoords = null;
|
Coord4D closestCoords = getClosest();
|
||||||
|
|
||||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
if(closestCoords == null)
|
||||||
{
|
{
|
||||||
if(!coords.equals(Coord4D.get(this)))
|
return;
|
||||||
{
|
|
||||||
closestCoords = coords;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
for(Entity entity : entitiesInPortal)
|
for(Entity entity : entitiesInPortal)
|
||||||
{
|
{
|
||||||
|
@ -345,10 +340,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe
|
||||||
teleportEntityTo(entity, closestCoords, teleporter);
|
teleportEntityTo(entity, closestCoords, teleporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*for(Coord4D coords : Mekanism.teleporters.get(code))
|
for(Coord4D coords : frequency.activeCoords)
|
||||||
{
|
{
|
||||||
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D));
|
Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D));
|
||||||
}*/
|
}
|
||||||
|
|
||||||
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords));
|
||||||
|
|
||||||
|
|
|
@ -230,59 +230,6 @@ public final class MekanismUtils
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the closest teleporter between a selection of one or two.
|
|
||||||
*/
|
|
||||||
/*public static Coord4D getClosestCoords(Teleporter.Code teleCode, EntityPlayer player)
|
|
||||||
{
|
|
||||||
if(Mekanism.teleporters.get(teleCode).size() == 1)
|
|
||||||
{
|
|
||||||
return Mekanism.teleporters.get(teleCode).get(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int dimensionId = player.worldObj.provider.dimensionId;
|
|
||||||
|
|
||||||
Coord4D coords0 = Mekanism.teleporters.get(teleCode).get(0);
|
|
||||||
Coord4D coords1 = Mekanism.teleporters.get(teleCode).get(1);
|
|
||||||
|
|
||||||
int distance0 = (int)player.getDistance(coords0.xCoord, coords0.yCoord, coords0.zCoord);
|
|
||||||
int distance1 = (int)player.getDistance(coords1.xCoord, coords1.yCoord, coords1.zCoord);
|
|
||||||
|
|
||||||
if(dimensionId == coords0.dimensionId && dimensionId != coords1.dimensionId)
|
|
||||||
{
|
|
||||||
return coords0;
|
|
||||||
}
|
|
||||||
else if(dimensionId == coords1.dimensionId && dimensionId != coords0.dimensionId)
|
|
||||||
{
|
|
||||||
return coords1;
|
|
||||||
}
|
|
||||||
else if(dimensionId == coords0.dimensionId && dimensionId == coords1.dimensionId)
|
|
||||||
{
|
|
||||||
if(distance0 < distance1)
|
|
||||||
{
|
|
||||||
return coords0;
|
|
||||||
}
|
|
||||||
else if(distance0 > distance1)
|
|
||||||
{
|
|
||||||
return coords1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(dimensionId != coords0.dimensionId && dimensionId != coords1.dimensionId)
|
|
||||||
{
|
|
||||||
if(distance0 < distance1)
|
|
||||||
{
|
|
||||||
return coords0;
|
|
||||||
}
|
|
||||||
else if(distance0 > distance1)
|
|
||||||
{
|
|
||||||
return coords1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}TODO*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the mod doesn't need an update.
|
* Checks if the mod doesn't need an update.
|
||||||
* @return if mod doesn't need an update
|
* @return if mod doesn't need an update
|
||||||
|
|
Loading…
Reference in a new issue