Search in sources :

Example 16 with GlobalCoordinate

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

the class DialingDeviceTileEntity method changeFavorite.

// Server side only.
private void changeFavorite(String playerName, BlockPos receiver, int dimension, boolean favorite) {
    List<EntityPlayerMP> list = ((WorldServer) getWorld()).getMinecraftServer().getPlayerList().getPlayers();
    for (EntityPlayerMP entityplayermp : list) {
        if (playerName.equals(entityplayermp.getName())) {
            FavoriteDestinationsProperties favoriteDestinations = PlayerExtendedProperties.getFavoriteDestinations(entityplayermp);
            favoriteDestinations.setDestinationFavorite(new GlobalCoordinate(receiver, dimension), favorite);
            return;
        }
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) FavoriteDestinationsProperties(mcjty.rftools.playerprops.FavoriteDestinationsProperties)

Example 17 with GlobalCoordinate

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

the class SimpleDialerBlock method addProbeInfo.

@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    super.addProbeInfo(mode, probeInfo, player, world, blockState, data);
    TileEntity te = world.getTileEntity(data.getPos());
    if (te instanceof SimpleDialerTileEntity) {
        SimpleDialerTileEntity simpleDialerTileEntity = (SimpleDialerTileEntity) te;
        GlobalCoordinate trans = simpleDialerTileEntity.getTransmitter();
        if (trans != null) {
            probeInfo.text(TextFormatting.GREEN + "Transmitter at: " + BlockPosTools.toString(trans.getCoordinate()) + " (dim " + trans.getDimension() + ")");
        }
        Integer receiver = simpleDialerTileEntity.getReceiver();
        if (receiver != null) {
            probeInfo.text(TextFormatting.GREEN + "Receiver: " + receiver);
        }
        if (simpleDialerTileEntity.isOnceMode()) {
            probeInfo.text(TextFormatting.GREEN + "Dial Once mode enabled");
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 18 with GlobalCoordinate

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

the class SimpleDialerTileEntity method update.

public void update() {
    if (transmitter == null) {
        return;
    }
    if ((powerLevel > 0) == prevIn) {
        return;
    }
    prevIn = powerLevel > 0;
    markDirty();
    if (powerLevel > 0) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(getWorld());
        BlockPos coordinate = null;
        int dim = 0;
        if (receiver != null) {
            GlobalCoordinate gc = destinations.getCoordinateForId(receiver);
            if (gc != null) {
                coordinate = gc.getCoordinate();
                dim = gc.getDimension();
            }
        }
        int dial = TeleportationTools.dial(getWorld(), null, null, transmitter.getCoordinate(), transmitter.getDimension(), coordinate, dim, onceMode);
        if (dial != DialingDeviceTileEntity.DIAL_OK) {
        // @todo some way to report error
        }
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 19 with GlobalCoordinate

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

the class BlockProtectors method readDestinationsFromNBT.

private void readDestinationsFromNBT(NBTTagCompound tagCompound) {
    NBTTagList lst = tagCompound.getTagList("blocks", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < lst.tagCount(); i++) {
        NBTTagCompound tc = lst.getCompoundTagAt(i);
        Coordinate c = new Coordinate(tc.getInteger("x"), tc.getInteger("y"), tc.getInteger("z"));
        int dim = tc.getInteger("dim");
        GlobalCoordinate gc = new GlobalCoordinate(c, dim);
        int id = tc.getInteger("id");
        protectorById.put(id, gc);
        protectorIdByCoordinate.put(gc, id);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 20 with GlobalCoordinate

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

the class BlockProtectorTileEntity method updateDestination.

/**
 * This method is called after putting down a protector that was earlier wrenched. We need to fix the data in
 * the destination.
 */
public void updateDestination() {
    BlockProtectors protectors = BlockProtectors.getProtectors(worldObj);
    GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
    if (id == -1) {
        id = protectors.getNewId(gc);
        markDirty();
    } else {
        protectors.assignId(gc, id);
    }
    protectors.save(worldObj);
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

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