Search in sources :

Example 56 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate 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 57 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate 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)

Example 58 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class PacketGetScreenData method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    modid = NetworkTools.readString(buf);
    pos = new GlobalCoordinate(NetworkTools.readPos(buf), buf.readInt());
    millis = buf.readLong();
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 59 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class SmartWrenchItem method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) {
    if (!world.isRemote) {
        SmartWrenchMode mode = getCurrentMode(stack);
        if (mode == SmartWrenchMode.MODE_SELECT) {
            GlobalCoordinate b = getCurrentBlock(stack);
            if (b != null) {
                if (b.getDimension() != world.provider.dimensionId) {
                    Logging.message(player, EnumChatFormatting.RED + "The selected block is in another dimension!");
                    return true;
                }
                TileEntity te = world.getTileEntity(b.getCoordinate().getX(), b.getCoordinate().getY(), b.getCoordinate().getZ());
                if (te instanceof SmartWrenchSelector) {
                    SmartWrenchSelector smartWrenchSelector = (SmartWrenchSelector) te;
                    smartWrenchSelector.selectBlock(player, x, y, z);
                }
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 60 with GlobalCoordinate

use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.

the class PacketGetTargets method onMessage.

@Override
public PacketTargetsReady onMessage(PacketGetTargets message, MessageContext ctx) {
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    ItemStack heldItem = player.getHeldItem();
    if (heldItem == null) {
        return null;
    }
    NBTTagCompound tagCompound = heldItem.getTagCompound();
    int target = -1;
    int[] targets = new int[AdvancedChargedPorterItem.MAXTARGETS];
    String[] names = new String[AdvancedChargedPorterItem.MAXTARGETS];
    TeleportDestinations destinations = TeleportDestinations.getDestinations(player.worldObj);
    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] = "";
        }
    }
    return new PacketTargetsReady(target, targets, names);
}
Also used : TeleportDestinations(mcjty.rftools.blocks.teleporter.TeleportDestinations) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination)

Aggregations

GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)78 Coordinate (mcjty.lib.varia.Coordinate)33 TileEntity (net.minecraft.tileentity.TileEntity)15 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 World (net.minecraft.world.World)13 NBTTagList (net.minecraft.nbt.NBTTagList)7 ItemStack (net.minecraft.item.ItemStack)6 BlockPos (net.minecraft.util.math.BlockPos)6 ArrayList (java.util.ArrayList)5 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)5 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)4 MovingSound (net.minecraft.client.audio.MovingSound)4 BlockProtectorTileEntity (mcjty.rftools.blocks.blockprotector.BlockProtectorTileEntity)3 PlayerExtendedProperties (mcjty.rftools.playerprops.PlayerExtendedProperties)3 IBlockState (net.minecraft.block.state.IBlockState)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 WorldServer (net.minecraft.world.WorldServer)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3