use of net.minecraft.world.chunk.AbstractChunkProvider in project dynmap by webbukkit.
the class ForgeMapChunkCache method setChunks.
public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
this.dw = dw;
this.w = dw.getWorld();
if (dw.isLoaded()) {
/* Check if world's provider is ServerChunkProvider */
AbstractChunkProvider cp = this.w.getChunkProvider();
if (cp instanceof ServerChunkProvider) {
cps = (ServerChunkProvider) cp;
} else {
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
}
} else {
chunks = new ArrayList<DynmapChunk>();
}
nsect = dw.worldheight >> 4;
this.chunks = chunks;
/* Compute range */
if (chunks.size() == 0) {
this.x_min = 0;
this.x_max = 0;
this.z_min = 0;
this.z_max = 0;
x_dim = 1;
} else {
x_min = x_max = chunks.get(0).x;
z_min = z_max = chunks.get(0).z;
for (DynmapChunk c : chunks) {
if (c.x > x_max) {
x_max = c.x;
}
if (c.x < x_min) {
x_min = c.x;
}
if (c.z > z_max) {
z_max = c.z;
}
if (c.z < z_min) {
z_min = c.z;
}
}
x_dim = x_max - x_min + 1;
}
snapcnt = x_dim * (z_max - z_min + 1);
snaparray = new ChunkSnapshot[snapcnt];
snaptile = new DynIntHashMap[snapcnt];
isSectionNotEmpty = new boolean[snapcnt][];
}
use of net.minecraft.world.chunk.AbstractChunkProvider in project dynmap by webbukkit.
the class ForgeMapChunkCache method setChunks.
public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
this.dw = dw;
this.w = dw.getWorld();
if (dw.isLoaded()) {
/* Check if world's provider is ServerChunkProvider */
AbstractChunkProvider cp = this.w.getChunkProvider();
if (cp instanceof ServerChunkProvider) {
cps = (ServerChunkProvider) cp;
} else {
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
}
} else {
chunks = new ArrayList<DynmapChunk>();
}
nsect = dw.worldheight >> 4;
this.chunks = chunks;
/* Compute range */
if (chunks.size() == 0) {
this.x_min = 0;
this.x_max = 0;
this.z_min = 0;
this.z_max = 0;
x_dim = 1;
} else {
x_min = x_max = chunks.get(0).x;
z_min = z_max = chunks.get(0).z;
for (DynmapChunk c : chunks) {
if (c.x > x_max) {
x_max = c.x;
}
if (c.x < x_min) {
x_min = c.x;
}
if (c.z > z_max) {
z_max = c.z;
}
if (c.z < z_min) {
z_min = c.z;
}
}
x_dim = x_max - x_min + 1;
}
snapcnt = x_dim * (z_max - z_min + 1);
snaparray = new ChunkSnapshot[snapcnt];
snaptile = new DynIntHashMap[snapcnt];
isSectionNotEmpty = new boolean[snapcnt][];
}
use of net.minecraft.world.chunk.AbstractChunkProvider in project FastAsyncWorldEdit by IntellectualSites.
the class ForgeWorld method regenerate.
@Override
public boolean regenerate(Region region, EditSession editSession) {
// Don't even try to regen if it's going to fail.
AbstractChunkProvider provider = getWorld().getChunkProvider();
if (!(provider instanceof ServerChunkProvider)) {
return false;
}
File saveFolder = Files.createTempDir();
// register this just in case something goes wrong
// normally it should be deleted at the end of this method
saveFolder.deleteOnExit();
try {
ServerWorld originalWorld = (ServerWorld) getWorld();
MinecraftServer server = originalWorld.getServer();
SaveHandler saveHandler = new SaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer());
try (World freshWorld = new ServerWorld(server, server.getBackgroundExecutor(), saveHandler, originalWorld.getWorldInfo(), originalWorld.dimension.getType(), originalWorld.getProfiler(), new NoOpChunkStatusListener())) {
// Pre-gen all the chunks
// We need to also pull one more chunk in every direction
CuboidRegion expandedPreGen = new CuboidRegion(region.getMinimumPoint().subtract(16, 0, 16), region.getMaximumPoint().add(16, 0, 16));
for (BlockVector2 chunk : expandedPreGen.getChunks()) {
freshWorld.getChunk(chunk.getBlockX(), chunk.getBlockZ());
}
ForgeWorld from = new ForgeWorld(freshWorld);
for (BlockVector3 vec : region) {
editSession.setBlock(vec, from.getFullBlock(vec));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
} catch (MaxChangedBlocksException e) {
throw new RuntimeException(e);
} finally {
saveFolder.delete();
}
return true;
}
use of net.minecraft.world.chunk.AbstractChunkProvider in project minecolonies by Minecolonies.
the class WorldUtil method getEntitiesWithinBuilding.
/**
* Get all entities within a building.
*
* @param world the world to check this for.
* @param clazz the entity class.
* @param building the building to check the range for.
* @param predicate the predicate to check
* @param <T> the type of the predicate.
* @return a list of all within those borders.
*/
public static <T extends Entity> List<T> getEntitiesWithinBuilding(@NotNull final World world, @NotNull final Class<? extends T> clazz, @NotNull final IBuilding building, @Nullable final Predicate<? super T> predicate) {
final Tuple<BlockPos, BlockPos> corners = building.getCorners();
int minX = corners.getA().getX() >> 4;
int maxX = corners.getB().getX() >> 4;
int minZ = corners.getA().getZ() >> 4;
int maxZ = corners.getB().getZ() >> 4;
int minY = Math.max(0, corners.getA().getY()) >> 4;
int maxY = Math.min(corners.getB().getY(), world.getHeight()) >> 4;
List<T> list = Lists.newArrayList();
AbstractChunkProvider abstractchunkprovider = world.getChunkSource();
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
if (isEntityChunkLoaded(world, x, z)) {
Chunk chunk = abstractchunkprovider.getChunkNow(x, z);
if (chunk != null) {
for (int y = minY; y <= maxY; y++) {
for (final T entity : chunk.getEntitySections()[y].find(clazz)) {
if (building.isInBuilding(entity.blockPosition()) && (predicate == null || predicate.test(entity))) {
list.add(entity);
}
}
}
}
}
}
}
return list;
}
use of net.minecraft.world.chunk.AbstractChunkProvider in project dynmap by webbukkit.
the class ForgeMapChunkCache method setChunks.
public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
this.w = (ServerWorld) dw.getWorld();
if (dw.isLoaded()) {
/* Check if world's provider is ServerChunkProvider */
AbstractChunkProvider cp = this.w.getChunkProvider();
if (cp instanceof ServerChunkProvider) {
cps = (ServerChunkProvider) cp;
} else {
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
}
}
super.setChunks(dw, chunks);
}
Aggregations