use of mcjty.rftools.blocks.teleporter.TeleportDestination in project RFTools by McJty.
the class PorterTools method returnTargets.
public static void returnTargets(EntityPlayer player) {
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem.isEmpty()) {
return;
}
NBTTagCompound tagCompound = heldItem.getTagCompound();
int target = -1;
int[] targets = new int[AdvancedChargedPorterItem.MAXTARGETS];
String[] names = new String[AdvancedChargedPorterItem.MAXTARGETS];
TeleportDestinations destinations = TeleportDestinations.getDestinations(player.getEntityWorld());
if (tagCompound != null) {
if (tagCompound.hasKey("target")) {
target = tagCompound.getInteger("target");
} else {
target = -1;
}
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
names[i] = "";
if (tagCompound.hasKey("target" + i)) {
targets[i] = tagCompound.getInteger("target" + i);
GlobalCoordinate gc = destinations.getCoordinateForId(targets[i]);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
names[i] = destination.getName() + " (dimension " + destination.getDimension() + ")";
}
}
} else {
targets[i] = -1;
}
}
} else {
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
targets[i] = -1;
names[i] = "";
}
}
PacketTargetsReady msg = new PacketTargetsReady(target, targets, names);
RFToolsMessages.INSTANCE.sendTo(msg, (EntityPlayerMP) player);
}
use of mcjty.rftools.blocks.teleporter.TeleportDestination in project RFTools by McJty.
the class PorterTools method checkTarget.
private static int checkTarget(EntityPlayer playerEntity, NBTTagCompound tagCompound, TeleportDestinations destinations, int curtarget, int donext, int tgt) {
if (tagCompound.hasKey("target" + tgt)) {
int target = tagCompound.getInteger("target" + tgt);
GlobalCoordinate gc = destinations.getCoordinateForId(target);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
if (donext == 1) {
String name = destination.getName() + " (dimension " + destination.getDimension() + ")";
tagCompound.setInteger("target", target);
ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Target: " + TextFormatting.WHITE + name);
if (playerEntity != null) {
playerEntity.sendStatusMessage(component, false);
}
donext = 2;
} else if (target == curtarget) {
donext = 1;
}
}
}
}
return donext;
}
Aggregations