Search in sources :

Example 26 with Entity

use of net.minecraft.server.v1_12_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListAdd.

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(listPlayer);
    EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
}
Also used : EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_12_R1.PacketPlayOutPlayerInfo)

Example 27 with Entity

use of net.minecraft.server.v1_12_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method getBossBar.

public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
    BossBattleServer bserver = null;
    try {
        if (entity.getType() == EntityType.WITHER) {
            bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
        } else if (entity.getType() == EntityType.ENDER_DRAGON) {
            bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
        }
    } catch (Exception e) {
    }
    if (bserver == null) {
        return null;
    }
    BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
    try {
        CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
    } catch (Exception e) {
    }
    return ret;
}
Also used : BossBar(org.bukkit.boss.BossBar) CraftBossBar(org.bukkit.craftbukkit.v1_12_R1.boss.CraftBossBar) BossBattleServer(net.minecraft.server.v1_12_R1.BossBattleServer) ReportedException(net.minecraft.server.v1_12_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 28 with Entity

use of net.minecraft.server.v1_12_R1.Entity in project Citizens2 by CitizensDev.

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, float f, float f1, float f2) {
    if ((entity.cC()) || (entity.bI())) {
        if ((entity.isInWater())) {
            double d2 = entity.locY;
            float f4 = entity instanceof EntityPolarBear ? 0.98F : 0.8F;
            float f3 = 0.02F;
            float f5 = EnchantmentManager.e(entity);
            if (f5 > 3.0F) {
                f5 = 3.0F;
            }
            if (!entity.onGround) {
                f5 *= 0.5F;
            }
            if (f5 > 0.0F) {
                f4 += (0.54600006F - f4) * f5 / 3.0F;
                f3 += (entity.cy() - f3) * f5 / 3.0F;
            }
            entity.b(f, f1, f2, f3);
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            entity.motX *= f4;
            entity.motY *= 0.800000011920929D;
            entity.motZ *= f4;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d2, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if (entity.au()) {
            double d2 = entity.locY;
            entity.b(f, f1, f2, 0.02F);
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            entity.motX *= 0.5D;
            entity.motY *= 0.5D;
            entity.motZ *= 0.5D;
            if (!entity.isNoGravity()) {
                entity.motY -= 0.02D;
            }
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d2, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if (entity.cP()) {
            if (entity.motY > -0.5D) {
                entity.fallDistance = 1.0F;
            }
            Vec3D vec3d = entity.aJ();
            float f6 = entity.pitch * 0.017453292F;
            double d0 = Math.sqrt(vec3d.x * vec3d.x + vec3d.z * vec3d.z);
            double d1 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
            double d3 = vec3d.b();
            float f7 = MathHelper.cos(f6);
            f7 = (float) (f7 * f7 * Math.min(1.0D, d3 / 0.4D));
            entity.motY += -0.08D + f7 * 0.06D;
            if ((entity.motY < 0.0D) && (d0 > 0.0D)) {
                double d4 = entity.motY * -0.1D * f7;
                entity.motY += d4;
                entity.motX += vec3d.x * d4 / d0;
                entity.motZ += vec3d.z * d4 / d0;
            }
            if (f6 < 0.0F) {
                double d4 = d1 * -MathHelper.sin(f6) * 0.04D;
                entity.motY += d4 * 3.2D;
                entity.motX -= vec3d.x * d4 / d0;
                entity.motZ -= vec3d.z * d4 / d0;
            }
            if (d0 > 0.0D) {
                entity.motX += (vec3d.x / d0 * d1 - entity.motX) * 0.1D;
                entity.motZ += (vec3d.z / d0 * d1 - entity.motZ) * 0.1D;
            }
            entity.motX *= 0.9900000095367432D;
            entity.motY *= 0.9800000190734863D;
            entity.motZ *= 0.9900000095367432D;
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (!entity.world.isClientSide)) {
                double d4 = Math.sqrt(entity.motX * entity.motX + entity.motZ * entity.motZ);
                double d5 = d1 - d4;
                float f8 = (float) (d5 * 10.0D - 3.0D);
                if (f8 > 0.0F) {
                    entity.a(f8 > 4 ? SoundEffects.bQ : SoundEffects.bY, 1.0F, 1.0F);
                    entity.damageEntity(DamageSource.FLY_INTO_WALL, f8);
                }
            }
            if ((entity.onGround) && (!entity.world.isClientSide) && (entity.getFlag(7)) && (!CraftEventFactory.callToggleGlideEvent(entity, false).isCancelled())) {
                entity.setFlag(7, false);
            }
        } else {
            float f9 = 0.91F;
            BlockPosition.PooledBlockPosition blockposition_pooledblockposition = BlockPosition.PooledBlockPosition.d(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ);
            if (entity.onGround) {
                f9 = entity.world.getType(blockposition_pooledblockposition).getBlock().frictionFactor * 0.91F;
            }
            float f4 = 0.16277136F / (f9 * f9 * f9);
            float f3;
            if (entity.onGround) {
                f3 = entity.cy() * f4;
            } else {
                f3 = entity.aR;
            }
            entity.b(f, f1, f2, f3);
            f9 = 0.91F;
            if (entity.onGround) {
                f9 = entity.world.getType(blockposition_pooledblockposition.e(entity.locX, entity.getBoundingBox().b - 1.0D, entity.locZ)).getBlock().frictionFactor * 0.91F;
            }
            if (entity.m_()) {
                entity.motX = MathHelper.a(entity.motX, -0.15000000596046448D, 0.15000000596046448D);
                entity.motZ = MathHelper.a(entity.motZ, -0.15000000596046448D, 0.15000000596046448D);
                entity.fallDistance = 0.0F;
                if (entity.motY < -0.15D) {
                    entity.motY = -0.15D;
                }
                boolean flag = (entity.isSneaking());
                if ((flag) && (entity.motY < 0.0D)) {
                    entity.motY = 0.0D;
                }
            }
            entity.move(EnumMoveType.SELF, entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (entity.m_())) {
                entity.motY = 0.2D;
            }
            if (entity.hasEffect(MobEffects.LEVITATION)) {
                entity.motY += (0.05D * (entity.getEffect(MobEffects.LEVITATION).getAmplifier() + 1) - entity.motY) * 0.2D;
            } else {
                blockposition_pooledblockposition.e(entity.locX, 0.0D, entity.locZ);
                if ((entity.world.isClientSide) && ((!entity.world.isLoaded(blockposition_pooledblockposition)) || (!entity.world.getChunkAtWorldCoords(blockposition_pooledblockposition).p()))) {
                    if (entity.locY > 0.0D) {
                        entity.motY = -0.1D;
                    } else {
                        entity.motY = 0.0D;
                    }
                } else if (!entity.isNoGravity()) {
                    entity.motY -= 0.08D;
                }
            }
            entity.motY *= 0.9800000190734863D;
            entity.motX *= f9;
            entity.motZ *= f9;
            blockposition_pooledblockposition.t();
        }
    }
    entity.aF = entity.aG;
    double d2 = entity.locX - entity.lastX;
    double d0 = entity.locZ - entity.lastZ;
    double d1 = (entity instanceof EntityBird) ? entity.locY - entity.lastY : 0.0D;
    float f10 = MathHelper.sqrt(d2 * d2 + d1 * d1 + d0 * d0) * 4.0F;
    if (f10 > 1.0F) {
        f10 = 1.0F;
    }
    entity.aG += (f10 - entity.aG) * 0.4F;
    entity.aH += entity.aG;
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) EntityBird(net.minecraft.server.v1_12_R1.EntityBird) EntityPolarBear(net.minecraft.server.v1_12_R1.EntityPolarBear) Vec3D(net.minecraft.server.v1_12_R1.Vec3D)

Example 29 with Entity

use of net.minecraft.server.v1_12_R1.Entity in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method run.

@Override
public BehaviorStatus run() {
    if (entity.dead) {
        return BehaviorStatus.FAILURE;
    }
    if (!isDigging) {
        return BehaviorStatus.SUCCESS;
    }
    // CraftBukkit
    currentTick = (int) (System.currentTimeMillis() / 50);
    if (configuration.radiusSquared() > 0 && distanceSquared() >= configuration.radiusSquared()) {
        startDigTick = currentTick;
        if (entity instanceof NPCHolder) {
            NPC npc = ((NPCHolder) entity).getNPC();
            if (npc != null && !npc.getNavigator().isNavigating()) {
                npc.getNavigator().setTarget(entity.world.getWorld().getBlockAt(x, y, z).getLocation().add(0, 1, 0));
            }
        }
        return BehaviorStatus.RUNNING;
    }
    Util.faceLocation(entity.getBukkitEntity(), location);
    if (entity instanceof EntityPlayer) {
        PlayerAnimation.ARM_SWING.play((Player) entity.getBukkitEntity());
    }
    IBlockData block = entity.world.getType(new BlockPosition(x, y, z));
    if (block == null || block == Blocks.AIR) {
        return BehaviorStatus.SUCCESS;
    } else {
        int tickDifference = currentTick - startDigTick;
        float damage = getStrength(block) * (tickDifference + 1) * configuration.blockStrengthModifier();
        if (damage >= 1F) {
            entity.world.getWorld().getBlockAt(x, y, z).breakNaturally(CraftItemStack.asCraftMirror(getCurrentItem()));
            return BehaviorStatus.SUCCESS;
        }
        int modifiedDamage = (int) (damage * 10.0F);
        if (modifiedDamage != currentDamage) {
            setBlockDamage(modifiedDamage);
            currentDamage = modifiedDamage;
        }
    }
    return BehaviorStatus.RUNNING;
}
Also used : NPC(net.citizensnpcs.api.npc.NPC) IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer)

