Search in sources :

Example 21 with IBlockData

use of net.minecraft.server.v1_11_R1.IBlockData in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 22 with IBlockData

use of net.minecraft.server.v1_11_R1.IBlockData in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_8_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_8_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_8_R1.Block.getByCombinedId(combined);
    chunk.a(bp, ibd);
    if (applyPhysics) {
        net.minecraft.server.v1_8_R1.Block block = chunk.getType(bp);
        w.update(bp, block);
    }
}
Also used : IBlockData(net.minecraft.server.v1_8_R1.IBlockData) BlockPosition(net.minecraft.server.v1_8_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 23 with IBlockData

use of net.minecraft.server.v1_11_R1.IBlockData in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_9_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_9_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_9_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_9_R1.IBlockData) BlockPosition(net.minecraft.server.v1_9_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_9_R1.CraftWorld)

Example 24 with IBlockData

use of net.minecraft.server.v1_11_R1.IBlockData in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method run.

@Override
public BehaviorStatus run() {
    if (entity.dead) {
        return BehaviorStatus.FAILURE;
    }
    if (!isDigging) {
        return BehaviorStatus.SUCCESS;
    }
    // CraftBukkit
    currentTick = (int) (System.currentTimeMillis() / 50);
    if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
        startDigTick = currentTick;
        if (entity instanceof NPCHolder) {
            NPC npc = ((NPCHolder) entity).getNPC();
            if (npc != null && !npc.getNavigator().isNavigating()) {
                npc.getNavigator().setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
            }
        }
        return BehaviorStatus.RUNNING;
    }
    Util.faceLocation(entity.getBukkitEntity(), location);
    if (entity instanceof EntityPlayer) {
        PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
    }
    IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
    if (block == null || block == Blocks.AIR) {
        return BehaviorStatus.SUCCESS;
    } else {
        int tickDifference = currentTick - startDigTick;
        float damage = getStrength(block.getBlock()) * (tickDifference + 1) * configuration.blockStrengthModifier();
        if (damage >= 1F) {
            entity.world.getWorld().getBlockAt(x, y, z).breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
            return BehaviorStatus.SUCCESS;
        }
        int modifiedDamage = (int) (damage * 10.0F);
        if (modifiedDamage != currentDamage) {
            setBlockDamage(modifiedDamage);
            currentDamage = modifiedDamage;
        }
    }
    return BehaviorStatus.RUNNING;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) IBlockData(net.minecraft.server.v1_8_R3.IBlockData) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer)

Example 25 with IBlockData

use of net.minecraft.server.v1_11_R1.IBlockData in project Citizens2 by CitizensDev.

the class PlayerNavigation method d.

@Override
protected void d() {
    PathPoint localPathPoint;
    for (int i = 0; i < this.c.d(); i++) {
        localPathPoint = this.c.a(i);
        Object localObject = i + 1 < this.c.d() ? this.c.a(i + 1) : null;
        IBlockData localIBlockData = this.b.getType(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c));
        Block localBlock = localIBlockData.getBlock();
        if (localBlock == Blocks.cauldron) {
            this.c.a(i, localPathPoint.a(localPathPoint.a, localPathPoint.b + 1, localPathPoint.c));
            if ((localObject != null) && (localPathPoint.b >= ((PathPoint) localObject).b)) {
                this.c.a(i + 1, ((PathPoint) localObject).a(((PathPoint) localObject).a, localPathPoint.b + 1, ((PathPoint) localObject).c));
            }
        }
    }
    if (this.f2) {
        if (this.b.h(new BlockPosition(MathHelper.floor(this.a.locX), (int) (this.a.getBoundingBox().b + 0.5D), MathHelper.floor(this.a.locZ)))) {
            return;
        }
        for (int i = 0; i < this.c.d(); i++) {
            localPathPoint = this.c.a(i);
            if (this.b.h(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c))) {
                this.c.b(i - 1);
                return;
            }
        }
    }
}
Also used : PathPoint(net.minecraft.server.v1_11_R1.PathPoint) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)5 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)5 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)5 IBlockData (net.minecraft.server.v1_11_R1.IBlockData)5 NPC (net.citizensnpcs.api.npc.NPC)4 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)4 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)4 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)4 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)3 IBlockData (net.minecraft.server.v1_8_R3.IBlockData)3 Block (net.minecraft.server.v1_10_R1.Block)2 Block (net.minecraft.server.v1_11_R1.Block)2 BlockPosition (net.minecraft.server.v1_8_R1.BlockPosition)2 IBlockData (net.minecraft.server.v1_8_R1.IBlockData)2 BlockPosition (net.minecraft.server.v1_8_R2.BlockPosition)2 IBlockData (net.minecraft.server.v1_8_R2.IBlockData)2 BlockPosition (net.minecraft.server.v1_9_R1.BlockPosition)2 IBlockData (net.minecraft.server.v1_9_R1.IBlockData)2 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)2 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)2