Search in sources :

Example 71 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method removeEntityGoals.

@Override
public void removeEntityGoals(LivingEntity livingEntity) {
    EntityLiving nmsEntity = ((CraftLivingEntity) livingEntity).getHandle();
    if (!(nmsEntity instanceof EntityInsentient))
        return;
    try {
        EntityInsentient insentient = (EntityInsentient) nmsEntity;
        // Remove all goal AI other than floating in water
        Set<PathfinderGoalWrapped> goals = (Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.goalSelector);
        Iterator<PathfinderGoalWrapped> goalsIterator = goals.iterator();
        while (goalsIterator.hasNext()) {
            PathfinderGoalWrapped goal = goalsIterator.next();
            if (goal.j() instanceof PathfinderGoalFloat)
                continue;
            goalsIterator.remove();
        }
        // Remove all targetting AI
        ((Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.targetSelector)).clear();
        // Forget any existing targets
        insentient.setGoalTarget(null);
        // Remove the move controller and replace it with a dummy one
        ControllerMove dummyMoveController = new ControllerMove(insentient) {

            @Override
            public void a() {
            }
        };
        field_EntityInsentient_moveController.set(insentient, dummyMoveController);
    } catch (ReflectiveOperationException ex) {
        ex.printStackTrace();
    }
}
Also used : PathfinderGoalWrapped(net.minecraft.server.v1_16_R2.PathfinderGoalWrapped) Set(java.util.Set) EntityLiving(net.minecraft.server.v1_16_R2.EntityLiving) PathfinderGoalFloat(net.minecraft.server.v1_16_R2.PathfinderGoalFloat) EntityInsentient(net.minecraft.server.v1_16_R2.EntityInsentient) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) ControllerMove(net.minecraft.server.v1_16_R2.ControllerMove)

Example 72 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link EntityTypes#createCreature(WorldServer, NBTTagCompound, IChatBaseComponent, EntityHuman, BlockPosition, EnumMobSpawn, boolean, boolean)}.
 * Contains a patch to prevent chicken jockeys from spawning and to not play the mob sound upon creation.
 */
private <T extends Entity> T createCreature(EntityTypes<T> entityTypes, WorldServer worldserver, NBTTagCompound nbttagcompound, IChatBaseComponent ichatbasecomponent, EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn) {
    T newEntity;
    if (entityTypes == EntityTypes.SPIDER) {
        newEntity = (T) new SoloEntitySpider((EntityTypes<? extends EntitySpider>) entityTypes, worldserver);
    } else if (entityTypes == EntityTypes.STRIDER) {
        newEntity = (T) new SoloEntityStrider((EntityTypes<? extends EntityStrider>) entityTypes, worldserver);
    } else {
        newEntity = entityTypes.a(worldserver);
    }
    if (newEntity == null) {
        return null;
    } else {
        if (field_Entity_spawnReason != null) {
            try {
                field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(enummobspawn));
            } catch (IllegalAccessException ignored) {
            }
        }
        newEntity.setPositionRotation(blockposition.getX() + 0.5D, blockposition.getY(), blockposition.getZ() + 0.5D, MathHelper.g(worldserver.random.nextFloat() * 360.0F), 0.0F);
        if (newEntity instanceof EntityInsentient) {
            EntityInsentient entityinsentient = (EntityInsentient) newEntity;
            entityinsentient.aC = entityinsentient.yaw;
            entityinsentient.aA = entityinsentient.yaw;
            GroupDataEntity groupDataEntity = null;
            if (entityTypes == EntityTypes.DROWNED || entityTypes == EntityTypes.HUSK || entityTypes == EntityTypes.ZOMBIE_VILLAGER || entityTypes == EntityTypes.ZOMBIFIED_PIGLIN || entityTypes == EntityTypes.ZOMBIE) {
                // Don't allow chicken jockeys to spawn
                groupDataEntity = new EntityZombie.GroupDataZombie(EntityZombie.a(worldserver.getRandom()), false);
            }
            entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), enummobspawn, groupDataEntity, nbttagcompound);
        }
        if (ichatbasecomponent != null && newEntity instanceof EntityLiving) {
            newEntity.setCustomName(ichatbasecomponent);
        }
        try {
            EntityTypes.a(worldserver, entityhuman, newEntity, nbttagcompound);
        } catch (Throwable ignored) {
        }
        return newEntity;
    }
}
Also used : EntityTypes(net.minecraft.server.v1_16_R3.EntityTypes) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntitySpider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntityStrider) EntityStrider(net.minecraft.server.v1_16_R3.EntityStrider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntityStrider) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) EntityZombie(net.minecraft.server.v1_16_R3.EntityZombie) GroupDataEntity(net.minecraft.server.v1_16_R3.GroupDataEntity) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient)

Example 73 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method removeEntityGoals.

