Search in sources :

Example 21 with CraftChunk

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

the class BlockHelperImpl method doRandomTick.

@Override
public void doRandomTick(Location location) {
    BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Chunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
    IBlockData nmsBlock = nmsChunk.getType(pos);
    WorldServer nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (nmsBlock.isTicking()) {
        nmsBlock.b(nmsWorld, pos, nmsWorld.random);
    }
    Fluid fluid = nmsBlock.getFluid();
    if (fluid.f()) {
        fluid.b(nmsWorld, pos, nmsWorld.random);
    }
}
Also used : CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk)

Example 22 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project VanillaSource by TheHollowPlanetMC.

the class PacketManager method sendClearChunkMultiBlockChangePacketAtPrimaryThread.

public static void sendClearChunkMultiBlockChangePacketAtPrimaryThread(Player player, ParallelChunk parallelChunk, NMSHandler nmsHandler) {
    if (!Bukkit.isPrimaryThread())
        throw new IllegalStateException("DO NOT CALL FROM ASYNC THREAD!");
    org.bukkit.World world = Bukkit.getWorld(parallelChunk.getWorld().getName());
    if (world == null)
        return;
    if (player.getWorld() != world)
        return;
    List<Short> coordList = new ArrayList<>();
    boolean has = false;
    for (int sectionIndex = 0; sectionIndex < 16; sectionIndex++) {
        SectionTypeArray sectionTypeArray = parallelChunk.getSectionTypeArray(sectionIndex);
        if (sectionTypeArray == null)
            continue;
        int finalSectionIndex = sectionIndex;
        boolean notEmpty = sectionTypeArray.threadsafeIteration((x, y, z, iBlockData) -> {
            short loc = (short) (x << 12 | z << 8 | (y + (finalSectionIndex << 4)));
            coordList.add(loc);
        });
        if (notEmpty)
            has = true;
    }
    if (!has)
        return;
    if (coordList.size() == 0)
        return;
    org.bukkit.Chunk chunk = world.getChunkAt(parallelChunk.getChunkX(), parallelChunk.getChunkZ());
    net.minecraft.server.v1_15_R1.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
    short[] array = new short[coordList.size()];
    for (int i = 0; i < coordList.size(); i++) {
        array[i] = coordList.get(i);
    }
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(coordList.size(), array, nmsChunk);
    nmsHandler.sendPacket(player, packet);
}
Also used : SectionTypeArray(thpmc.vanilla_source.util.SectionTypeArray) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) CraftChunk(org.bukkit.craftbukkit.v1_15_R1.CraftChunk)

Example 23 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_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 24 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_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 25 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_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_17_R1.CraftChunk)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)17 Material (org.bukkit.Material)14 World (org.bukkit.World)12 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)11 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)11 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)11 BlockPos (net.minecraft.core.BlockPos)11 Location (org.bukkit.Location)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 CraftChunk (org.bukkit.craftbukkit.v1_17_R1.CraftChunk)9 CraftChunk (org.bukkit.craftbukkit.v1_18_R2.CraftChunk)9 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8