Search in sources :

Example 6 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project MagicPlugin by elBukkit.

the class CompatibilityUtils method setBlockFast.

@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
    LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
    net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
    BlockPos blockLocation = new BlockPos(x, y, z);
    nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
    return true;
}
Also used : LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockPos(net.minecraft.core.BlockPos) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk)

Example 7 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project MagicPlugin by elBukkit.

the class CompatibilityUtils method setBlockFast.

@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
    LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
    net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
    BlockPos blockLocation = new BlockPos(x, y, z);
    nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
    return true;
}
Also used : LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockPos(net.minecraft.core.BlockPos) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk)

Example 8 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project NotQuests by AlessioGr.

the class PacketInjector method spawnBeaconBeam.

public void spawnBeaconBeam(Player player, Location location) {
    // Prepare Data
    Connection connection = getConnection(getServerPlayer(player).connection);
    location = location.clone();
    BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
    Chunk chunk = location.getChunk();
    CraftChunk craftChunk = (CraftChunk) chunk;
    LevelChunk levelChunk = craftChunk.getHandle();
    World world = location.getWorld();
    CraftWorld craftWorld = (CraftWorld) world;
    ServerLevel serverLevel = craftWorld.getHandle();
    // 
    BlockState blockState = location.getBlock().getState();
    blockState.setType(Material.BEACON);
    SectionPos sectionPos = SectionPos.of((int) location.getX(), (int) location.getY(), (int) location.getZ());
    ShortSet positions = ShortSet.of((short) 0);
    // PalettedContainer<BlockState> pcB = new PalettedContainer<>();
    // net.minecraft.world.level.block.state.BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(world, chunkPos, b0 << 4);
    // PalettedContainer<BlockState> datapaletteblock = new PalettedContainer<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, presetBlockStates);
    LevelChunkSection section = levelChunk.getHighestSection();
    ClientboundSectionBlocksUpdatePacket clientboundSectionBlocksUpdatePacket = new ClientboundSectionBlocksUpdatePacket(sectionPos, positions, section, true);
    main.sendMessage(player, "<main>Sending packet...");
    connection.send(clientboundSectionBlocksUpdatePacket);
    main.sendMessage(player, "<success>Packet sent!");
// ClientboundBlockUpdatePacket clientboundBlockUpdatePacket = new ClientboundBlockUpdatePacket(blockPos, BlockState.);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Connection(net.minecraft.network.Connection) ClientboundSectionBlocksUpdatePacket(net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) CraftChunk(org.bukkit.craftbukkit.v1_18_R2.CraftChunk) Chunk(org.bukkit.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) World(org.bukkit.World) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) CraftBlockState(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState) BlockState(org.bukkit.block.BlockState) LevelChunkSection(net.minecraft.world.level.chunk.LevelChunkSection) ShortSet(it.unimi.dsi.fastutil.shorts.ShortSet) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) SectionPos(net.minecraft.core.SectionPos) CraftChunk(org.bukkit.craftbukkit.v1_18_R2.CraftChunk)

Example 9 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project Denizen-For-Bukkit by DenizenScript.

the class ChunkHelperImpl method refreshChunkSections.

@Override
public void refreshChunkSections(Chunk chunk) {
    ClientboundLevelChunkPacket packet = new ClientboundLevelChunkPacket(((CraftChunk) chunk).getHandle());
    ChunkPos pos = new ChunkPos(chunk.getX(), chunk.getZ());
    ChunkHolder playerChunk = ((CraftWorld) chunk.getWorld()).getHandle().getChunkProvider().chunkMap.l.get(pos.toLong());
    if (playerChunk == null) {
        return;
    }
    playerChunk.playerProvider.getPlayers(pos, false).forEach(player -> {
        player.connection.send(packet);
    });
}
Also used : ChunkHolder(net.minecraft.server.level.ChunkHolder) ChunkPos(net.minecraft.world.level.ChunkPos) ClientboundLevelChunkPacket(net.minecraft.network.protocol.game.ClientboundLevelChunkPacket) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 10 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project Denizen-For-Bukkit by DenizenScript.

the class ChunkHelperImpl method setAllBiomes.

@Override
public void setAllBiomes(Chunk chunk, BiomeNMS biome) {
    Biome nmsBiome = ((BiomeNMSImpl) biome).biomeBase;
    LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
    ChunkBiomeContainer biomeContainer = nmsChunk.getBiomes();
    for (int x = 0; x < 4; x++) {
        for (int y = 0; y < 64; y++) {
            for (int z = 0; z < 4; z++) {
                biomeContainer.setBiome(x, y, z, nmsBiome);
            }
        }
    }
    nmsChunk.markUnsaved();
}
Also used : Biome(net.minecraft.world.level.biome.Biome) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk) ChunkBiomeContainer(net.minecraft.world.level.chunk.ChunkBiomeContainer) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)10 BlockPos (net.minecraft.core.BlockPos)8 CraftChunk (org.bukkit.craftbukkit.v1_17_R1.CraftChunk)5 CraftChunk (org.bukkit.craftbukkit.v1_18_R1.CraftChunk)5 ServerLevel (net.minecraft.server.level.ServerLevel)3 ChunkPos (net.minecraft.world.level.ChunkPos)2 Biome (net.minecraft.world.level.biome.Biome)2 LevelChunkSection (net.minecraft.world.level.chunk.LevelChunkSection)2 Heightmap (net.minecraft.world.level.levelgen.Heightmap)2 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)2 CraftChunk (org.bukkit.craftbukkit.v1_18_R2.CraftChunk)2 BiomeNMSImpl (com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)1 BiomeNMSImpl (com.denizenscript.denizen.nms.v1_18.impl.BiomeNMSImpl)1 ShortSet (it.unimi.dsi.fastutil.shorts.ShortSet)1 SectionPos (net.minecraft.core.SectionPos)1 Connection (net.minecraft.network.Connection)1 ClientboundLevelChunkPacket (net.minecraft.network.protocol.game.ClientboundLevelChunkPacket)1 ClientboundSectionBlocksUpdatePacket (net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket)1 ChunkHolder (net.minecraft.server.level.ChunkHolder)1 LevelHeightAccessor (net.minecraft.world.level.LevelHeightAccessor)1