@Override
public void removeEntityGoals(LivingEntity livingEntity) {
    EntityLiving nmsEntity = ((CraftLivingEntity) livingEntity).getHandle();
    if (!(nmsEntity instanceof EntityInsentient))
        return;
    try {
        EntityInsentient insentient = (EntityInsentient) nmsEntity;
        // Remove all goal AI other than floating in water
        Set<PathfinderGoalWrapped> goals = (Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.goalSelector);
        Iterator<PathfinderGoalWrapped> goalsIterator = goals.iterator();
        while (goalsIterator.hasNext()) {
            PathfinderGoalWrapped goal = goalsIterator.next();
            if (goal.j() instanceof PathfinderGoalFloat)
                continue;
            goalsIterator.remove();
        }
        // Remove all targetting AI
        ((Set<PathfinderGoalWrapped>) field_PathfinderGoalSelector_d.get(insentient.targetSelector)).clear();
        // Forget any existing targets
        insentient.setGoalTarget(null);
        // Remove the move controller and replace it with a dummy one
        ControllerMove dummyMoveController = new ControllerMove(insentient) {

            @Override
            public void a() {
            }
        };
        field_EntityInsentient_moveController.set(insentient, dummyMoveController);
    } catch (ReflectiveOperationException ex) {
        ex.printStackTrace();
    }
}
Also used : PathfinderGoalWrapped(net.minecraft.server.v1_16_R3.PathfinderGoalWrapped) Set(java.util.Set) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) PathfinderGoalFloat(net.minecraft.server.v1_16_R3.PathfinderGoalFloat) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) ControllerMove(net.minecraft.server.v1_16_R3.ControllerMove)

Example 74 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.

the class PlayerPathfinder method a.

@Override
public PathEntity a(ChunkCache var0, EntityInsentient var1, Set<BlockPosition> var2, float var3, int var4, float var5) {
    this.d.a();
    this.c.a(var0, var1);
    PathPoint var6 = this.c.b();
    Map var7 = var2.stream().collect(Collectors.toMap((var0x) -> {
        return this.c.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
    }, Function.identity()));
    PathEntity var8 = this.a(var6, var7, var3, var4, var5);
    this.c.a();
    return var8;
}
Also used : Pathfinder(net.minecraft.server.v1_16_R3.Pathfinder) ImmutableSet(com.google.common.collect.ImmutableSet) EntityHumanNPC(net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) ChunkCache(net.minecraft.server.v1_16_R3.ChunkCache) Sets(com.google.common.collect.Sets) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) Map(java.util.Map) Optional(java.util.Optional) Path(net.minecraft.server.v1_16_R3.Path) Comparator(java.util.Comparator) PathDestination(net.minecraft.server.v1_16_R3.PathDestination) PathPoint(net.minecraft.server.v1_16_R3.PathPoint) PathEntity(net.minecraft.server.v1_16_R3.PathEntity) Map(java.util.Map)

Example 75 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project UltraCosmetics by iSach.

the class PlayerFollower method follow.

@Override
public void follow(Player player) {
    if (player == null) {
        return;
    }
    if (UltraCosmeticsData.get().getPlugin().getPlayerManager().getUltraPlayer(player).getCurrentTreasureChest() != null) {
        return;
    }
    Entity petEntity;
    if (pet.isCustomEntity()) {
        petEntity = ((CustomEntityPet) pet).getCustomEntity();
    } else {
        petEntity = ((CraftEntity) pet.getEntity()).getHandle();
    }
    if (!player.getWorld().equals(petEntity.getBukkitEntity().getWorld())) {
        petEntity.getBukkitEntity().teleport(player.getLocation());
        return;
    }
    ((EntityInsentient) petEntity).getNavigation().a(2);
    Location targetLocation = player.getLocation();
    PathEntity path = ((EntityInsentient) petEntity).getNavigation().a(targetLocation.getX() + 1, targetLocation.getY(), targetLocation.getZ() + 1);
    try {
        int distance = (int) Bukkit.getPlayer(player.getName()).getLocation().distance(petEntity.getBukkitEntity().getLocation());
        if (distance > 10 && petEntity.valid && player.isOnGround()) {
            petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
        }
        if (path != null && distance > 3.3) {
            double speed = 1.05d;
            if (pet.getType().getEntityType() == EntityType.ZOMBIE) {
                speed *= 1.5;
            }
            ((EntityInsentient) petEntity).getNavigation().a(path, speed);
            ((EntityInsentient) petEntity).getNavigation().a(speed);
        }
    } catch (IllegalArgumentException exception) {
        petEntity.setLocation(targetLocation.getBlockX(), targetLocation.getBlockY(), targetLocation.getBlockZ(), 0, 0);
        exception.printStackTrace();
    }
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity) PathEntity(net.minecraft.server.v1_13_R2.PathEntity) PathEntity(net.minecraft.server.v1_13_R2.PathEntity) Location(org.bukkit.Location)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)43 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)42 Location (org.bukkit.Location)18 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)12 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)11 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 CommandException (net.citizensnpcs.api.command.exception.CommandException)8 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)8 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)8 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)8 EntityInsentient (net.minecraft.server.v1_14_R1.EntityInsentient)8 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)7 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)7 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)7 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)7 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)7 PathEntity (net.minecraft.server.v1_13_R2.PathEntity)7 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)7 Vector (org.bukkit.util.Vector)7