Search in sources :

Example 66 with IBlockData

use of net.minecraft.server.v1_15_R1.IBlockData in project RoseStacker by Rosewood-Development.

the class StackedSpawnerTileImpl method setSpawnData.

@Override
public void setSpawnData(MobSpawnerData var0) {
    super.setSpawnData(var0);
    if (this.a() != null) {
        IBlockData var1 = this.a().getType(this.b());
        this.a().notify(this.blockPos, var1, var1, 4);
    }
}
Also used : IBlockData(net.minecraft.server.v1_16_R3.IBlockData)

Example 67 with IBlockData

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

the class NMSAdapter_v1_12_R1 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    World worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.s(blockPosition);
    org.bukkit.block.Block bukkitBlock = location.getBlock();
    bukkitBlock.setType(type);
    if (data > 0)
        // noinspection deprecation
        bukkitBlock.setData(data);
    if (nbt != null) {
        try {
            Block block = worldServer.getType(blockPosition).getBlock();
            IBlockData blockData = CommandAbstract.a(block, nbt);
            worldServer.setTypeAndData(blockPosition, blockData, 2);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block) World(net.minecraft.server.v1_12_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 68 with IBlockData

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

the class NMSAdapter_v1_15_R1 method simulateToolBreak.

@Override
public void simulateToolBreak(Player bukkitPlayer, org.bukkit.block.Block bukkitBlock) {
    EntityPlayer entityPlayer = ((CraftPlayer) bukkitPlayer).getHandle();
    ItemStack itemStack = entityPlayer.getItemInMainHand();
    WorldServer worldServer = ((CraftWorld) bukkitBlock.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    assert itemStack != null;
    itemStack.a(worldServer, blockData, blockPosition, entityPlayer);
}
Also used : IBlockData(net.minecraft.server.v1_15_R1.IBlockData) BlockPosition(net.minecraft.server.v1_15_R1.BlockPosition) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) WorldServer(net.minecraft.server.v1_15_R1.WorldServer) ItemStack(net.minecraft.server.v1_15_R1.ItemStack) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 69 with IBlockData

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

the class NMSAdapter_v1_8_R3 method setBlock.

@Override
public void setBlock(Location location, Material type, byte data, String nbt) {
    assert location.getWorld() != null;
    World worldServer = ((CraftWorld) location.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    worldServer.t(blockPosition);
    org.bukkit.block.Block bukkitBlock = location.getBlock();
    bukkitBlock.setType(type);
    if (data > 0)
        // noinspection deprecation
        bukkitBlock.setData(data);
    if (nbt != null) {
        try {
            Block block = worldServer.getType(blockPosition).getBlock();
            IBlockData blockData = block.fromLegacyData(CommandAbstract.a(nbt, 0, 15));
            worldServer.setTypeAndData(blockPosition, blockData, 2);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : IBlockData(net.minecraft.server.v1_8_R3.IBlockData) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) Block(net.minecraft.server.v1_8_R3.Block) World(net.minecraft.server.v1_8_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 70 with IBlockData

use of net.minecraft.server.v1_15_R1.IBlockData in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot116 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        Block b = bd.getBlock();
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        // getLightBlock
        int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
        // Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
        // Fill in base attributes
        bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
        if (mat.isSolid()) {
            bld.setSolid();
        }
        if (mat == Material.AIR) {
            bld.setAir();
        }
        if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
            bld.setLog();
        }
        if (mat == Material.LEAVES) {
            bld.setLeaves();
        }
        if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bld.setWaterlogged();
        }
        // Build state
        DynmapBlockState dbs = bld.build();
        dataToState.put(bd, dbs);
        lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
        Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
    }
}
Also used : BlockRotatable(net.minecraft.server.v1_16_R1.BlockRotatable) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) BukkitMaterial(org.dynmap.bukkit.helper.BukkitMaterial) Material(net.minecraft.server.v1_16_R1.Material) IBlockData(net.minecraft.server.v1_16_R1.IBlockData) Block(net.minecraft.server.v1_16_R1.Block) BlockFluids(net.minecraft.server.v1_16_R1.BlockFluids)

Aggregations

HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)20 Block (org.bukkit.block.Block)18 List (java.util.List)16 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)16 NotNull (org.jetbrains.annotations.NotNull)16 Chunk (org.bukkit.Chunk)12 IBlockData (net.minecraft.server.v1_14_R1.IBlockData)10 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)9 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)8 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 IBlockData (net.minecraft.server.v1_11_R1.IBlockData)7 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)7 IBlockData (net.minecraft.server.v1_8_R3.IBlockData)7 IdentityHashMap (java.util.IdentityHashMap)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)6