use of net.minecraft.world.ChunkCoordIntPair in project LogisticsPipes by RS485.
the class MainProxy method isAnyoneWatching.
// ignores dimension; more stringent check done inside sendPacketToAllWatching
public static boolean isAnyoneWatching(int X, int Z, int dimensionID) {
ChunkCoordIntPair chunk = new ChunkCoordIntPair(X >> 4, Z >> 4);
PlayerCollectionList players = LogisticsEventListener.watcherList.get(chunk);
if (players == null) {
return false;
}
return !players.isEmptyWithoutCheck();
}
use of net.minecraft.world.ChunkCoordIntPair in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class ChunkHandler method forceChunkLoading.
/**
* <h2>Force load chunks</h2>
* collects the chunk positions around the entity and it's sub-entities, and then forces them to load
* @param transport the entity to update
* @param newChunkX the x position of the new chunk
* @param newChunkZ the z position of the new chunk
*/
private static void forceChunkLoading(GenericRailTransport transport, int newChunkX, int newChunkZ) {
/*be sure the ticket is valid, otherwise we just crash*/
if (transport.getChunkTicket() != null) {
ChunkCoordIntPair pair = null;
List<ChunkCoordIntPair> newChunks = new ArrayList<ChunkCoordIntPair>();
/*get the chunks around the new chunk of the main entitiy, this should find 9 chunks (3x3 grid).
* it would probably be a good idea to be sure the chunk limit per ticket will support at least 9 chunks
* if it doesn't, then the settings should change chunkloading to off and stop it before using it*/
for (int x = newChunkX - 1; x <= newChunkX + 1; ++x) {
for (int z = newChunkZ - 1; z <= newChunkZ + 1; ++z) {
newChunks.add(new ChunkCoordIntPair(x, z));
}
}
/*update chunks around the sub-entities, in this case it's the hitbox entities
* this should also find 9 chunks, per hitbox. But we only add the ones we don't already know,
* and we clamp the list length to the max chunk count for the ticket,
* since the user can change that value in forge, and we don't wanna try and bite off more than we can chew*/
for (HitboxHandler.MultipartHitbox hitbox : transport.hitboxHandler.hitboxList) {
for (int x = hitbox.chunkCoordX - 1; x <= hitbox.chunkCoordX + 1; ++x) {
for (int z = hitbox.chunkCoordZ - 1; z <= hitbox.chunkCoordZ + 1; ++z) {
pair = new ChunkCoordIntPair(x, z);
if (!newChunks.contains(pair) && newChunks.size() < transport.getChunkTicket().getMaxChunkListDepth()) {
newChunks.add(pair);
}
}
}
}
/*now we take the list we generated and force the chunks to load.*/
for (ChunkCoordIntPair chunk : newChunks) {
ForgeChunkManager.forceChunk(transport.getChunkTicket(), chunk);
ForgeChunkManager.reorderChunk(transport.getChunkTicket(), chunk);
}
/*now we go through the old list and force any chunks that were previously loaded to unload*/
for (ChunkCoordIntPair oldChunk : transport.chunkLocations) {
if (!newChunks.contains(oldChunk)) {
ForgeChunkManager.unforceChunk(transport.getChunkTicket(), oldChunk);
}
}
/*and lastly we set the old chunk list to the new one*/
transport.chunkLocations = newChunks;
}
}
use of net.minecraft.world.ChunkCoordIntPair in project ArsMagica2 by Mithion.
the class PowerNodeCache method onWorldSave.
@SubscribeEvent
public void onWorldSave(WorldEvent.Save event) {
World world = event.world;
if (world.isRemote)
return;
HashMap<ChunkCoordIntPair, NBTTagCompound> saveData = PowerNodeRegistry.For(world).saveAll();
for (ChunkCoordIntPair pair : saveData.keySet()) {
SaveNBTToFile(world, pair, saveData.get(pair), AMCore.config.savePowerDataOnWorldSave());
}
}
use of net.minecraft.world.ChunkCoordIntPair in project ArsMagica2 by Mithion.
the class PowerNodeRegistry method removePowerNode.
public void removePowerNode(IPowerNode node) {
ChunkCoordIntPair chunk = getChunkFromNode(node);
removePowerNode(chunk, new AMVector3((TileEntity) node));
}
use of net.minecraft.world.ChunkCoordIntPair in project ArsMagica2 by Mithion.
the class RetroactiveWorldgenerator method continueRetrogen.
public void continueRetrogen(World world) {
if (world == null)
return;
int dimensionID = world.provider.dimensionId;
int count = 0;
ArrayList<ChunkCoordIntPair> chunks = deferredChunkGeneration.get(dimensionID);
if (chunks != null && chunks.size() > 0) {
int amt = Math.min(5, chunks.size());
for (int i = 0; i < amt; ++i) {
count++;
ChunkCoordIntPair chunkPos = chunks.get(0);
AMCore.proxy.worldGen.generate(world.rand, chunkPos.chunkXPos, chunkPos.chunkZPos, world, world.getChunkProvider(), world.getChunkProvider());
chunks.remove(0);
}
deferredChunkGeneration.put(dimensionID, chunks);
LogHelper.info("Retro-genned %d chunks, %d left to generate.", count, chunks.size());
}
}
Aggregations