use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class MatterTransmitterTileEntity method setTeleportDestination.
public void setTeleportDestination(TeleportDestination teleportDestination, boolean once) {
this.teleportDestination = null;
this.teleportId = null;
this.once = once;
if (teleportDestination != null) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
Integer id = destinations.getIdForCoordinate(new GlobalCoordinate(teleportDestination.getCoordinate(), teleportDestination.getDimension()));
if (id == null) {
this.teleportDestination = teleportDestination;
} else {
this.teleportId = id;
}
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
markDirty();
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class SimpleDialerItemBlock method checkReceiverAccess.
private boolean checkReceiverAccess(EntityPlayer player, World world, Integer id) {
boolean access = true;
TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
GlobalCoordinate coordinate = destinations.getCoordinateForId(id);
if (coordinate != null) {
TeleportDestination destination = destinations.getDestination(coordinate);
if (destination != null) {
World worldForDimension = RfToolsDimensionManager.getWorldForDimension(destination.getDimension());
if (worldForDimension != null) {
TileEntity recTe = worldForDimension.getTileEntity(destination.getCoordinate().getX(), destination.getCoordinate().getY(), destination.getCoordinate().getZ());
if (recTe instanceof MatterReceiverTileEntity) {
MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) recTe;
if (!matterReceiverTileEntity.checkAccess(player.getDisplayName())) {
access = false;
}
}
}
}
}
return access;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class SimpleDialerTileEntity method checkStateServer.
@Override
protected void checkStateServer() {
// Update is called manuall which is why canUpdate() returns false.
super.checkStateServer();
if (transmitter == null) {
return;
}
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
int newvalue = BlockTools.getRedstoneSignalIn(meta) ? 1 : 0;
if (newvalue != prevValue) {
prevValue = newvalue;
if (newvalue == 1) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
Coordinate 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(worldObj, 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 TeleportDestinations method writeDestinationsToNBT.
private static void writeDestinationsToNBT(NBTTagCompound tagCompound, Collection<TeleportDestination> destinations, Map<GlobalCoordinate, Integer> coordinateToInteger) {
NBTTagList lst = new NBTTagList();
for (TeleportDestination destination : destinations) {
NBTTagCompound tc = new NBTTagCompound();
Coordinate c = destination.getCoordinate();
tc.setInteger("x", c.getX());
tc.setInteger("y", c.getY());
tc.setInteger("z", c.getZ());
tc.setInteger("dim", destination.getDimension());
tc.setString("name", destination.getName());
if (coordinateToInteger != null) {
Integer id = coordinateToInteger.get(new GlobalCoordinate(c, destination.getDimension()));
if (id != null) {
tc.setInteger("id", id);
}
}
lst.appendTag(tc);
}
tagCompound.setTag("destinations", lst);
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class TeleportDestinations method getValidDestinations.
// Server side only
public Collection<TeleportDestinationClientInfo> getValidDestinations(World worldObj, String playerName) {
PlayerExtendedProperties properties = null;
if (playerName != null) {
List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (Object player : list) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) player;
if (playerName.equals(entityplayermp.getDisplayName())) {
properties = PlayerExtendedProperties.getProperties(entityplayermp);
break;
}
}
}
List<TeleportDestinationClientInfo> result = new ArrayList<TeleportDestinationClientInfo>();
for (TeleportDestination destination : destinations.values()) {
TeleportDestinationClientInfo destinationClientInfo = new TeleportDestinationClientInfo(destination);
Coordinate c = destination.getCoordinate();
World world = DimensionManager.getWorld(destination.getDimension());
String dimName = null;
if (world != null) {
dimName = DimensionManager.getProvider(destination.getDimension()).getDimensionName();
}
DimensionInformation information = RfToolsDimensionManager.getDimensionManager(worldObj).getDimensionInformation(destination.getDimension());
if (information != null) {
dimName = information.getName();
}
if (dimName == null || dimName.trim().isEmpty()) {
dimName = "Id " + destination.getDimension();
} else {
dimName = dimName + " (" + destination.getDimension() + ")";
}
destinationClientInfo.setDimensionName(dimName);
if (world != null) {
TileEntity te = world.getTileEntity(c.getX(), c.getY(), c.getZ());
if (te instanceof MatterReceiverTileEntity) {
MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) te;
if (playerName != null && !matterReceiverTileEntity.checkAccess(playerName)) {
// No access.
continue;
}
}
}
if (properties != null) {
destinationClientInfo.setFavorite(properties.getFavoriteDestinationsProperties().isDestinationFavorite(new GlobalCoordinate(c, destination.getDimension())));
}
result.add(destinationClientInfo);
}
Collections.sort(result);
return result;
}
Aggregations