Search in sources :

Example 1 with TeleportDestination

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);
}
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 2 with TeleportDestination

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

Aggregations

GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ITextComponent (net.minecraft.util.text.ITextComponent)1