use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project Denizen by DenizenScript.
the class ChunkHelperImpl method setAllBiomes.
@Override
public void setAllBiomes(Chunk chunk, BiomeNMS biome) {
Holder<Biome> nmsBiome = ((BiomeNMSImpl) biome).biomeBase;
LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
ChunkPos chunkcoordintpair = nmsChunk.getPos();
int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX());
int j = QuartPos.fromBlock(chunkcoordintpair.getMinBlockZ());
LevelHeightAccessor levelheightaccessor = nmsChunk.getHeightAccessorForGeneration();
for (int k = levelheightaccessor.getMinSection(); k < levelheightaccessor.getMaxSection(); ++k) {
LevelChunkSection chunksection = nmsChunk.getSection(nmsChunk.getSectionIndexFromSectionY(k));
PalettedContainer<Holder<Biome>> datapaletteblock = chunksection.getBiomes();
datapaletteblock.acquire();
for (int l = 0; l < 4; ++l) {
for (int i1 = 0; i1 < 4; ++i1) {
for (int j1 = 0; j1 < 4; ++j1) {
datapaletteblock.getAndSetUnchecked(l, i1, j1, nmsBiome);
}
}
}
datapaletteblock.release();
}
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project FastAsyncWorldEdit by IntellectualSites.
the class PaperweightPlatformAdapter method ensureLoaded.
public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int chunkZ) {
if (!PaperLib.isPaper()) {
LevelChunk nmsChunk = serverLevel.getChunkSource().getChunk(chunkX, chunkZ, false);
if (nmsChunk != null) {
return nmsChunk;
}
if (Fawe.isMainThread()) {
return serverLevel.getChunk(chunkX, chunkZ);
}
} else {
LevelChunk nmsChunk = serverLevel.getChunkSource().getChunkAtIfCachedImmediately(chunkX, chunkZ);
if (nmsChunk != null) {
return nmsChunk;
}
nmsChunk = serverLevel.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
if (nmsChunk != null) {
return nmsChunk;
}
// Avoid "async" methods from the main thread.
if (Fawe.isMainThread()) {
return serverLevel.getChunk(chunkX, chunkZ);
}
CompletableFuture<org.bukkit.Chunk> future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true);
try {
CraftChunk chunk = (CraftChunk) future.get();
return chunk.getHandle();
} catch (Throwable e) {
e.printStackTrace();
}
}
return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ));
}
use of org.bukkit.craftbukkit.v1_7_R4.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.);
}
use of org.bukkit.craftbukkit.v1_7_R4.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;
}
use of org.bukkit.craftbukkit.v1_7_R4.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;
}
Aggregations