Search in sources :

Example 66 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, Coordinate receiver, int dimension, boolean favorite) {
    List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
    for (Object p : list) {
        EntityPlayerMP entityplayermp = (EntityPlayerMP) p;
        if (playerName.equals(entityplayermp.getDisplayName())) {
            PlayerExtendedProperties properties = PlayerExtendedProperties.getProperties(entityplayermp);
            properties.getFavoriteDestinationsProperties().setDestinationFavorite(new GlobalCoordinate(receiver, dimension), favorite);
            return;
        }
    }
}
Also used : PlayerExtendedProperties(mcjty.rftools.playerprops.PlayerExtendedProperties) ArrayList(java.util.ArrayList) List(java.util.List) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 67 with GlobalCoordinate

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

the class MatterReceiverTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    if (cachedX != xCoord || cachedY != yCoord || cachedZ != zCoord) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        destinations.removeDestination(new Coordinate(cachedX, cachedY, cachedZ), worldObj.provider.dimensionId);
        cachedX = xCoord;
        cachedY = yCoord;
        cachedZ = zCoord;
        GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
        if (id == -1) {
            id = destinations.getNewId(gc);
        } else {
            destinations.assignId(gc, id);
        }
        destinations.addDestination(gc);
        destinations.save(worldObj);
        markDirty();
    }
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 68 with GlobalCoordinate

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

the class RemoteStorageIdRegistry method getRemoteStorage.

public static RemoteStorageTileEntity getRemoteStorage(World world, int id) {
    RemoteStorageIdRegistry registry = RemoteStorageIdRegistry.getRegistry(world);
    if (registry == null) {
        return null;
    }
    GlobalCoordinate coordinate = registry.getStorage(id);
    if (coordinate == null) {
        return null;
    }
    World w = DimensionManager.getWorld(coordinate.getDimension());
    if (w == null) {
        return null;
    }
    Coordinate c = coordinate.getCoordinate();
    boolean exists = w.getChunkProvider().chunkExists(c.getX() >> 4, c.getZ() >> 4);
    if (!exists) {
        return null;
    }
    TileEntity te = w.getTileEntity(c.getX(), c.getY(), c.getZ());
    if (te instanceof RemoteStorageTileEntity) {
        RemoteStorageTileEntity remoteStorageTileEntity = (RemoteStorageTileEntity) te;
        int index = remoteStorageTileEntity.findRemoteIndex(id);
        if (index == -1) {
            return null;
        }
        if (remoteStorageTileEntity.isGlobal(index) || world.provider.dimensionId == coordinate.getDimension()) {
            return remoteStorageTileEntity;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) World(net.minecraft.world.World)

Example 69 with GlobalCoordinate

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

the class RemoteStorageTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    timer--;
    if (timer > 0) {
        return;
    }
    timer = 5;
    int hasPower = isPowerLow() ? 0 : 8;
    int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
    int newmeta = (meta & 0x7) | hasPower;
    if (newmeta != meta) {
        worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newmeta, 2);
    }
    RemoteStorageIdRegistry registry = RemoteStorageIdRegistry.getRegistry(worldObj);
    for (int i = 0; i < 4; i++) {
        if (inventoryHelper.containsItem(i)) {
            ItemStack stack = inventoryHelper.getStackInSlot(i);
            NBTTagCompound tagCompound = stack.getTagCompound();
            if (tagCompound != null && tagCompound.hasKey("id")) {
                int rf;
                if (isGlobal(i)) {
                    rf = ModularStorageConfiguration.remoteShareGlobal;
                } else {
                    rf = ModularStorageConfiguration.remoteShareLocal;
                }
                rf = (int) (rf * (2.0f - getInfusedFactor()) / 2.0f);
                if (getEnergyStored(ForgeDirection.DOWN) < rf) {
                    return;
                }
                consumeEnergy(rf);
                markDirty();
                int id = tagCompound.getInteger("id");
                registry.publishStorage(id, new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId));
            }
        }
    }
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) ItemStack(net.minecraft.item.ItemStack)

Example 70 with GlobalCoordinate

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

the class SimpleDialerTileEntity method readRestorableFromNBT.

@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
    super.readRestorableFromNBT(tagCompound);
    if (tagCompound.hasKey("transX")) {
        transmitter = new GlobalCoordinate(new Coordinate(tagCompound.getInteger("transX"), tagCompound.getInteger("transY"), tagCompound.getInteger("transZ")), tagCompound.getInteger("transDim"));
    } else {
        transmitter = null;
    }
    if (tagCompound.hasKey("receiver")) {
        receiver = tagCompound.getInteger("receiver");
    } else {
        receiver = null;
    }
    onceMode = tagCompound.getBoolean("once");
}
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