Search in sources :

Example 1 with TileEntityChest

use of net.minecraft.world.level.block.entity.TileEntityChest in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_18_R1 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) getTileEntity(world, blockPosition);
    if (tileChest != null)
        playBlockAction(world, blockPosition, getBlock(getBlock(tileChest)), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 2 with TileEntityChest

use of net.minecraft.world.level.block.entity.TileEntityChest in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_18_R2 method playChestAction.

@Override
public void playChestAction(Location location, boolean open) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
    TileEntityChest tileChest = (TileEntityChest) getBlockEntity(world, blockPosition);
    if (tileChest != null)
        blockEvent(world, blockPosition, getBlock(NMSMappings_v1_18_R2.getBlockState(tileChest)), 1, open ? 1 : 0);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 3 with TileEntityChest

use of net.minecraft.world.level.block.entity.TileEntityChest in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_17_R1 method setChestName.

@Override
public void setChestName(Location chest, String name) {
    assert chest.getWorld() != null;
    World world = ((CraftWorld) chest.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(chest.getBlockX(), chest.getBlockY(), chest.getBlockZ());
    TileEntityChest tileEntityChest = (TileEntityChest) world.getTileEntity(blockPosition);
    assert tileEntityChest != null;
    tileEntityChest.setCustomName(CraftChatMessage.fromString(name)[0]);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 4 with TileEntityChest

use of net.minecraft.world.level.block.entity.TileEntityChest in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_18_R1 method setChestName.

@Override
public void setChestName(Location chest, String name) {
    assert chest.getWorld() != null;
    World world = ((CraftWorld) chest.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(chest.getBlockX(), chest.getBlockY(), chest.getBlockZ());
    TileEntityChest tileEntityChest = (TileEntityChest) world.c_(blockPosition);
    assert tileEntityChest != null;
    tileEntityChest.a(CraftChatMessage.fromString(name)[0]);
}
Also used : TileEntityChest(net.minecraft.world.level.block.entity.TileEntityChest) BlockPosition(net.minecraft.core.BlockPosition) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 5 with TileEntityChest

use of net.minecraft.world.level.block.entity.TileEntityChest 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)6 World (net.minecraft.world.level.World)6 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)6 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)2 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)2 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)2 TileEntityEnderChest (net.minecraft.world.level.block.entity.TileEntityEnderChest)1 Material (org.bukkit.Material)1