Search in sources :

Example 1 with TileEntityEnderChest

use of net.minecraft.world.level.block.entity.TileEntityEnderChest in project Crazy-Crates by Crazy-Crew.

the class NMS_Support method openChest.

@Override
public void openChest(Block block, boolean open) {
    Material type = block.getType();
    if (type == Material.CHEST || type == Material.TRAPPED_CHEST || type == Material.ENDER_CHEST) {
        World world = ((CraftWorld) block.getWorld()).getHandle();
        BlockPosition position = new BlockPosition(block.getX(), block.getY(), block.getZ());
        if (block.getType() == Material.ENDER_CHEST) {
            TileEntityEnderChest tileChest = (TileEntityEnderChest) world.getBlockEntity(position, false);
            world.a(position, tileChest.q(), 1, open ? 1 : 0);
        } else {
            TileEntityChest tileChest = (TileEntityChest) world.getBlockEntity(position, false);
            world.a(position, tileChest.q(), 1, open ? 1 : 0);
        }
    }
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) Material(org.bukkit.Material) TileEntityEnderChest(net.minecraft.world.level.block.entity.TileEntityEnderChest) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Aggregations

BlockPosition (net.minecraft.core.BlockPosition)1 World (net.minecraft.world.level.World)1 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)1 TileEntityEnderChest (net.minecraft.world.level.block.entity.TileEntityEnderChest)1 Material (org.bukkit.Material)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)1