Search in sources :

Example 26 with BlockPosition

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

the class ItemFrameController method createEntity.

@Override
protected Entity createEntity(Location at, NPC npc) {
    Entity e = super.createEntity(at, npc);
    EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
    item.setDirection(EnumDirection.EAST);
    item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
    return e;
}
Also used : Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) EntityItemFrame(net.minecraft.server.v1_8_R3.EntityItemFrame) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition)

Example 27 with BlockPosition

use of net.minecraft.server.v1_8_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));
            final NPC holder = CitizensAPI.getNPCRegistry().createNPC(EntityType.ARMOR_STAND, "");
            holder.spawn(player.getBukkitEntity().getLocation());
            ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
            trait.setGravity(false);
            trait.setHasArms(false);
            trait.setHasBaseplate(false);
            trait.setSmall(true);
            trait.setMarker(true);
            trait.setVisible(false);
            holder.getTrait(ArmorStandTrait.class).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().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_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_11_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) PacketPlayOutEntityMetadata(net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ArmorStandTrait(net.citizensnpcs.trait.ArmorStandTrait) PacketPlayOutBed(net.minecraft.server.v1_11_R1.PacketPlayOutBed)

Example 28 with BlockPosition

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

the class PlayerNavigation method a2.

public PathEntity a2(BlockPosition paramBlockPosition) {
    if (!b()) {
        return null;
    }
    if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.q))) {
        return this.c;
    }
    this.q = paramBlockPosition;
    float f1 = h();
    this.b.methodProfiler.a("pathfind");
    BlockPosition localBlockPosition = new BlockPosition(this.a);
    int i1 = (int) (f1 + 8.0F);
    ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1), localBlockPosition.a(i1, i1, i1), 0);
    PathEntity localPathEntity = this.r.a(localChunkCache, this.a, this.q, f1);
    this.b.methodProfiler.b();
    return localPathEntity;
}
Also used : ChunkCache(net.minecraft.server.v1_11_R1.ChunkCache) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) PathEntity(net.minecraft.server.v1_11_R1.PathEntity) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 29 with BlockPosition

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

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    PathType localObject1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = 0; i < paramInt4; i++) {
        for (int k = 0; k < paramInt5; k++) {
            for (int m = 0; m < paramInt6; m++) {
                int n = i + paramInt1;
                int i1 = k + paramInt2;
                int i2 = m + paramInt3;
                PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
                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 == 0) && (k == 0) && (m == 0)) {
                    localObject1 = localPathType2;
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    PathType localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return localObject2;
}
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) BlockMinecartTrackAbstract(net.minecraft.server.v1_11_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 30 with BlockPosition

use of net.minecraft.server.v1_8_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);
    PathType localObject1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = 0; i < paramInt4; i++) {
        for (int k = 0; k < paramInt5; k++) {
            for (int m = 0; m < paramInt6; m++) {
                int n = i + paramInt1;
                int i1 = k + paramInt2;
                int i2 = m + paramInt3;
                PathType localPathType2 = a(paramIBlockAccess, n, i1, i2);
                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 == 0) && (k == 0) && (m == 0)) {
                    localObject1 = localPathType2;
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    PathType localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a(localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a(localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return localObject2;
}
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) BlockMinecartTrackAbstract(net.minecraft.server.v1_11_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Aggregations

BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)23 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)23 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)20 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)17 Location (org.bukkit.Location)16 PathPoint (net.minecraft.server.v1_10_R1.PathPoint)10 PathPoint (net.minecraft.server.v1_11_R1.PathPoint)10 NPC (net.citizensnpcs.api.npc.NPC)8 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 MutableBlockPosition (net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition)7 PathType (net.minecraft.server.v1_10_R1.PathType)7 MutableBlockPosition (net.minecraft.server.v1_11_R1.BlockPosition.MutableBlockPosition)7 MutableBlockPosition (net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition)7 Block (net.minecraft.server.v1_10_R1.Block)6 Block (net.minecraft.server.v1_11_R1.Block)6 PathType (net.minecraft.server.v1_11_R1.PathType)6 PathType (net.minecraft.server.v1_12_R1.PathType)6 BlockPosition (net.minecraft.server.v1_9_R2.BlockPosition)6 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)5 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)5