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;
}
}
}
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();
}
}
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;
}
}
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));
}
}
}
}
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");
}
Aggregations