use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class RegionHandler_Vanilla_1_14 method getRegions3.
@Override
public Set<IntVector3> getRegions3(World world) {
HashSet<IntVector3> regionIndices = new HashSet<IntVector3>();
// Add all RegionFile instances in the cache
Object regionFileCache = findRegionFileCache.invoke(null, HandleConversion.toWorldHandle(world));
regionIndices.addAll(findCacheRegionFileCoordinates.invoke(null, regionFileCache));
// Obtain the region coordinates from all files in regions folder
File regionFolder = Common.SERVER.getWorldRegionFolder(world.getName());
if (regionFolder != null) {
String[] regionFileNames = regionFolder.list();
for (String regionFileName : regionFileNames) {
File file = new File(regionFolder, regionFileName);
if (file.isFile() && file.exists() && file.length() >= 4096) {
IntVector3 coords = getRegionFileCoordinates(file).toIntVector3(0);
if (coords != null && !regionIndices.contains(coords)) {
regionIndices.add(coords);
}
}
}
}
// Look at all loaded chunks of the world and add the regions they are inside of
for (Chunk chunk : world.getLoadedChunks()) {
IntVector3 coords = new IntVector3(chunk.getX() >> 5, 0, chunk.getZ() >> 5);
regionIndices.add(coords);
}
return regionIndices;
}
use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class ChunkBlockStateChangeConverter method convertInput.
@Override
public BlockStateChange convertInput(Object value) {
final ClientboundLevelChunkPacketDataHandle.BlockEntityDataHandle handle;
handle = ClientboundLevelChunkPacketDataHandle.BlockEntityDataHandle.createHandle(value);
// Deferred readout of metadata for performance, as we're using reflection
IntVector3 position = handle.getPosition(this.chunkX, this.chunkZ);
BlockStateType type = handle.getType();
CommonTagCompound initialMetadata = handle.getTag();
if (initialMetadata != null) {
// Constant value
return BlockStateChange.deferred(position, type, LogicUtil.constantSupplier(initialMetadata), () -> true);
} else {
// Initialize when first called
final DeferredSupplier<CommonTagCompound> metadataSupplier = DeferredSupplier.of(() -> {
CommonTagCompound metadata = new CommonTagCompound();
handle.setTag(metadata);
return metadata;
});
return BlockStateChange.deferred(position, type, metadataSupplier, metadataSupplier::isInitialized);
}
}
Aggregations