Search in sources :

Example 26 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class Block_1_15_R1 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable Material mask, byte data) {
    if (blocks == null || blocks.isEmpty()) {
        throw new IllegalArgumentException("No blocks are being changed!");
    }
    Map<org.bukkit.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 theMask = mask == null ? null : ((CraftBlockData) mask.createBlockData()).getState();
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, theMask));
    }
    return packets;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Chunk(net.minecraft.server.v1_15_R1.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_15_R1.CraftChunk) IBlockData(net.minecraft.server.v1_15_R1.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData in project MechanicsMain by WeaponMechanics.

the class Block_1_9_R2 method getMultiBlockMaskPacket.

@SuppressWarnings("deprecation")
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable Material mask, byte data) {
    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 theMask = mask == null ? null : net.minecraft.server.v1_9_R2.Block.getByCombinedId(mask.getId() | data << 12);
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, theMask));
    }
    return packets;
}
Also used : IBlockData(net.minecraft.server.v1_9_R2.IBlockData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftChunk(org.bukkit.craftbukkit.v1_9_R2.CraftChunk) Chunk(org.bukkit.Chunk) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with IBlockData

use of net.minecraft.server.v1_13_R2.IBlockData 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 29 with IBlockData

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

the class PlayerNavigation method d.

@Override
protected void d() {
    super.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 (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_10_R1.PathPoint) IBlockData(net.minecraft.server.v1_10_R1.IBlockData) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) Block(net.minecraft.server.v1_10_R1.Block) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 30 with IBlockData

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

the class CitizensBlockBreaker method strengthMod.

private float strengthMod(IBlockData block) {
    ItemStack itemstack = getCurrentItem();
    float f = itemstack.a(block);
    if (getHandle() instanceof EntityLiving) {
        EntityLiving handle = (EntityLiving) getHandle();
        if (f > 1.0F) {
            int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
            if (i > 0) {
                f += i * i + 1;
            }
        }
        if (handle.hasEffect(MobEffects.FASTER_DIG)) {
            f *= (1.0F + (handle.getEffect(MobEffects.FASTER_DIG).getAmplifier() + 1) * 0.2F);
        }
        if (handle.hasEffect(MobEffects.SLOWER_DIG)) {
            float f1 = 1.0F;
            switch(handle.getEffect(MobEffects.SLOWER_DIG).getAmplifier()) {
                case 0:
                    f1 = 0.3F;
                    break;
                case 1:
                    f1 = 0.09F;
                    break;
                case 2:
                    f1 = 0.0027F;
                    break;
                case 3:
                default:
                    f1 = 8.1E-4F;
            }
            f *= f1;
        }
        if (handle.a(TagsFluid.WATER) && !EnchantmentManager.h(handle)) {
            f /= 5.0F;
        }
    }
    if (!getHandle().onGround) {
        f /= 5.0F;
    }
    return f;
}
Also used : EntityLiving(net.minecraft.server.v1_13_R2.EntityLiving) ItemStack(net.minecraft.server.v1_13_R2.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack)

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)14 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