Search in sources :

Example 36 with LevelChunk

use of net.minecraft.world.level.chunk.LevelChunk 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);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)36 BlockPos (net.minecraft.core.BlockPos)13 ChunkAccess (net.minecraft.world.level.chunk.ChunkAccess)10 ServerLevel (net.minecraft.server.level.ServerLevel)9 LevelChunkBridge (org.spongepowered.common.bridge.world.level.chunk.LevelChunkBridge)8 Vector3i (org.spongepowered.math.vector.Vector3i)7 BlockState (net.minecraft.world.level.block.state.BlockState)6 Nullable (org.checkerframework.checker.nullness.qual.Nullable)6 BlockEntity (org.spongepowered.api.block.entity.BlockEntity)5 BlockLight (com.denizenscript.denizen.nms.abstracts.BlockLight)4 ChunkCoordinate (com.denizenscript.denizen.utilities.blocks.ChunkCoordinate)4 UUID (java.util.UUID)4 Tuple (net.minecraft.util.Tuple)4 Level (net.minecraft.world.level.Level)4 MonotonicNonNull (org.checkerframework.checker.nullness.qual.MonotonicNonNull)4 CompoundTag (net.minecraft.nbt.CompoundTag)3 ChunkPos (net.minecraft.world.level.ChunkPos)3 PhaseTracker (org.spongepowered.common.event.tracking.PhaseTracker)3 SpongeBlockChangeFlag (org.spongepowered.common.world.SpongeBlockChangeFlag)3 BitSet (java.util.BitSet)2