use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit 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 net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class PlayerHelperImpl method deTrackEntity.
@Override
public void deTrackEntity(Player player, Entity entity) {
ServerPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
ServerLevel world = (ServerLevel) nmsPlayer.level;
ChunkMap.TrackedEntity tracker = world.getChunkProvider().chunkMap.G.get(entity.getEntityId());
if (tracker == null) {
return;
}
sendEntityDestroy(player, entity);
tracker.removePlayer(nmsPlayer);
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class WorldHelperImpl method setStatic.
@Override
public void setStatic(World world, boolean isStatic) {
ServerLevel worldServer = ((CraftWorld) world).getHandle();
ReflectionHelper.setFieldValue(net.minecraft.world.level.Level.class, ReflectionMappingsInfo.Level_isClientSide, worldServer, isStatic);
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method spawnHook.
@Override
public FishHook spawnHook(Location location, Player player) {
ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
FishingHook hook = new FishingHook(((CraftPlayer) player).getHandle(), nmsWorld, 0, 0);
nmsWorld.addEntity(hook, CreatureSpawnEvent.SpawnReason.CUSTOM);
return (FishHook) hook.getBukkitEntity();
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomeAt.
@Override
public BiomeNMS getBiomeAt(Block block) {
// Based on CraftWorld source
ServerLevel level = ((CraftWorld) block.getWorld()).getHandle();
Biome biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
return new BiomeNMSImpl(level, keyText);
}
Aggregations