Search in sources :

Example 61 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 var0, int var1, int var2, int var3, EntityInsentient var4, int var5, int var6, int var7, boolean var8, boolean var9) {
    EnumSet<PathType> var10 = EnumSet.noneOf(PathType.class);
    PathType var11 = PathType.BLOCKED;
    BlockPosition var12 = var4.getChunkCoordinates();
    var11 = a(var0, var1, var2, var3, var5, var6, var7, var8, var9, var10, var11, var12);
    if (var10.contains(PathType.FENCE))
        return PathType.FENCE;
    if (var10.contains(PathType.UNPASSABLE_RAIL))
        return PathType.UNPASSABLE_RAIL;
    PathType var13 = PathType.BLOCKED;
    for (PathType var15 : var10) {
        if (var4.a(var15) < 0.0F)
            return var15;
        if (var4.a(var15) >= var4.a(var13))
            var13 = var15;
    }
    if (var11 == PathType.OPEN && var4.a(var13) == 0.0F && var5 <= 1)
        return PathType.OPEN;
    return var13;
}
Also used : PathType(net.minecraft.server.v1_16_R3.PathType) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition)

Example 62 with BlockPosition

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

the class NMSImpl method getCollisionBox.

@Override
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    AxisAlignedBB aabb = world.getType(pos).d(world, pos);
    if (aabb == null) {
        aabb = world.getType(pos).e(world, pos);
    }
    return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) BoundingBox(net.citizensnpcs.api.util.BoundingBox) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 63 with BlockPosition

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

the class PlayerAnimationImpl method play.

public static void play(PlayerAnimation animation, Player bplayer, int radius) {
    // TODO: this is pretty gross
    final EntityPlayer player = (EntityPlayer) NMSImpl.getHandle(bplayer);
    if (DEFAULTS.containsKey(animation)) {
        playDefaultAnimation(player, radius, DEFAULTS.get(animation));
        return;
    }
    switch(animation) {
        case SIT:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), true));
            NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("PlayerAnimationImpl");
            if (registry == null) {
                registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
            }
            final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
            holder.spawn(player.getBukkitEntity().getLocation());
            ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
            trait.setGravity(false);
            trait.setHasArms(false);
            trait.setHasBaseplate(false);
            trait.setSmall(true);
            trait.setMarker(true);
            trait.setVisible(false);
            holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
            holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
            new BukkitRunnable() {

                @Override
                public void cancel() {
                    super.cancel();
                    holder.destroy();
                }

                @Override
                public void run() {
                    if (player.dead || !player.valid || !player.getBukkitEntity().hasMetadata("citizens.sitting") || !player.getBukkitEntity().getMetadata("citizens.sitting").get(0).asBoolean()) {
                        cancel();
                        return;
                    }
                    if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
                        cancel();
                        return;
                    }
                    if (!NMS.getPassengers(holder.getEntity()).contains(player.getBukkitEntity())) {
                        NMS.mount(holder.getEntity(), player.getBukkitEntity());
                    }
                }
            }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
            break;
        case SLEEP:
            PacketPlayOutBed packet = new PacketPlayOutBed(player, new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
            sendPacketNearby(packet, player, radius);
            break;
        case SNEAK:
            player.getBukkitEntity().setSneaking(true);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case START_ELYTRA:
            player.N();
            break;
        case START_USE_MAINHAND_ITEM:
            player.c(EnumHand.MAIN_HAND);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case START_USE_OFFHAND_ITEM:
            player.c(EnumHand.OFF_HAND);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case STOP_SITTING:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), false));
            NMS.mount(player.getBukkitEntity(), null);
            break;
        case STOP_SLEEPING:
            playDefaultAnimation(player, radius, 2);
            break;
        case STOP_SNEAKING:
            player.getBukkitEntity().setSneaking(false);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case STOP_USE_ITEM:
            player.clearActiveItem();
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) PacketPlayOutEntityMetadata(net.minecraft.server.v1_12_R1.PacketPlayOutEntityMetadata) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) PacketPlayOutBed(net.minecraft.server.v1_12_R1.PacketPlayOutBed) MemoryNPCDataStore(net.citizensnpcs.api.npc.MemoryNPCDataStore) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) ArmorStandTrait(net.citizensnpcs.trait.ArmorStandTrait) NPCRegistry(net.citizensnpcs.api.npc.NPCRegistry)

Example 64 with BlockPosition

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

the class PlayerNavigation method s.

private int s() {
    if ((!this.a.isInWater()) || (!h())) {
        return (int) (this.a.getBoundingBox().b + 0.5D);
    }
    int j = (int) this.a.getBoundingBox().b;
    Block localBlock = this.b.getType(new BlockPosition(MathHelper.floor(this.a.locX), j, MathHelper.floor(this.a.locZ))).getBlock();
    int k = 0;
    while ((localBlock == Blocks.FLOWING_WATER) || (localBlock == Blocks.WATER)) {
        j++;
        localBlock = this.b.getType(new BlockPosition(MathHelper.floor(this.a.locX), j, MathHelper.floor(this.a.locZ))).getBlock();
        k++;
        if (k > 16) {
            return (int) this.a.getBoundingBox().b;
        }
    }
    return j;
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Block(net.minecraft.server.v1_12_R1.Block) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Example 65 with BlockPosition

use of net.minecraft.server.v1_15_R1.BlockPosition 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_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) Block(net.minecraft.server.v1_12_R1.Block) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) PathPoint(net.minecraft.server.v1_12_R1.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)57 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)36 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)34 Location (org.bukkit.Location)32 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)30 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)30 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)27 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)26 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)24 Chunk (org.bukkit.Chunk)24 ArrayList (java.util.ArrayList)22 List (java.util.List)20 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 Block (org.bukkit.block.Block)14 HashMap (java.util.HashMap)12 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)10 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)9