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 Denizen by DenizenScript.
the class ChunkHelperImpl method getHeightMap.
@Override
public int[] getHeightMap(Chunk chunk) {
Heightmap map = ((CraftChunk) chunk).getHandle().heightmaps.get(Heightmap.Types.MOTION_BLOCKING);
int[] outputMap = new int[256];
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
outputMap[x * 16 + y] = map.getFirstAvailable(x, y);
}
}
return outputMap;
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project Denizen 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);
}
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project Denizen by DenizenScript.
the class BlockHelperImpl method doRandomTick.
@Override
public void doRandomTick(Location location) {
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
LevelChunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
net.minecraft.world.level.block.state.BlockState nmsBlock = nmsChunk.getBlockState(pos);
ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
if (nmsBlock.isRandomlyTicking()) {
nmsBlock.randomTick(nmsWorld, pos, nmsWorld.random);
}
try {
// FluidState fluid = nmsBlock.getFluidState();
// if (fluid.isRandomlyTicking()) {
// fluid.animateTick(nmsWorld, pos, nmsWorld.random);
// }
Object fluid = BLOCKSTATEBASE_GETFLUIDSTATE.invoke(nmsBlock);
if ((boolean) FLUIDSTATE_ISRANDOMLYTICKING.invoke(fluid)) {
FLUIDSTATE_ANIMATETICK.invoke(fluid, nmsWorld, pos, nmsWorld.random);
}
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project WildLoaders by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method removeLoader.
@Override
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
Location loaderLoc = chunkLoader.getLocation();
World world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
long tileEntityLong = LongHash.toLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
if (tileEntityChunkLoader != null) {
tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_8_R3::removeHologram);
tileEntityChunkLoader.removed = true;
world.tileEntityList.remove(tileEntityChunkLoader);
}
if (spawnParticle)
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner).forEach(tileEntity -> {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
tileEntity.b(nbtTagCompound);
nbtTagCompound.setShort("RequiredPlayerRange", (short) 16);
tileEntity.a(nbtTagCompound);
});
}
}
Aggregations