Search in sources :

Example 21 with CraftBlockData

use of org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData in project FastAsyncWorldEdit by IntellectualSites.

the class PaperweightAdapter method getBlock.

@Override
public BlockState getBlock(Location location) {
    checkNotNull(location);
    CraftWorld craftWorld = ((CraftWorld) location.getWorld());
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();
    final ServerLevel handle = craftWorld.getHandle();
    LevelChunk chunk = handle.getChunk(x >> 4, z >> 4);
    final BlockPos blockPos = new BlockPos(x, y, z);
    final CraftBlockData blockData = chunk.getBlockState(blockPos).createCraftBlockData();
    BlockState state = BukkitAdapter.adapt(blockData);
    if (state == null) {
        org.bukkit.block.Block bukkitBlock = location.getBlock();
        state = BukkitAdapter.adapt(bukkitBlock.getBlockData());
    }
    return state;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftBlockData(org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockState(com.sk89q.worldedit.world.block.BlockState) BlockPos(net.minecraft.core.BlockPos) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 22 with CraftBlockData

use of org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData in project Denizen by DenizenScript.

the class EntityHelperImpl method setFallingBlockType.

@Override
public void setFallingBlockType(FallingBlock entity, BlockData block) {
    BlockState state = ((CraftBlockData) block).getState();
    FallingBlockEntity nmsEntity = ((CraftFallingBlock) entity).getHandle();
    try {
        FALLINGBLOCK_TYPE_SETTER.invoke(nmsEntity, state);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : FallingBlockEntity(net.minecraft.world.entity.item.FallingBlockEntity) CraftBlockData(org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 23 with CraftBlockData

use of org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData in project Denizen by DenizenScript.

the class EntityHelperImpl method setFallingBlockType.

@Override
public void setFallingBlockType(FallingBlock entity, BlockData block) {
    BlockState state = ((CraftBlockData) block).getState();
    FallingBlockEntity nmsEntity = ((CraftFallingBlock) entity).getHandle();
    try {
        FALLINGBLOCK_TYPE_SETTER.invoke(nmsEntity, state);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : FallingBlockEntity(net.minecraft.world.entity.item.FallingBlockEntity) CraftBlockData(org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 24 with CraftBlockData

use of org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData in project Denizen by DenizenScript.

the class EntityHelperImpl method setFallingBlockType.

@Override
public void setFallingBlockType(FallingBlock entity, BlockData block) {
    BlockState state = ((CraftBlockData) block).getState();
    FallingBlockEntity nmsEntity = ((CraftFallingBlock) entity).getHandle();
    try {
        FALLINGBLOCK_TYPE_SETTER.invoke(nmsEntity, state);
    } catch (Throwable ex) {
        Debug.echoError(ex);
    }
}
Also used : FallingBlockEntity(net.minecraft.world.entity.item.FallingBlockEntity) CraftBlockData(org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData) BlockState(net.minecraft.world.level.block.state.BlockState)

Example 25 with CraftBlockData

use of org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData in project Magma-1.16.x by magmafoundation.

the class CraftMinecart method setDisplayBlockData.

@Override
public void setDisplayBlockData(BlockData blockData) {
    if (blockData != null) {
        BlockState block = ((CraftBlockData) blockData).getState();
        this.getHandle().setDisplayBlockState(block);
    } else {
        // Set block to air (default) and set the flag to not have a display block.
        this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState());
        this.getHandle().setCustomDisplay(false);
    }
}
Also used : CraftBlockData(org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData) BlockState(net.minecraft.block.BlockState)

Aggregations

BlockData (org.bukkit.block.data.BlockData)12 BlockState (net.minecraft.world.level.block.state.BlockState)9 CraftBlockData (org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData)9 CraftBlockData (org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)8 Nullable (org.jetbrains.annotations.Nullable)6 BlockState (net.minecraft.block.BlockState)4 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)4 FallingBlockEntity (net.minecraft.world.entity.item.FallingBlockEntity)4 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)4 ParallelWorld (thpmc.vanilla_source.api.world.parallel.ParallelWorld)4 BlockPos (net.minecraft.core.BlockPos)3 ServerLevel (net.minecraft.server.level.ServerLevel)3 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)3 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)3 CraftBlockData (org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData)3 CraftBlockData (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData)3 CraftBlockData (org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData)3 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)3 ParallelUniverse (thpmc.vanilla_source.api.world.parallel.ParallelUniverse)3 StringReader (com.mojang.brigadier.StringReader)2