Search in sources :

Example 11 with WorldChunk

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);
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk) WorldChunk(net.minecraft.world.chunk.WorldChunk) Chunk(net.minecraft.world.chunk.Chunk)

Example 12 with WorldChunk

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;
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk)

Example 13 with WorldChunk

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;
}
Also used : WorldChunk(net.minecraft.world.chunk.WorldChunk) ArrayList(java.util.ArrayList)

Example 14 with WorldChunk

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;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) HashMap(java.util.HashMap) Box(net.minecraft.util.math.Box) Dimension(com.seedfinding.mccore.state.Dimension) SimpleBlockMap(dev.xpple.seedmapper.util.maps.SimpleBlockMap) MCVersion(com.seedfinding.mccore.version.MCVersion) Biome(com.seedfinding.mcbiome.biome.Biome) WorldChunk(net.minecraft.world.chunk.WorldChunk) BiomeSource(com.seedfinding.mcbiome.source.BiomeSource) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) TerrainGenerator(com.seedfinding.mcterrain.TerrainGenerator)

Example 15 with WorldChunk

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;
}
Also used : Arrays(java.util.Arrays) MCVersion(com.seedfinding.mccore.version.MCVersion) Dimension(com.seedfinding.mccore.state.Dimension) Command(com.mojang.brigadier.Command) BiomeSource(com.seedfinding.mcbiome.source.BiomeSource) ChatBuilder(dev.xpple.seedmapper.util.chat.ChatBuilder) TranslatableText(net.minecraft.text.TranslatableText) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) Block(com.seedfinding.mccore.block.Block) AtomicReference(java.util.concurrent.atomic.AtomicReference) SimpleBlockMap(dev.xpple.seedmapper.util.maps.SimpleBlockMap) Chat(dev.xpple.seedmapper.util.chat.Chat) WorldChunk(net.minecraft.world.chunk.WorldChunk) Biomes(com.seedfinding.mcbiome.biome.Biomes) TerrainGenerator(com.seedfinding.mcterrain.TerrainGenerator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SharedHelpers(dev.xpple.seedmapper.command.SharedHelpers) Identifier(net.minecraft.util.Identifier) CustomClientCommandSource(dev.xpple.seedmapper.command.CustomClientCommandSource) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) Biome(com.seedfinding.mcbiome.biome.Biome) ClientCommand(dev.xpple.seedmapper.command.ClientCommand) TranslatableText(net.minecraft.text.TranslatableText) AtomicReference(java.util.concurrent.atomic.AtomicReference) Dimension(com.seedfinding.mccore.state.Dimension) SimpleBlockMap(dev.xpple.seedmapper.util.maps.SimpleBlockMap) Biome(com.seedfinding.mcbiome.biome.Biome) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WorldChunk(net.minecraft.world.chunk.WorldChunk) BiomeSource(com.seedfinding.mcbiome.source.BiomeSource) Block(com.seedfinding.mccore.block.Block) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) TerrainGenerator(com.seedfinding.mcterrain.TerrainGenerator)

Aggregations

WorldChunk (net.minecraft.world.chunk.WorldChunk)34 BlockPos (net.minecraft.util.math.BlockPos)15 BlockState (net.minecraft.block.BlockState)9 ChunkPos (net.minecraft.util.math.ChunkPos)8 Inject (org.spongepowered.asm.mixin.injection.Inject)8 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)6 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)4 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)4 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)4 Collectors (java.util.stream.Collectors)4 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)3 CommandManager (at.haha007.edenclient.command.CommandManager)3 ChatColor (at.haha007.edenclient.utils.ChatColor)3 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)3 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)3 CommandContext (com.mojang.brigadier.context.CommandContext)3 Biome (com.seedfinding.mcbiome.biome.Biome)3 BiomeSource (com.seedfinding.mcbiome.source.BiomeSource)3 BlockEntity (net.minecraft.block.entity.BlockEntity)3 Direction (net.minecraft.util.math.Direction)3