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