Search in sources :

Example 1 with ArgumentTileLocation

use of net.minecraft.server.v1_15_R1.ArgumentTileLocation in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_15_R1 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.removeTileEntity(blockPosition);
    location.getBlock().setType(type);
    if (nbt != null) {
        try {
            ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
            ArgumentTileLocation tileLocation = new ArgumentTileLocation(argumentBlock.getBlockData(), argumentBlock.getStateMap().keySet(), argumentBlock.c());
            tileLocation.a(worldServer, blockPosition, 2);
            worldServer.update(blockPosition, tileLocation.a().getBlock());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : ArgumentTileLocation(net.minecraft.server.v1_15_R1.ArgumentTileLocation) ArgumentBlock(net.minecraft.server.v1_15_R1.ArgumentBlock) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) StringReader(com.mojang.brigadier.StringReader) WorldServer(net.minecraft.server.v1_15_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 2 with ArgumentTileLocation

use of net.minecraft.server.v1_15_R1.ArgumentTileLocation in project SSB-OneBlock by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.removeTileEntity(blockPosition);
    location.getBlock().setType(type);
    if (nbt != null) {
        try {
            ArgumentBlock argumentBlock = new ArgumentBlock(new StringReader(nbt), false).a(true);
            ArgumentTileLocation tileLocation = new ArgumentTileLocation(argumentBlock.getBlockData(), argumentBlock.getStateMap().keySet(), argumentBlock.c());
            tileLocation.a(worldServer, blockPosition, 2);
            worldServer.update(blockPosition, tileLocation.a().getBlock());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : ArgumentTileLocation(net.minecraft.server.v1_16_R3.ArgumentTileLocation) ArgumentBlock(net.minecraft.server.v1_16_R3.ArgumentBlock) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) StringReader(com.mojang.brigadier.StringReader) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Aggregations

StringReader (com.mojang.brigadier.StringReader)2 ArgumentBlock (net.minecraft.server.v1_15_R1.ArgumentBlock)1 ArgumentTileLocation (net.minecraft.server.v1_15_R1.ArgumentTileLocation)1 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)1 WorldServer (net.minecraft.server.v1_15_R1.WorldServer)1 ArgumentBlock (net.minecraft.server.v1_16_R3.ArgumentBlock)1 ArgumentTileLocation (net.minecraft.server.v1_16_R3.ArgumentTileLocation)1 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)1 WorldServer (net.minecraft.server.v1_16_R3.WorldServer)1 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)1