use of mcjty.rftools.blocks.teleporter.TeleportDestinations in project RFTools by McJty.
the class PorterTools method cycleDestination.
public static void cycleDestination(EntityPlayer player, boolean next) {
ItemStack stack = player.getHeldItemMainhand();
if (!stack.isEmpty() && stack.getItem() instanceof AdvancedChargedPorterItem) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
return;
}
TeleportDestinations destinations = TeleportDestinations.getDestinations(player.getEntityWorld());
int curtarget = tagCompound.getInteger("target");
int donext = 0;
// To wrap around we cycle through the list twice
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS * 2; i++) {
int tgt;
if (next) {
tgt = i % AdvancedChargedPorterItem.MAXTARGETS;
} else {
tgt = (AdvancedChargedPorterItem.MAXTARGETS * 2 - i) % AdvancedChargedPorterItem.MAXTARGETS;
}
donext = checkTarget(player, tagCompound, destinations, curtarget, donext, tgt);
if (donext == 2) {
break;
}
}
}
}
use of mcjty.rftools.blocks.teleporter.TeleportDestinations in project RFTools by McJty.
the class CmdCleanupReceivers method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(sender.getEntityWorld());
destinations.cleanupInvalid(sender.getEntityWorld());
}
use of mcjty.rftools.blocks.teleporter.TeleportDestinations in project RFTools by McJty.
the class CmdListReceivers method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(sender.getEntityWorld());
Collection<TeleportDestinationClientInfo> validDestinations = destinations.getValidDestinations(sender.getEntityWorld(), null);
for (TeleportDestinationClientInfo clientInfo : validDestinations) {
int id = clientInfo.getDimension();
ITextComponent component = new TextComponentString(" Receiver: dimension=" + id + ", location=" + BlockPosTools.toString(clientInfo.getCoordinate()));
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
}
}
use of mcjty.rftools.blocks.teleporter.TeleportDestinations 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.TeleportDestinations in project RFTools by McJty.
the class PorterTools method returnDestinationInfo.
public static void returnDestinationInfo(EntityPlayer player, int receiverId) {
World world = player.getEntityWorld();
TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
String name = TeleportDestinations.getDestinationName(destinations, receiverId);
RFToolsMessages.sendToClient(player, ClientCommandHandler.CMD_RETURN_DESTINATION_INFO, Arguments.builder().value(receiverId).value(name));
}
Aggregations