Search in sources :

Example 41 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition in project MechanicsMain by WeaponMechanics.

the class Block_1_10_R1 method getBlastResistance.

@Override
public float getBlastResistance(Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    net.minecraft.server.v1_10_R1.Block nmsBlock = world.c(pos).getBlock();
    return (float) ReflectionUtil.invokeField(durabilityField, nmsBlock) / 5.0f;
}
Also used : BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 42 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition in project MechanicsMain by WeaponMechanics.

the class Block_1_16_R3 method getMultiBlockMaskPacket.

private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
    BlockPosition position = ((CraftBlock) blocks.get(0)).getPosition();
    // Setup default information
    short[] locations = new short[blocks.size()];
    IBlockData[] data = new IBlockData[blocks.size()];
    for (int i = 0; i < locations.length; i++) {
        Block block = blocks.get(i);
        int x = block.getX() & 0xF;
        int y = block.getY() & 0xF;
        int z = block.getZ() & 0xF;
        short shortLocation = (short) (x << 8 | z << 4 | y);
        locations[i] = shortLocation;
        data[i] = mask;
    }
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(SectionPosition.a(position), new ShortArraySet(0), null, false);
    ReflectionUtil.setField(multiBlockChangeB, packet, locations);
    ReflectionUtil.setField(multiBlockChangeC, packet, data);
    return packet;
}
Also used : IBlockData(net.minecraft.server.v1_16_R3.IBlockData) ShortArraySet(org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.shorts.ShortArraySet) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) PacketPlayOutMultiBlockChange(net.minecraft.server.v1_16_R3.PacketPlayOutMultiBlockChange) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)

Example 43 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition in project MechanicsMain by WeaponMechanics.

the class Block_1_12_R1 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
    if (blocks == null || blocks.isEmpty()) {
        throw new IllegalArgumentException("No blocks are being changed!");
    }
    Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
    for (Block block : blocks) {
        List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
        list.add(block);
    }
    List<Object> packets = new ArrayList<>(sortedBlocks.size());
    IBlockData blockData = null;
    if (mask != null) {
        WorldServer world = ((CraftWorld) mask.getWorld()).getHandle();
        BlockPosition pos = new BlockPosition(mask.getX(), mask.getY(), mask.getZ());
        blockData = world.c(pos).getBlock().getBlockData();
    }
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, blockData));
    }
    return packets;
}
Also used : HashMap(java.util.HashMap) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_12_R1.CraftChunk) Chunk(org.bukkit.Chunk) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method getPathTypeBase.

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

Example 45 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    Object localObject1 = PathType.BLOCKED;
    double d = paramEntityInsentient.width / 2.0D;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
        for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
            for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
                PathType localPathType2 = a(paramIBlockAccess, i, k, m);
                if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
                    localPathType2 = PathType.WALKABLE;
                }
                if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
                    localPathType2 = PathType.BLOCKED;
                }
                if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                    localPathType2 = PathType.FENCE;
                }
                if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
                    localObject1 = localPathType2;
                }
                if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
                    AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D, m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
                    if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
                        localPathType2 = PathType.OPEN;
                    }
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject2;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) PathType(net.minecraft.server.v1_10_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) BlockMinecartTrackAbstract(net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)35 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)34 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)32 Location (org.bukkit.Location)31 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)28 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)28 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)23 ArrayList (java.util.ArrayList)22 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)21 List (java.util.List)20 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)18 Map (java.util.Map)17 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)17 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)16 Iterator (java.util.Iterator)14 HashMap (java.util.HashMap)12 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)10 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)10 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)9 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)8