Search in sources :

Example 6 with EntityHuman

use of net.minecraft.world.entity.player.EntityHuman in project BedWars1058 by andrei1058.

the class Silverfish method u.

@Override
protected void u() {
    this.bR.a(1, new PathfinderGoalFloat(this));
    this.bR.a(2, new PathfinderGoalMeleeAttack(this, 1.9D, false));
    this.bS.a(1, new PathfinderGoalHurtByTarget(this));
    this.bR.a(3, new PathfinderGoalRandomStroll(this, 2D));
    this.bS.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 20, true, false, player -> {
        return (!((EntityHuman) player).getBukkitEntity().isDead()) && (!team.wasMember(((EntityHuman) player).getBukkitEntity().getUniqueId())) && (!team.getArena().isReSpawning(((EntityHuman) player).getBukkitEntity().getUniqueId())) && (!team.getArena().isSpectator(((EntityHuman) player).getBukkitEntity().getUniqueId()));
    }));
    this.bS.a(3, new PathfinderGoalNearestAttackableTarget(this, IGolem.class, 20, true, false, golem -> {
        return ((IGolem) golem).getTeam() != team;
    }));
    this.bS.a(4, new PathfinderGoalNearestAttackableTarget(this, Silverfish.class, 20, true, false, sf -> {
        return ((Silverfish) sf).getTeam() != team;
    }));
}
Also used : ITeam(com.andrei1058.bedwars.api.arena.team.ITeam) WorldServer(net.minecraft.server.level.WorldServer) EntityHuman(net.minecraft.world.entity.player.EntityHuman) VersionCommon(com.andrei1058.bedwars.support.version.common.VersionCommon) EntityTypes(net.minecraft.world.entity.EntityTypes) StringUtils(org.apache.commons.lang.StringUtils) CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent) PathfinderGoalNearestAttackableTarget(net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget) CraftEventFactory(org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory) GenericAttributes(net.minecraft.world.entity.ai.attributes.GenericAttributes) PathfinderGoalFloat(net.minecraft.world.entity.ai.goal.PathfinderGoalFloat) PathfinderGoalRandomStroll(net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll) PathfinderGoalMeleeAttack(net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack) World(net.minecraft.world.level.World) LivingEntity(org.bukkit.entity.LivingEntity) Messages(com.andrei1058.bedwars.api.language.Messages) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftLivingEntity) PathfinderGoalHurtByTarget(net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget) Location(org.bukkit.Location) DamageSource(net.minecraft.world.damagesource.DamageSource) Language(com.andrei1058.bedwars.api.language.Language) EntitySilverfish(net.minecraft.world.entity.monster.EntitySilverfish) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) EntityHuman(net.minecraft.world.entity.player.EntityHuman) PathfinderGoalHurtByTarget(net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget) PathfinderGoalNearestAttackableTarget(net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget) PathfinderGoalMeleeAttack(net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack) PathfinderGoalFloat(net.minecraft.world.entity.ai.goal.PathfinderGoalFloat) PathfinderGoalRandomStroll(net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll) EntitySilverfish(net.minecraft.world.entity.monster.EntitySilverfish)

Example 7 with EntityHuman

use of net.minecraft.world.entity.player.EntityHuman in project LaBoulangerieMmo by LaBoulangerie.

the class Dodging method trigger.

@Override
public void trigger(Event baseEvent, int level) {
    ComboCompletedEvent event = (ComboCompletedEvent) baseEvent;
    Player player = event.getPlayer();
    EntityHuman human = (EntityHuman) ((CraftPlayer) event.getPlayer()).getHandle();
    /**
     * See ItemTrident.java in craftbukkit or TridentItem.java in paper
     * Mapping:
     * k -> power (originally the riptide level)
     * f -> yRot
     * f1 -> xRot
     */
    float power = 1;
    float yRot = human.getYRot();
    float xRot = human.getXRot();
    float f2 = -MathHelper.sin(yRot * 0.017453292F) * MathHelper.cos(xRot * 0.017453292F);
    float f3 = -MathHelper.sin(xRot * 0.017453292F);
    float f4 = MathHelper.cos(yRot * 0.017453292F) * MathHelper.cos(xRot * 0.017453292F);
    float f5 = MathHelper.c(f2 * f2 + f3 * f3 + f4 * f4);
    float f6 = 3.0F * ((1.0F + power) / 4.0F);
    f2 *= f6 / f5;
    f3 *= f6 / f5;
    f4 *= f6 / f5;
    // human.i((double) f2, (double) f3, (double) f4); // = human.push doesn't work
    // but next line replaced it maybe try again in 1.18
    player.setVelocity(new Vector((double) f2, (double) f3, (double) f4));
    human.s(20);
    player.getWorld().playSound(player.getLocation(), Sound.ITEM_TRIDENT_RIPTIDE_1, 1, 1);
}
Also used : EntityHuman(net.minecraft.world.entity.player.EntityHuman) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) Player(org.bukkit.entity.Player) ComboCompletedEvent(net.laboulangerie.laboulangeriemmo.events.ComboCompletedEvent) Vector(org.bukkit.util.Vector)

