Search in sources :

Example 31 with org.bukkit.craftbukkit.v1_18_R1.block

use of org.bukkit.craftbukkit.v1_18_R1.block in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

private PathType b(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
    BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
    IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
    Block localBlock = localIBlockData.getBlock();
    Material localMaterial = localIBlockData.getMaterial();
    if (localMaterial == Material.AIR) {
        return PathType.OPEN;
    }
    if ((localBlock == Blocks.TRAPDOOR) || (localBlock == Blocks.IRON_TRAPDOOR) || (localBlock == Blocks.WATERLILY)) {
        return PathType.TRAPDOOR;
    }
    if (localBlock == Blocks.FIRE) {
        return PathType.DAMAGE_FIRE;
    }
    if (localBlock == Blocks.CACTUS) {
        return PathType.DAMAGE_CACTUS;
    }
    if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.WOOD) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_WOOD_CLOSED;
    }
    if (((localBlock instanceof BlockDoor)) && (localMaterial == Material.ORE) && (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_IRON_CLOSED;
    }
    if (((localBlock instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
        return PathType.DOOR_OPEN;
    }
    if ((localBlock instanceof BlockMinecartTrackAbstract)) {
        return PathType.RAIL;
    }
    if (((localBlock instanceof BlockFence)) || ((localBlock instanceof BlockCobbleWall)) || (((localBlock instanceof BlockFenceGate)) && (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
        return PathType.FENCE;
    }
    if (localMaterial == Material.WATER) {
        return PathType.WATER;
    }
    if (localMaterial == Material.LAVA) {
        return PathType.LAVA;
    }
    if (localBlock.b(paramIBlockAccess, localBlockPosition)) {
        return PathType.OPEN;
    }
    return PathType.BLOCKED;
}
Also used : BlockDoor(net.minecraft.server.v1_11_R1.BlockDoor) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) BlockFenceGate(net.minecraft.server.v1_11_R1.BlockFenceGate) BlockCobbleWall(net.minecraft.server.v1_11_R1.BlockCobbleWall) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) Material(net.minecraft.server.v1_11_R1.Material) BlockMinecartTrackAbstract(net.minecraft.server.v1_11_R1.BlockMinecartTrackAbstract) BlockFence(net.minecraft.server.v1_11_R1.BlockFence)

Example 32 with org.bukkit.craftbukkit.v1_18_R1.block

use of org.bukkit.craftbukkit.v1_18_R1.block in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
    PathType localPathType1 = b(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
    if ((localPathType1 == PathType.OPEN) && (paramInt2 >= 1)) {
        Block localObject = paramIBlockAccess.getType(new BlockPosition(paramInt1, paramInt2 - 1, paramInt3)).getBlock();
        PathType localPathType2 = b(paramIBlockAccess, paramInt1, paramInt2 - 1, paramInt3);
        localPathType1 = (localPathType2 == PathType.WALKABLE) || (localPathType2 == PathType.OPEN) || (localPathType2 == PathType.WATER) || (localPathType2 == PathType.LAVA) ? PathType.OPEN : PathType.WALKABLE;
        if ((localPathType2 == PathType.DAMAGE_FIRE) || (localObject == Blocks.df)) {
            localPathType1 = PathType.DAMAGE_FIRE;
        }
        if (localPathType2 == PathType.DAMAGE_CACTUS) {
            localPathType1 = PathType.DAMAGE_CACTUS;
        }
    }
    Object localObject = BlockPosition.PooledBlockPosition.s();
    if (localPathType1 == PathType.WALKABLE) {
        for (int i = -1; i <= 1; i++) {
            for (int k = -1; k <= 1; k++) {
                if ((i != 0) || (k != 0)) {
                    Block localBlock = paramIBlockAccess.getType(((BlockPosition.PooledBlockPosition) localObject).f(i + paramInt1, paramInt2, k + paramInt3)).getBlock();
                    if (localBlock == Blocks.CACTUS) {
                        localPathType1 = PathType.DANGER_CACTUS;
                    } else if (localBlock == Blocks.FIRE) {
                        localPathType1 = PathType.DANGER_FIRE;
                    }
                }
            }
        }
    }
    ((BlockPosition.PooledBlockPosition) localObject).t();
    return localPathType1;
}
Also used : PathType(net.minecraft.server.v1_11_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) Block(net.minecraft.server.v1_11_R1.Block) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 33 with org.bukkit.craftbukkit.v1_18_R1.block

use of org.bukkit.craftbukkit.v1_18_R1.block in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method b.

@Override
public PathPoint b() {
    int i;
    BlockPosition localObject1;
    if ((e()) && (this.b.isInWater())) {
        i = (int) this.b.getBoundingBox().b;
        localObject1 = new BlockPosition.MutableBlockPosition(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
        Block localObject2 = this.a.getType(localObject1).getBlock();
        while ((localObject2 == Blocks.FLOWING_WATER) || (localObject2 == Blocks.WATER)) {
            i++;
            ((MutableBlockPosition) localObject1).c(MathHelper.floor(this.b.locX), i, MathHelper.floor(this.b.locZ));
            localObject2 = this.a.getType(localObject1).getBlock();
        }
    } else if (this.b.onGround) {
        i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
    } else {
        localObject1 = new BlockPosition(this.b);
        while (((this.a.getType(localObject1).getMaterial() == Material.AIR) || (this.a.getType(localObject1).getBlock().b(this.a, localObject1))) && (localObject1.getY() > 0)) {
            localObject1 = localObject1.down();
        }
        i = localObject1.up().getY();
    }
    localObject1 = new BlockPosition(this.b);
    Object localObject2 = a(this.b, localObject1.getX(), i, localObject1.getZ());
    if (this.b.a((PathType) localObject2) < 0.0F) {
        HashSet<BlockPosition> localHashSet = Sets.newHashSet();
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().f));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().c));
        localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().f));
        for (BlockPosition localBlockPosition : localHashSet) {
            PathType localPathType = a(this.b, localBlockPosition);
            if (this.b.a(localPathType) >= 0.0F) {
                return a(localBlockPosition.getX(), localBlockPosition.getY(), localBlockPosition.getZ());
            }
        }
    }
    return a(localObject1.getX(), i, localObject1.getZ());
}
Also used : PathType(net.minecraft.server.v1_11_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_11_R1.Block) MutableBlockPosition(net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 34 with org.bukkit.craftbukkit.v1_18_R1.block

use of org.bukkit.craftbukkit.v1_18_R1.block in project Citizens2 by CitizensDev.

the class FallingBlockController method createEntity.

@Override
protected Entity createEntity(Location at, NPC npc) {
    WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
    Block id = Blocks.STONE;
    int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
    if (npc.data().has("falling-block-id") || npc.data().has(NPC.ITEM_ID_METADATA)) {
        id = CraftMagicNumbers.getBlock(Material.getMaterial(npc.data().<String>get(NPC.ITEM_ID_METADATA, npc.data().<String>get("falling-block-id"))));
    }
    final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(), id.fromLegacyData(data));
    return handle.getBukkitEntity();
}
Also used : Block(net.minecraft.server.v1_12_R1.Block) EntityFallingBlock(net.minecraft.server.v1_12_R1.EntityFallingBlock) FallingBlock(org.bukkit.entity.FallingBlock) CraftFallingBlock(org.bukkit.craftbukkit.v1_12_R1.entity.CraftFallingBlock) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 35 with org.bukkit.craftbukkit.v1_18_R1.block

