use of net.minecraft.world.chunk.WorldChunk in project ImmersivePortalsMod by qouteall.
the class ClientTeleportationManager method amendChunkEntityStatus.
private void amendChunkEntityStatus(Entity entity) {
WorldChunk worldChunk1 = entity.world.getWorldChunk(entity.getBlockPos());
Chunk chunk2 = entity.world.getChunk(entity.chunkX, entity.chunkZ);
removeEntityFromChunk(entity, worldChunk1);
if (chunk2 instanceof WorldChunk) {
removeEntityFromChunk(entity, ((WorldChunk) chunk2));
}
worldChunk1.addEntity(entity);
}
use of net.minecraft.world.chunk.WorldChunk in project Hypnotic-Client by Hypnotic-Development.
the class WorldChunkIterator method next.
@Override
public WorldChunk next() {
WorldChunk chunk = this.chunk;
nextChunk();
return chunk;
}
use of net.minecraft.world.chunk.WorldChunk in project Hypnotic-Client by Hypnotic-Development.
the class WorldUtils method getLoadedChunks.
public static List<WorldChunk> getLoadedChunks() {
List<WorldChunk> chunks = new ArrayList<>();
int viewDist = mc.options.viewDistance;
for (int x = -viewDist; x <= viewDist; x++) {
for (int z = -viewDist; z <= viewDist; z++) {
WorldChunk chunk = mc.world.getChunkManager().getWorldChunk((int) mc.player.getX() / 16 + x, (int) mc.player.getZ() / 16 + z);
if (chunk != null) {
chunks.add(chunk);
}
}
}
return chunks;
}
use of net.minecraft.world.chunk.WorldChunk in project SeedMapper by xpple.
the class SeedOverlayCommand method seedOverlay.
private static int seedOverlay(CustomClientCommandSource source) throws CommandSyntaxException {
long seed = SharedHelpers.getSeed();
String dimensionPath;
if (source.getMeta("dimension") == null) {
dimensionPath = source.getWorld().getRegistryKey().getValue().getPath();
} else {
dimensionPath = ((Identifier) source.getMeta("dimension")).getPath();
}
Dimension dimension = SharedHelpers.getDimension(dimensionPath);
MCVersion mcVersion;
if (source.getMeta("version") == null) {
mcVersion = SharedHelpers.getMCVersion(CLIENT.getGame().getVersion().getName());
} else {
mcVersion = (MCVersion) source.getMeta("version");
}
BiomeSource biomeSource = BiomeSource.of(dimension, mcVersion, seed);
TerrainGenerator generator = TerrainGenerator.of(dimension, biomeSource);
final SimpleBlockMap map = new SimpleBlockMap(mcVersion, dimension, Biomes.PLAINS);
BlockPos.Mutable mutable = new BlockPos.Mutable();
final BlockPos center = new BlockPos(source.getPosition());
final WorldChunk chunk = source.getWorld().getChunk(center.getX() >> 4, center.getZ() >> 4);
final ChunkPos chunkPos = chunk.getPos();
Map<Box, String> boxes = new HashMap<>();
int blocks = 0;
for (int x = chunkPos.getStartX(); x <= chunkPos.getEndX(); x++) {
mutable.setX(x);
for (int z = chunkPos.getStartZ(); z <= chunkPos.getEndZ(); z++) {
mutable.setZ(z);
final var column = generator.getColumnAt(x, z);
final Biome biome = biomeSource.getBiome(x, 0, z);
map.setBiome(biome);
for (int y = 0; y < column.length; y++) {
mutable.setY(y);
final var terrainBlock = chunk.getBlockState(mutable).getBlock();
String terrainBlockName = Registry.BLOCK.getId(terrainBlock).getPath();
if (Config.getIgnoredBlocks().contains(terrainBlockName)) {
continue;
}
if (map.get(terrainBlock) == column[y].getId()) {
continue;
}
boxes.put(new Box(mutable), terrainBlockName);
Chat.print("", chain(highlight(new TranslatableText("command.seedoverlay.feedback.0")), copy(hover(accent("x: " + x + ", y: " + y + ", z: " + z), chain(base(new TranslatableText("command.seedoverlay.feedback.1")), highlight(terrainBlockName))), String.format("%d %d %d", x, y, z)), highlight(new TranslatableText("command.seedoverlay.feedback.2"))));
blocks++;
}
}
}
boxes.forEach((key, value) -> RenderQueue.addCuboid(RenderQueue.Layer.ON_TOP, key, key, Config.getColors().get(value), 30 * 20));
if (blocks > 0) {
Chat.print("", chain(highlight(new TranslatableText("command.seedoverlay.feedback.3")), accent(String.valueOf(blocks)), highlight(new TranslatableText("command.seedoverlay.feedback.4"))));
} else {
Chat.print("", highlight(new TranslatableText("command.seedoverlay.feedback.5")));
}
return blocks;
}
use of net.minecraft.world.chunk.WorldChunk in project SeedMapper by xpple.
the class TerrainVersionCommand method execute.
private int execute(CustomClientCommandSource source) throws CommandSyntaxException {
long seed = SharedHelpers.getSeed();
String dimensionPath;
if (source.getMeta("dimension") == null) {
dimensionPath = source.getWorld().getRegistryKey().getValue().getPath();
} else {
dimensionPath = ((Identifier) source.getMeta("dimension")).getPath();
}
Dimension dimension = SharedHelpers.getDimension(dimensionPath);
final AtomicInteger blocks = new AtomicInteger(Integer.MAX_VALUE);
final AtomicReference<String> version = new AtomicReference<>();
Arrays.stream(MCVersion.values()).filter(mcVersion -> mcVersion.isNewerThan(MCVersion.v1_10_2)).forEach(mcVersion -> {
BiomeSource biomeSource = BiomeSource.of(dimension, mcVersion, seed);
TerrainGenerator generator = TerrainGenerator.of(dimension, biomeSource);
SimpleBlockMap map = new SimpleBlockMap(mcVersion, dimension, Biomes.PLAINS);
BlockPos.Mutable mutable = new BlockPos.Mutable();
final BlockPos center = new BlockPos(source.getPosition());
final WorldChunk chunk = source.getWorld().getChunk(center.getX() >> 4, center.getZ() >> 4);
final ChunkPos chunkPos = chunk.getPos();
int newBlocks = 0;
for (int x = chunkPos.getStartX(); x <= chunkPos.getEndX(); x++) {
mutable.setX(x);
for (int z = chunkPos.getStartZ(); z <= chunkPos.getEndZ(); z++) {
mutable.setZ(z);
final Block[] column = generator.getColumnAt(x, z);
final Biome biome = biomeSource.getBiome(x, 0, z);
map.setBiome(biome);
for (int y = 0; y < column.length; y++) {
mutable.setY(y);
int seedBlockInt = column[y].getId();
int terrainBlockInt = map.get(chunk.getBlockState(mutable).getBlock());
if (seedBlockInt == terrainBlockInt) {
continue;
}
newBlocks++;
}
}
}
if (newBlocks < blocks.get()) {
blocks.set(newBlocks);
version.set(mcVersion.name);
}
});
if (version.get().startsWith("1")) {
Chat.print("", chain(accent(version.get()), highlight(new TranslatableText("command.terrainversion.feedback"))));
} else {
Chat.print("", highlight(version.get()));
}
return Command.SINGLE_SUCCESS;
}
Aggregations