use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class MatterReceiverTileEntity method getOrCalculateID.
public int getOrCalculateID() {
if (id == -1) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
id = destinations.getNewId(gc);
destinations.save(worldObj);
setId(id);
}
return id;
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class MatterReceiverTileEntity method updateDestination.
/**
* This method is called after putting down a receiver that was earlier wrenched. We need to fix the data in
* the destination.
*/
public void updateDestination() {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
TeleportDestination destination = destinations.getDestination(gc.getCoordinate(), gc.getDimension());
if (destination != null) {
destination.setName(name);
if (id == -1) {
id = destinations.getNewId(gc);
markDirty();
} else {
destinations.assignId(gc, id);
}
destinations.save(worldObj);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class MatterTransmitterTileEntity method readRestorableFromNBT.
@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
super.readRestorableFromNBT(tagCompound);
name = tagCompound.getString("tpName");
Coordinate c = Coordinate.readFromNBT(tagCompound, "dest");
if (c == null) {
teleportDestination = null;
} else {
int dim = tagCompound.getInteger("dim");
teleportDestination = new TeleportDestination(c, dim);
}
if (tagCompound.hasKey("destId")) {
teleportId = tagCompound.getInteger("destId");
} else {
teleportId = null;
}
privateAccess = tagCompound.getBoolean("private");
beamHidden = tagCompound.getBoolean("hideBeam");
once = tagCompound.getBoolean("once");
allowedPlayers.clear();
NBTTagList playerList = tagCompound.getTagList("players", Constants.NBT.TAG_STRING);
if (playerList != null) {
for (int i = 0; i < playerList.tagCount(); i++) {
String player = playerList.getStringTagAt(i);
allowedPlayers.add(player);
}
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class MatterTransmitterTileEntity method startTeleportation.
public void startTeleportation(Entity entity) {
if (cooldownTimer > 0) {
// In cooldown. We can't do teleport right now.
return;
}
if (teleportingPlayer != null) {
// Already teleporting
return;
}
if (!(entity instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) entity;
TeleportDestination dest = teleportDestination;
if (teleportId != null) {
dest = getTeleportDestination();
}
if (dest != null && dest.isValid()) {
Coordinate cthis = new Coordinate(xCoord, yCoord, zCoord);
int cost = TeleportationTools.calculateRFCost(worldObj, cthis, dest);
cost = (int) (cost * (4.0f - getInfusedFactor()) / 4.0f);
if (getEnergyStored(ForgeDirection.DOWN) < cost) {
Logging.warn(player, "Not enough power to start the teleport!");
cooldownTimer = 80;
return;
}
int srcId = worldObj.provider.dimensionId;
int dstId = dest.getDimension();
if (!TeleportationTools.checkValidTeleport(player, srcId, dstId)) {
cooldownTimer = 80;
return;
}
Logging.message(player, "Start teleportation...");
teleportingPlayer = player;
teleportTimer = TeleportationTools.calculateTime(worldObj, cthis, dest);
teleportTimer = (int) (teleportTimer * (1.2f - getInfusedFactor()) / 1.2f);
int rf = TeleportConfiguration.rfTeleportPerTick;
rf = (int) (rf * (4.0f - getInfusedFactor()) / 4.0f);
int totalRfUsed = cost + rf * (teleportTimer + 1);
rfPerTick = totalRfUsed / (teleportTimer + 1);
totalTicks = teleportTimer;
goodTicks = 0;
badTicks = 0;
} else {
Logging.warn(player, "Something is wrong with the destination!");
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class GuiDialingDevice method checkStatus.
private void checkStatus() {
int receiverSelected = receiverList.getSelected();
TeleportDestination destination = getSelectedReceiver(receiverSelected);
if (destination == null) {
return;
}
Coordinate c = destination.getCoordinate();
RFToolsMessages.INSTANCE.sendToServer(new PacketRequestIntegerFromServer(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, DialingDeviceTileEntity.CMD_CHECKSTATUS, DialingDeviceTileEntity.CLIENTCMD_STATUS, new Argument("c", c), new Argument("dim", destination.getDimension())));
lastCheckedReceiver = true;
listDirty = 0;
}
Aggregations