use of net.minecraft.server.v1_14_R1.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();
}
}
use of net.minecraft.server.v1_14_R1.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;
}
}
use of net.minecraft.server.v1_14_R1.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();
}
}
use of net.minecraft.server.v1_14_R1.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;
}
Aggregations