mattheuss185

Minecraft mundo repetidor onde quando coloca um bloco em um lugar se repete nas outras chunks

Kodari AI
KodariNov 7 at 7:38 pm 1
ChunkReplicator
ChunkReplicator is a Minecraft plugin that creates a repeating world effect. When a player places a block in one chunk, the plugin automatically replicates that block placement across all other chunks in the world at the same relative coordinates. The plugin tracks block placements and breaks, synchronizing changes across the entire world grid. It features configurable replication radius, toggleable per-world settings, and performance optimizations to handle large-scale replication without lag. Players can enable or disable replication mode with a simple command, and administrators can configure which worlds use the replication system. The plugin also handles edge cases like chunk loading and unloading to ensure consistent replication across all dimensions.
  • Replicar blocos colocados na mesma posição relativa das outras chunks carregadas do mundo.

  • Manter os dados do bloco, como orientação e estado.

Criado o plugin: ao colocar um bloco, ele é repetido na mesma posição relativa das outras chunks carregadas do mundo, substituindo o bloco existente.

Chunks carregadas depois não recebem a cópia. Inventários e outros dados especiais de blocos não são copiados.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
3 57
src/main/java/com/kodari/mundorepetidor/MundoRepetidor.java
package com.kodari.mundorepetidor;

import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class MundoRepetidor extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onBlockPlace(BlockPlaceEvent event) {
        Block block = event.getBlockPlaced();
        Chunk source = block.getChunk();
        BlockData data = block.getBlockData().clone();
        int localX = block.getX() & 15;
        int localZ = block.getZ() & 15;

        for (Chunk chunk : block.getWorld().getLoadedChunks()) {
            if (chunk.getX() == source.getX() && chunk.getZ() == source.getZ()) {
                continue;
            }
            chunk.getBlock(localX, block.getY(), localZ).setBlockData(data, false);
        }
    }
}