Search in sources :

Example 41 with BlockPosition

use of net.minecraft.server.v1_16_R3.BlockPosition in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method shiftClick.

// Overrides 1.15.1
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.b;
    Slot slot = (Slot) this.slots.get(i);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            this.containerAccess.a((world, blockposition) -> {
                itemstack1.getItem().b(itemstack1, world, entityhuman);
            });
            if (!this.a(itemstack1, 10, 46, true)) {
                return ItemStack.b;
            }
            slot.a(itemstack1, itemstack);
        } else if (i >= 10 && i < 46 ? !this.a(itemstack1, 1, 10, false) && (i < 37 ? !this.a(itemstack1, 37, 46, false) : !this.a(itemstack1, 10, 37, false)) : !this.a(itemstack1, 10, 46, false)) {
            return ItemStack.b;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.b);
        } else {
            slot.d();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.b;
        }
        ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack2, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_16_R3.Slot) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 42 with BlockPosition

use of net.minecraft.server.v1_16_R3.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 43 with BlockPosition

use of net.minecraft.server.v1_16_R3.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 44 with BlockPosition

use of net.minecraft.server.v1_16_R3.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 45 with BlockPosition

use of net.minecraft.server.v1_16_R3.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)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)39 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)36 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)34 Location (org.bukkit.Location)31 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)26 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)24 ArrayList (java.util.ArrayList)23 Chunk (org.bukkit.Chunk)23 List (java.util.List)19 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)18 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)18 Map (java.util.Map)17 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)17 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 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)10