Search in sources :

Example 16 with BlockPosition

use of net.minecraft.core.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_17_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) world.getTileEntity(blockPosition);
    if (tileChest != null)
        world.playBlockAction(blockPosition, tileChest.getBlock().getBlock(), 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_17_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 17 with BlockPosition

use of net.minecraft.core.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_17_R1 method updateTileEntity.

@Override
public void updateTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity tileEntity = world.getTileEntity(blockPosition);
    TileEntityWildChest tileEntityWildChest;
    if (tileEntity instanceof TileEntityWildChest) {
        tileEntityWildChest = (TileEntityWildChest) tileEntity;
        ((WChest) chest).setTileEntityContainer(tileEntityWildChest);
    } else {
        tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
        world.removeTileEntity(blockPosition);
        world.setTileEntity(tileEntityWildChest);
        Chunk chunk = world.getChunkAtWorldCoords(blockPosition);
        world.a(CREATE_TICKING_BLOCK.invoke(chunk, tileEntityWildChest, tileEntityWildChest));
    }
}
Also used : TileEntity(net.minecraft.world.level.block.entity.TileEntity) BlockPosition(net.minecraft.core.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) World(net.minecraft.world.level.World) WChest(com.bgsoftware.wildchests.objects.chests.WChest) Chunk(net.minecraft.world.level.chunk.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Location(org.bukkit.Location)

Example 18 with BlockPosition

use of net.minecraft.core.BlockPosition in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_17_R1 method removeTileEntity.

@Override
public void removeTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity currentTileEntity = world.getTileEntity(blockPosition);
    if (currentTileEntity instanceof TileEntityWildChest)
        world.removeTileEntity(blockPosition);
}
Also used : TileEntity(net.minecraft.world.level.block.entity.TileEntity) BlockPosition(net.minecraft.core.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) World(net.minecraft.world.level.World) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Location(org.bukkit.Location)

Aggregations

BlockPosition (net.minecraft.core.BlockPosition)18 World (net.minecraft.world.level.World)10 WorldServer (net.minecraft.server.level.WorldServer)8 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)7 TileEntityChest (net.minecraft.world.level.block.entity.TileEntityChest)6 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)6 IBlockData (net.minecraft.world.level.block.state.IBlockData)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)5 Location (org.bukkit.Location)4 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)2 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)2 StringReader (com.mojang.brigadier.StringReader)2 Random (java.util.Random)2 ArgumentBlock (net.minecraft.commands.arguments.blocks.ArgumentBlock)2 ArgumentTileLocation (net.minecraft.commands.arguments.blocks.ArgumentTileLocation)2 EntityPlayer (net.minecraft.server.level.EntityPlayer)2 ItemStack (net.minecraft.world.item.ItemStack)2 Block (net.minecraft.world.level.block.Block)2 TileEntity (net.minecraft.world.level.block.entity.TileEntity)2 DefinedStructure (net.minecraft.world.level.levelgen.structure.templatesystem.DefinedStructure)2