Example 30 with Entity

use of net.minecraft.server.v1_12_R1.Entity in project Citizens2 by CitizensDev.

the class PlayerlistTrackerEntry method updatePlayer.

@Override
public void updatePlayer(final EntityPlayer entityplayer) {
    // prevent updates to NPC "viewers"
    if (entityplayer instanceof EntityHumanNPC)
        return;
    Entity tracker = getTracker(this);
    if (entityplayer != tracker && c(entityplayer)) {
        if (!this.trackedPlayers.contains(entityplayer) && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, tracker.ae, tracker.ag)) || (tracker.attachedToPlayer))) {
            if ((tracker instanceof SkinnableEntity)) {
                SkinnableEntity skinnable = (SkinnableEntity) tracker;
                Player player = skinnable.getBukkitEntity();
                if (!entityplayer.getBukkitEntity().canSee(player))
                    return;
                skinnable.getSkinTracker().updateViewer(entityplayer.getBukkitEntity());
            }
        }
    }
    super.updatePlayer(entityplayer);
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_8_R3.Entity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)51 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)41 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)26 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)21 Entity (org.bukkit.entity.Entity)16 Entity (net.minecraft.server.v1_12_R1.Entity)13 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)12 Entity (net.minecraft.server.v1_11_R1.Entity)12 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)11 Entity (net.minecraft.server.v1_8_R3.Entity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 Player (org.bukkit.entity.Player)11 Entity (net.minecraft.server.v1_10_R1.Entity)10 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)9 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)9 PathEntity (net.minecraft.server.v1_8_R3.PathEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)9 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)9 Entity (com.google.datastore.v1.Entity)8