Example 8 with EntityHuman

use of net.minecraft.world.entity.player.EntityHuman in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_17_R1 method dropItemAsPlayer.

@Override
public void dropItemAsPlayer(HumanEntity humanEntity, org.bukkit.inventory.ItemStack bukkitItem) {
    EntityHuman entityHuman = ((CraftHumanEntity) humanEntity).getHandle();
    ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
    entityHuman.drop(itemStack, false);
}
Also used : EntityHuman(net.minecraft.world.entity.player.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftHumanEntity) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)

Example 9 with EntityHuman

use of net.minecraft.world.entity.player.EntityHuman in project NyaaCore by NyaaCat.

the class NmsUtils method setEntityTag.

/* see CommandEntityData.java */
public static void setEntityTag(Entity e, String tag) {
    net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) e).getHandle();
    if (nmsEntity instanceof EntityHuman) {
        throw new IllegalArgumentException("Player NBT cannot be edited");
    } else {
        NBTTagCompound nbtToBeMerged;
        try {
            nbtToBeMerged = MojangsonParser.parseTag(tag);
        } catch (CommandSyntaxException ex) {
            throw new IllegalArgumentException("Invalid NBTTag string");
        }
        // entity to nbt
        NBTTagCompound nmsOrigNBT = CriterionConditionNBT.getEntityTagToCompare(nmsEntity);
        // clone
        NBTTagCompound nmsClonedNBT = nmsOrigNBT.copy();
        // merge NBT
        nmsClonedNBT.merge(nbtToBeMerged);
        if (nmsClonedNBT.equals(nmsOrigNBT)) {
            return;
        } else {
            // store UUID
            UUID uuid = nmsEntity.getUUID();
            // set nbt
            nmsEntity.load(nmsClonedNBT);
            // set uuid
            nmsEntity.setUUID(uuid);
        }
    }
}
Also used : EntityHuman(net.minecraft.world.entity.player.EntityHuman) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) UUID(java.util.UUID) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException)

Aggregations

EntityHuman (net.minecraft.world.entity.player.EntityHuman)9 ITeam (com.andrei1058.bedwars.api.arena.team.ITeam)4 Language (com.andrei1058.bedwars.api.language.Language)4 Messages (com.andrei1058.bedwars.api.language.Messages)4 VersionCommon (com.andrei1058.bedwars.support.version.common.VersionCommon)4 WorldServer (net.minecraft.server.level.WorldServer)4 DamageSource (net.minecraft.world.damagesource.DamageSource)4 EntityTypes (net.minecraft.world.entity.EntityTypes)4 GenericAttributes (net.minecraft.world.entity.ai.attributes.GenericAttributes)4 PathfinderGoalFloat (net.minecraft.world.entity.ai.goal.PathfinderGoalFloat)4 PathfinderGoalMeleeAttack (net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack)4 PathfinderGoalRandomStroll (net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll)4 PathfinderGoalHurtByTarget (net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget)4 PathfinderGoalNearestAttackableTarget (net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget)4 World (net.minecraft.world.level.World)4 StringUtils (org.apache.commons.lang.StringUtils)4 Location (org.bukkit.Location)4 LivingEntity (org.bukkit.entity.LivingEntity)4 CreatureSpawnEvent (org.bukkit.event.entity.CreatureSpawnEvent)4 ItemStack (net.minecraft.world.item.ItemStack)3