Search in sources :

Example 1 with TeleportDestinations

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;
            }
        }
    }
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TeleportDestinations

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());
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations)

Example 3 with TeleportDestinations

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);
        }
    }
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) TeleportDestinationClientInfo(mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 4 with TeleportDestinations

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);
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TextComponentString(net.minecraft.util.text.TextComponentString) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination)

Example 5 with TeleportDestinations

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));
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World)

Aggregations

TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)5 TextComponentString (net.minecraft.util.text.TextComponentString)3 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)1 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)1 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 World (net.minecraft.world.World)1