use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class ShieldBlock method wrenchSneakSelect.
@Override
protected boolean wrenchSneakSelect(World world, int x, int y, int z, EntityPlayer player) {
if (!world.isRemote) {
GlobalCoordinate currentBlock = SmartWrenchItem.getCurrentBlock(player.getHeldItem());
if (currentBlock == null) {
SmartWrenchItem.setCurrentBlock(player.getHeldItem(), new GlobalCoordinate(new Coordinate(x, y, z), world.provider.dimensionId));
Logging.message(player, EnumChatFormatting.YELLOW + "Selected block");
} else {
SmartWrenchItem.setCurrentBlock(player.getHeldItem(), null);
Logging.message(player, EnumChatFormatting.YELLOW + "Cleared selected block");
}
}
return true;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class FavoriteDestinationsProperties method writeFavoritesToNBT.
private static void writeFavoritesToNBT(NBTTagCompound tagCompound, Collection<GlobalCoordinate> destinations) {
NBTTagList lst = new NBTTagList();
for (GlobalCoordinate 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());
lst.appendTag(tc);
}
tagCompound.setTag("destinations", lst);
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class FavoriteDestinationsProperties method readCoordinatesFromNBT.
private static void readCoordinatesFromNBT(NBTTagCompound tagCompound, Set<GlobalCoordinate> destinations) {
NBTTagList lst = tagCompound.getTagList("destinations", net.minecraftforge.common.util.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"));
destinations.add(new GlobalCoordinate(c, tc.getInteger("dim")));
}
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PeacefulAreaManager method isPeaceful.
public static boolean isPeaceful(GlobalCoordinate coordinate) {
if (areas.isEmpty()) {
return false;
}
List<GlobalCoordinate> toRemove = new ArrayList<GlobalCoordinate>();
boolean peaceful = false;
long curtime = System.currentTimeMillis() - 10000;
for (Map.Entry<GlobalCoordinate, PeacefulArea> entry : areas.entrySet()) {
PeacefulArea area = entry.getValue();
GlobalCoordinate entryCoordinate = entry.getKey();
if (area.in(coordinate, entryCoordinate)) {
peaceful = true;
}
if (area.getLastTouched() < curtime) {
// Hasn't been touched for at least 10 seconds. Probably no longer valid.
// To be sure we will first check this by testing if the environmental controller is still active and running.
WorldServer world = DimensionManager.getWorld(entryCoordinate.getDimension());
if (world != null) {
Coordinate c = entryCoordinate.getCoordinate();
// If the world is not loaded we don't do anything and we also don't remove the area since we have no information about it.
if (!world.getChunkProvider().chunkExists(c.getX() >> 4, c.getZ() >> 4)) {
boolean removeArea = true;
TileEntity te = world.getTileEntity(c.getX(), c.getY(), c.getZ());
if (te instanceof EnvironmentalControllerTileEntity) {
EnvironmentalControllerTileEntity controllerTileEntity = (EnvironmentalControllerTileEntity) te;
for (EnvironmentModule module : controllerTileEntity.getEnvironmentModules()) {
if (module instanceof PeacefulEModule) {
if (((PeacefulEModule) module).isActive()) {
removeArea = false;
break;
}
}
}
}
if (removeArea) {
toRemove.add(entryCoordinate);
}
}
}
}
}
for (GlobalCoordinate globalCoordinate : toRemove) {
areas.remove(globalCoordinate);
}
return peaceful;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PacketGetDestinationInfo method onMessage.
@Override
public PacketReturnDestinationInfo onMessage(PacketGetDestinationInfo message, MessageContext ctx) {
World world = ctx.getServerHandler().playerEntity.worldObj;
TeleportDestinations destinations = TeleportDestinations.getDestinations(world);
GlobalCoordinate coordinate = destinations.getCoordinateForId(message.receiverId);
String name;
if (coordinate == null) {
name = "?";
} else {
TeleportDestination destination = destinations.getDestination(coordinate);
if (destination == null) {
name = "?";
} else {
name = destination.getName();
if (name == null || name.isEmpty()) {
name = destination.getCoordinate() + " (" + destination.getDimension() + ")";
}
}
}
return new PacketReturnDestinationInfo(message.receiverId, name);
}
Aggregations