Search in sources :

Example 1 with World

use of net.minecraft.world.level.World 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 World

use of net.minecraft.world.level.World 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 World

use of net.minecraft.world.level.World 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 World

use of net.minecraft.world.level.World in project Atlas by funkemunky.

the class BlockBox1_17_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final World world = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    IBlockData iblockData = ((CraftBlock) block).getNMS();
    Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
    List<AxisAlignedBB> boxes = shape.toList();
    if (boxes.size() == 0) {
        return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
    } else if (boxes.size() == 1) {
        AxisAlignedBB box = boxes.get(0);
        return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
        }
        return complexBox;
    }
}
Also used : AxisAlignedBB(net.minecraft.world.phys.AxisAlignedBB) BlockPosition(net.minecraft.core.BlockPosition) ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) IBlockData(net.minecraft.world.level.block.state.IBlockData) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) CraftBlock(org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock) Block(net.minecraft.world.level.block.Block) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 5 with World

use of net.minecraft.world.level.World 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)

Aggregations

BlockPosition (net.minecraft.core.BlockPosition)10 World (net.minecraft.world.level.World)10 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)6 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)3 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)2 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)2 Block (net.minecraft.world.level.block.Block)2 TileEntity (net.minecraft.world.level.block.entity.TileEntity)2 IBlockData (net.minecraft.world.level.block.state.IBlockData)2 AxisAlignedBB (net.minecraft.world.phys.AxisAlignedBB)2 VoxelShape (net.minecraft.world.phys.shapes.VoxelShape)2 Location (org.bukkit.Location)2 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)2 WChest (com.bgsoftware.wildchests.objects.chests.WChest)1 TileEntityEnderChest (net.minecraft.world.level.block.entity.TileEntityEnderChest)1 Chunk (net.minecraft.world.level.chunk.Chunk)1 Material (org.bukkit.Material)1 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)1 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)1