use of org.bukkit.craftbukkit.v1_18_R1.block in project NoCheatPlus by NoCheatPlus.

the class BlockCacheCB3026 method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    // TODO: change api for this / use nodes (!)
    @SuppressWarnings("deprecation") final int id = getType(x, y, z).getId();
    final net.minecraft.server.v1_7_R2.Block block = net.minecraft.server.v1_7_R2.Block.e(id);
    if (block == null)
        return null;
    // getData from cache.
    block.updateShape(iBlockAccess, x, y, z);
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { block.x(), block.z(), block.B(), block.y(), block.A(), block.C() };
}
Also used : Block(net.minecraft.server.v1_7_R2.Block)

Aggregations

Block (net.minecraft.server.v1_10_R1.Block)7 Block (net.minecraft.server.v1_11_R1.Block)7 Block (net.minecraft.server.v1_12_R1.Block)7 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)6 Block (net.minecraft.server.v1_8_R3.Block)6 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)4 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)4 Block (net.minecraft.world.level.block.Block)4 ArrayList (java.util.ArrayList)3 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)3 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)3 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)3 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)3 PathPoint (net.minecraft.server.v1_12_R1.PathPoint)3 PathPoint (net.minecraft.server.v1_8_R3.PathPoint)3 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)3 FallingBlock (org.bukkit.entity.FallingBlock)3 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)2