2016-02-05 00:29:41 +00:00
|
|
|
package me.TheBukor.SkStuff.effects;
|
|
|
|
|
2016-02-14 23:58:54 +00:00
|
|
|
import java.lang.reflect.Constructor;
|
|
|
|
|
2016-02-05 00:29:41 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2016-02-16 00:33:49 +00:00
|
|
|
import org.bukkit.Material;
|
2016-02-07 12:39:37 +00:00
|
|
|
import org.bukkit.entity.Animals;
|
2016-02-08 00:49:09 +00:00
|
|
|
import org.bukkit.entity.Blaze;
|
2016-02-06 18:09:06 +00:00
|
|
|
import org.bukkit.entity.Creeper;
|
2016-02-14 23:58:54 +00:00
|
|
|
import org.bukkit.entity.Enderman;
|
|
|
|
import org.bukkit.entity.Ghast;
|
2016-02-17 23:15:11 +00:00
|
|
|
import org.bukkit.entity.Guardian;
|
2016-02-05 00:29:41 +00:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2016-02-08 00:49:09 +00:00
|
|
|
import org.bukkit.entity.Ocelot;
|
2016-02-17 23:15:11 +00:00
|
|
|
import org.bukkit.entity.PigZombie;
|
2016-02-05 00:29:41 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2016-02-17 23:15:11 +00:00
|
|
|
import org.bukkit.entity.Rabbit;
|
2016-02-14 23:58:54 +00:00
|
|
|
import org.bukkit.entity.Silverfish;
|
2016-02-17 23:15:11 +00:00
|
|
|
import org.bukkit.entity.Slime;
|
2016-02-14 23:58:54 +00:00
|
|
|
import org.bukkit.entity.Spider;
|
2016-02-08 00:49:09 +00:00
|
|
|
import org.bukkit.entity.Squid;
|
2016-02-07 12:39:37 +00:00
|
|
|
import org.bukkit.entity.Tameable;
|
2016-02-05 00:29:41 +00:00
|
|
|
import org.bukkit.event.Event;
|
2016-02-16 00:33:49 +00:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
import com.google.common.base.Predicate;
|
|
|
|
import com.google.common.base.Predicates;
|
2016-02-05 00:29:41 +00:00
|
|
|
|
|
|
|
import ch.njol.skript.entity.EntityData;
|
|
|
|
import ch.njol.skript.lang.Effect;
|
|
|
|
import ch.njol.skript.lang.Expression;
|
|
|
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
2016-02-06 02:53:11 +00:00
|
|
|
import ch.njol.skript.util.Timespan;
|
2016-02-05 00:29:41 +00:00
|
|
|
import ch.njol.util.Kleenean;
|
|
|
|
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
|
|
|
|
2016-02-06 18:09:06 +00:00
|
|
|
public class EffSetPathGoal extends Effect {
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Integer> goalPriority;
|
2016-02-06 02:53:11 +00:00
|
|
|
private Expression<EntityData<?>> typeToAvoid;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> avoidRadius;
|
2016-02-16 00:33:49 +00:00
|
|
|
private Expression<Number> avoidSpeed;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Number> avoidSpeedNear;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> breedSpeed;
|
|
|
|
private Expression<Number> fleeSunSpeed;
|
|
|
|
private Expression<Number> followOwnerSpeed;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Number> followMinDist;
|
|
|
|
private Expression<Number> followMaxDist;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> followAdultsSpeed;
|
2016-02-06 02:53:11 +00:00
|
|
|
private Expression<EntityData<?>> typesToFightBack;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Boolean> callForHelp;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> jumpOnBlockSpeed;
|
|
|
|
private Expression<Number> leapHeight;
|
2016-02-06 02:53:11 +00:00
|
|
|
private Expression<EntityData<?>> lookType;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> lookRadius;
|
|
|
|
private Expression<EntityData<?>> meleeTarget;
|
|
|
|
private Expression<Number> meleeSpeed;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Boolean> meleeMemorize;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> moveTargetSpeed;
|
|
|
|
private Expression<Number> moveTargetRadius;
|
|
|
|
private Expression<EntityData<?>> nearTarget;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Boolean> checkSight;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<Number> panicSpeed;
|
|
|
|
private Expression<Number> randomWalkSpeed;
|
2016-02-06 02:53:11 +00:00
|
|
|
private Expression<Timespan> randomWalkInterval;
|
2016-02-16 00:33:49 +00:00
|
|
|
private Expression<ItemStack> temptItem;
|
|
|
|
private Expression<Number> temptSpeed;
|
2016-02-20 05:50:47 +00:00
|
|
|
private Expression<Boolean> temptScared;
|
2016-02-16 00:33:49 +00:00
|
|
|
private Expression<EntityData<?>> nonTamedTarget;
|
2016-02-05 00:29:41 +00:00
|
|
|
private Expression<LivingEntity> entity;
|
|
|
|
|
|
|
|
private int mark;
|
|
|
|
|
2016-02-16 00:33:49 +00:00
|
|
|
private Class<?> craftItemClass = ReflectionUtils.getOBCClass("inventory.CraftItemStack");
|
2016-02-08 00:49:09 +00:00
|
|
|
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
|
2016-02-05 00:29:41 +00:00
|
|
|
private Class<?> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal", false);
|
|
|
|
private Class<?> entCreature = ReflectionUtils.getNMSClass("EntityCreature", false);
|
|
|
|
private Class<?> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
|
2016-02-06 02:53:11 +00:00
|
|
|
private Class<?> entTameable = ReflectionUtils.getNMSClass("EntityTameableAnimal", false);
|
2016-02-16 00:33:49 +00:00
|
|
|
private Class<?> nmsItemClass = ReflectionUtils.getNMSClass("Item", false);
|
2016-02-05 00:29:41 +00:00
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
|
|
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
|
|
|
goalPriority = (Expression<Integer>) expr[0];
|
|
|
|
mark = result.mark;
|
|
|
|
if (mark == 0) {
|
2016-02-06 02:53:11 +00:00
|
|
|
typeToAvoid = (Expression<EntityData<?>>) expr[1];
|
2016-02-05 00:29:41 +00:00
|
|
|
avoidRadius = (Expression<Number>) expr[2];
|
2016-02-16 00:33:49 +00:00
|
|
|
avoidSpeed = (Expression<Number>) expr[3];
|
2016-02-20 05:50:47 +00:00
|
|
|
avoidSpeedNear = (Expression<Number>) expr[4];
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 2) {
|
2016-02-20 05:50:47 +00:00
|
|
|
breedSpeed = (Expression<Number>) expr[5];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 4) {
|
2016-02-20 05:50:47 +00:00
|
|
|
fleeSunSpeed = (Expression<Number>) expr[6];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 6) {
|
2016-02-20 05:50:47 +00:00
|
|
|
followOwnerSpeed = (Expression<Number>) expr[7];
|
|
|
|
followMinDist = (Expression<Number>) expr[8];
|
|
|
|
followMaxDist = (Expression<Number>) expr[9];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 7) {
|
2016-02-20 05:50:47 +00:00
|
|
|
followAdultsSpeed = (Expression<Number>) expr[10];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 8) {
|
2016-02-20 05:50:47 +00:00
|
|
|
typesToFightBack = (Expression<EntityData<?>>) expr[11];
|
|
|
|
callForHelp = (Expression<Boolean>) expr[12];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 9) {
|
2016-02-20 05:50:47 +00:00
|
|
|
jumpOnBlockSpeed = (Expression<Number>) expr[13];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 10) {
|
2016-02-20 05:50:47 +00:00
|
|
|
leapHeight = (Expression<Number>) expr[14];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 11) {
|
2016-02-20 05:50:47 +00:00
|
|
|
lookType = (Expression<EntityData<?>>) expr[15];
|
|
|
|
lookRadius = (Expression<Number>) expr[16];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 12) {
|
2016-02-20 05:50:47 +00:00
|
|
|
meleeTarget = (Expression<EntityData<?>>) expr[17];
|
|
|
|
meleeSpeed = (Expression<Number>) expr[18];
|
|
|
|
meleeMemorize = (Expression<Boolean>) expr[19];
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 13) {
|
2016-02-20 05:50:47 +00:00
|
|
|
moveTargetSpeed = (Expression<Number>) expr[20];
|
|
|
|
moveTargetRadius = (Expression<Number>) expr[21];
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 14) {
|
2016-02-20 05:50:47 +00:00
|
|
|
nearTarget = (Expression<EntityData<?>>) expr[22];
|
|
|
|
checkSight = (Expression<Boolean>) expr[23];
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 17) {
|
2016-02-20 05:50:47 +00:00
|
|
|
panicSpeed = (Expression<Number>) expr[24];
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 19) {
|
2016-02-20 05:50:47 +00:00
|
|
|
randomWalkSpeed = (Expression<Number>) expr[25];
|
|
|
|
randomWalkInterval = (Expression<Timespan>) expr[26];
|
2016-02-16 00:33:49 +00:00
|
|
|
} else if (mark == 31) {
|
2016-02-20 05:50:47 +00:00
|
|
|
temptItem = (Expression<ItemStack>) expr[27];
|
|
|
|
temptSpeed = (Expression<Number>) expr[28];
|
|
|
|
temptScared = (Expression<Boolean>) expr[29];
|
2016-02-16 00:33:49 +00:00
|
|
|
} else if (mark == 32) {
|
2016-02-20 05:50:47 +00:00
|
|
|
nonTamedTarget = (Expression<EntityData<?>>) expr[30];
|
2016-02-05 00:29:41 +00:00
|
|
|
}
|
2016-02-20 05:50:47 +00:00
|
|
|
entity = (Expression<LivingEntity>) expr[31];
|
2016-02-05 00:29:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-02-14 23:58:54 +00:00
|
|
|
public String toString(@Nullable Event e, boolean debug) {
|
2016-02-20 05:50:47 +00:00
|
|
|
return "add pathfinder goal to" + entity.toString(e, debug);
|
2016-02-05 00:29:41 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 18:09:06 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2016-02-05 00:29:41 +00:00
|
|
|
@Override
|
|
|
|
protected void execute(Event e) {
|
|
|
|
int priority = 0;
|
|
|
|
if (goalPriority != null) {
|
|
|
|
priority = goalPriority.getSingle(e).intValue();
|
|
|
|
} else {
|
2016-02-14 23:58:54 +00:00
|
|
|
priority = 4;
|
2016-02-05 00:29:41 +00:00
|
|
|
}
|
2016-02-20 05:50:47 +00:00
|
|
|
if (priority < 0) {
|
|
|
|
priority = 0;
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (priority > 9) {
|
|
|
|
priority = 9;
|
|
|
|
}
|
|
|
|
LivingEntity ent = entity.getSingle(e);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (ent == null ||ent instanceof Player)
|
2016-02-05 00:29:41 +00:00
|
|
|
return;
|
|
|
|
Object obcEnt = craftLivEnt.cast(ent);
|
|
|
|
try {
|
2016-02-14 23:58:54 +00:00
|
|
|
Object nmsEnt = null;
|
2016-02-06 02:53:11 +00:00
|
|
|
boolean target = false;
|
2016-02-05 00:29:41 +00:00
|
|
|
Object newGoal = null;
|
2016-02-08 00:49:09 +00:00
|
|
|
nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
|
2016-02-05 00:29:41 +00:00
|
|
|
Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
2016-02-06 02:53:11 +00:00
|
|
|
Object targets = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
2016-02-05 00:29:41 +00:00
|
|
|
if (mark == 0) {
|
2016-02-20 05:50:47 +00:00
|
|
|
float radius = 6.0F;
|
|
|
|
double spd = 1.0D;
|
|
|
|
double nearSpd = 1.2D;
|
|
|
|
if (avoidRadius != null)
|
|
|
|
radius = avoidRadius.getSingle(e).floatValue();
|
|
|
|
if (avoidSpeed != null)
|
|
|
|
spd = avoidSpeed.getSingle(e).doubleValue();
|
|
|
|
if (avoidSpeedNear != null)
|
|
|
|
nearSpd = avoidSpeedNear.getSingle(e).doubleValue();
|
2016-02-05 00:29:41 +00:00
|
|
|
EntityData<?> entityData;
|
2016-02-06 02:53:11 +00:00
|
|
|
String exprInput = typeToAvoid.toString(e, false);
|
2016-02-05 00:29:41 +00:00
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-05 00:29:41 +00:00
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
2016-02-16 00:33:49 +00:00
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
2016-02-05 00:29:41 +00:00
|
|
|
className = "Entity" + className;
|
|
|
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
|
|
|
if (nmsClass == null)
|
|
|
|
return;
|
2016-02-17 23:15:11 +00:00
|
|
|
if (ent instanceof Rabbit) {
|
|
|
|
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else {
|
|
|
|
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
|
2016-02-17 23:15:11 +00:00
|
|
|
}
|
2016-02-05 00:29:41 +00:00
|
|
|
} else if (mark == 1) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
2016-02-05 00:29:41 +00:00
|
|
|
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 2) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (breedSpeed != null)
|
|
|
|
spd = breedSpeed.getSingle(e).doubleValue();
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!(ent instanceof Animals))
|
2016-02-05 00:29:41 +00:00
|
|
|
return;
|
|
|
|
newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
|
|
|
} else if (mark == 3) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
|
2016-02-05 00:29:41 +00:00
|
|
|
newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 4) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (fleeSunSpeed != null)
|
|
|
|
spd = fleeSunSpeed.getSingle(e).doubleValue();
|
2016-02-05 00:29:41 +00:00
|
|
|
newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 5) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 6) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (followOwnerSpeed != null)
|
|
|
|
spd = followOwnerSpeed.getSingle(e).doubleValue();
|
|
|
|
float minDist = 3.0F;
|
|
|
|
if (followMinDist != null)
|
|
|
|
minDist = followMinDist.getSingle(e).floatValue();
|
|
|
|
float maxDist = 10.0F;
|
|
|
|
if (followMaxDist != null)
|
|
|
|
maxDist = followMaxDist.getSingle(e).floatValue();
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!(ent instanceof Tameable))
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
2016-02-20 05:50:47 +00:00
|
|
|
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, maxDist, minDist);
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 7) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (followAdultsSpeed != null)
|
|
|
|
spd = followAdultsSpeed.getSingle(e).doubleValue();
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!(ent instanceof Animals))
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
|
|
|
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
|
|
|
} else if (mark == 8) {
|
|
|
|
target = true;
|
2016-02-20 05:50:47 +00:00
|
|
|
boolean callHelp = false;
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
2016-02-06 02:53:11 +00:00
|
|
|
EntityData<?> entityData;
|
|
|
|
String exprInput = typesToFightBack.toString(e, false);
|
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
|
|
|
return;
|
2016-02-06 02:53:11 +00:00
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
2016-02-16 00:33:49 +00:00
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
2016-02-06 02:53:11 +00:00
|
|
|
className = "Entity" + className;
|
2016-02-06 18:09:06 +00:00
|
|
|
Class<?>[] nmsClass = new Class<?>[] { ReflectionUtils.getNMSClass(className, false) };
|
|
|
|
if (nmsClass[0] == null)
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
2016-02-20 05:50:47 +00:00
|
|
|
if (callForHelp != null)
|
|
|
|
callHelp = callForHelp.getSingle(e);
|
|
|
|
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, callHelp, nmsClass);
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 9) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (jumpOnBlockSpeed != null)
|
|
|
|
spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
|
2016-02-08 00:49:09 +00:00
|
|
|
if (!(ent instanceof Ocelot))
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
2016-02-08 00:49:09 +00:00
|
|
|
newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 10) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
float height = 0.4F;
|
|
|
|
if (leapHeight != null)
|
|
|
|
height = leapHeight.getSingle(e).floatValue();
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
|
|
|
|
} else if (mark == 11) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
2016-02-06 02:53:11 +00:00
|
|
|
EntityData<?> entityData;
|
|
|
|
String exprInput = lookType.toString(e, false);
|
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
|
|
|
return;
|
2016-02-06 02:53:11 +00:00
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
2016-02-16 00:33:49 +00:00
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
2016-02-06 02:53:11 +00:00
|
|
|
className = "Entity" + className;
|
|
|
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
|
|
|
if (nmsClass == null)
|
|
|
|
return;
|
2016-02-20 05:50:47 +00:00
|
|
|
float radius = 1.0F;
|
|
|
|
if (lookRadius != null)
|
|
|
|
radius = lookRadius.getSingle(e).floatValue();
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, nmsClass, radius);
|
|
|
|
} else if (mark == 12) {
|
|
|
|
EntityData<?> entityData;
|
|
|
|
String exprInput = meleeTarget.toString(e, false);
|
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
2016-02-16 00:33:49 +00:00
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
|
|
|
className = "Entity" + className;
|
|
|
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
|
|
|
if (nmsClass == null)
|
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
if (ent instanceof Spider) {
|
2016-02-16 00:33:49 +00:00
|
|
|
Class<?> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack", false);
|
|
|
|
Constructor<?> constr = goalSpiderMelee.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
|
2016-02-14 23:58:54 +00:00
|
|
|
constr.setAccessible(true);
|
2016-02-16 00:33:49 +00:00
|
|
|
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
2016-02-14 23:58:54 +00:00
|
|
|
} else {
|
|
|
|
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (meleeSpeed != null)
|
|
|
|
spd = meleeSpeed.getSingle(e).doubleValue();
|
|
|
|
boolean memorize = false;
|
|
|
|
if (meleeMemorize != null)
|
|
|
|
memorize = meleeMemorize.getSingle(e);
|
|
|
|
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, memorize);
|
2016-02-14 23:58:54 +00:00
|
|
|
}
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 13) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (moveTargetSpeed != null)
|
|
|
|
spd = moveTargetSpeed.getSingle(e).doubleValue();
|
|
|
|
float radius = 32.0F;
|
|
|
|
if (moveTargetRadius != null)
|
|
|
|
radius = moveTargetRadius.getSingle(e).floatValue();
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
|
|
|
|
} else if (mark == 14) {
|
|
|
|
target = true;
|
2016-02-20 05:50:47 +00:00
|
|
|
boolean checkView = false;
|
2016-02-06 02:53:11 +00:00
|
|
|
EntityData<?> entityData;
|
|
|
|
String exprInput = nearTarget.toString(e, false);
|
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
2016-02-06 02:53:11 +00:00
|
|
|
return;
|
2016-02-16 00:33:49 +00:00
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
|
|
|
className = "Entity" + className;
|
|
|
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
|
|
|
if (nmsClass == null)
|
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
if (ent instanceof Spider) {
|
|
|
|
Class<?> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget", false);
|
|
|
|
Constructor<?> constr = goalSpiderNearTarget.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
|
|
|
|
constr.setAccessible(true);
|
2016-02-16 00:33:49 +00:00
|
|
|
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
2016-02-14 23:58:54 +00:00
|
|
|
} else {
|
2016-02-20 05:50:47 +00:00
|
|
|
if (checkSight != null)
|
|
|
|
checkView = checkSight.getSingle(e);
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, checkView);
|
2016-02-14 23:58:54 +00:00
|
|
|
}
|
2016-02-06 02:53:11 +00:00
|
|
|
} else if (mark == 15) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalOcelotAttack.getConstructor(entInsent).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 16) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
2016-02-06 18:09:06 +00:00
|
|
|
newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt, false);
|
|
|
|
} else if (mark == 17) {
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (panicSpeed != null)
|
|
|
|
spd = panicSpeed.getSingle(e).doubleValue();
|
2016-02-17 23:15:11 +00:00
|
|
|
if (ent instanceof Rabbit) {
|
|
|
|
Class<?> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic", false);
|
|
|
|
newGoal = goalRabbitPanic.getDeclaredConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
|
|
|
} else {
|
|
|
|
Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
|
|
|
|
|
|
|
|
newGoal = goalPanic.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
|
|
|
}
|
2016-02-06 18:09:06 +00:00
|
|
|
} else if (mark == 18) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround", false);
|
2016-02-06 18:09:06 +00:00
|
|
|
newGoal = goalRandomLook.getConstructor(entInsent).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 19) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (randomWalkSpeed != null)
|
|
|
|
spd = randomWalkSpeed.getSingle(e).doubleValue();
|
|
|
|
int interval = 120;
|
|
|
|
if (randomWalkInterval != null)
|
|
|
|
interval = randomWalkInterval.getSingle(e).getTicks();
|
2016-02-06 18:09:06 +00:00
|
|
|
newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
|
|
|
|
} else if (mark == 20) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
|
|
|
if (!(ent instanceof Tameable))
|
2016-02-06 18:09:06 +00:00
|
|
|
return;
|
|
|
|
newGoal = goalSit.getConstructor(entTameable).newInstance(nmsEnt);
|
|
|
|
} else if (mark == 21) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
|
|
|
|
if (!(ent instanceof Creeper))
|
2016-02-06 18:09:06 +00:00
|
|
|
return;
|
|
|
|
newGoal = goalSwell.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
2016-02-08 00:49:09 +00:00
|
|
|
} else if (mark == 22) {
|
2016-02-14 23:58:54 +00:00
|
|
|
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
|
|
|
|
if (!(ent instanceof Squid))
|
2016-02-08 00:49:09 +00:00
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
Constructor<?> constr = goalSquid.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 23) {
|
|
|
|
if (ent instanceof Blaze) {
|
|
|
|
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball", false);
|
|
|
|
Constructor<?> constr = goalBlazeFireball.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (ent instanceof Ghast) {
|
|
|
|
Class<?> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget", false);
|
|
|
|
Constructor<?> constr = goalGhastFireball.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-08 00:49:09 +00:00
|
|
|
}
|
2016-02-14 23:58:54 +00:00
|
|
|
} else if (mark == 24) {
|
2016-02-20 05:50:47 +00:00
|
|
|
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock", false);
|
2016-02-14 23:58:54 +00:00
|
|
|
if (!(ent instanceof Silverfish))
|
2016-02-08 00:49:09 +00:00
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
Constructor<?> constr = goalHideInBlock.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 25) {
|
|
|
|
Class<?> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers", false);
|
|
|
|
if (!(ent instanceof Silverfish))
|
2016-02-08 00:49:09 +00:00
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
Constructor<?> constr = goalWakeSilverfish.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 26) {
|
|
|
|
Class<?> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock", false);
|
|
|
|
if (!(ent instanceof Enderman))
|
2016-02-08 00:49:09 +00:00
|
|
|
return;
|
2016-02-14 23:58:54 +00:00
|
|
|
Constructor<?> constr = goalPickBlocks.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 27) {
|
|
|
|
Class<?> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock", false);
|
|
|
|
if (!(ent instanceof Enderman))
|
|
|
|
return;
|
|
|
|
Constructor<?> constr = goalPlaceBlocks.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 28) {
|
|
|
|
target = true;
|
|
|
|
Class<?> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget", false);
|
|
|
|
if (!(ent instanceof Enderman))
|
|
|
|
return;
|
|
|
|
Constructor<?> constr = goalAttackLooker.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 29) {
|
|
|
|
Class<?> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget", false);
|
|
|
|
if (!(ent instanceof Ghast))
|
|
|
|
return;
|
|
|
|
Constructor<?> constr = goalGhastMoveTarget.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 30) {
|
|
|
|
Class<?> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove", false);
|
|
|
|
if (!(ent instanceof Ghast))
|
|
|
|
return;
|
|
|
|
Constructor<?> constr = goalGhastIdleMove.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
|
|
|
} else if (mark == 31) {
|
2016-02-16 00:33:49 +00:00
|
|
|
Class<?> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt", false);
|
|
|
|
ItemStack itemStack = temptItem.getSingle(e);
|
|
|
|
if (itemStack.getType() == Material.AIR || itemStack == null)
|
|
|
|
return;
|
|
|
|
Object nmsItemStack = craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(itemStack, itemStack);
|
|
|
|
Object nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
|
2016-02-20 05:50:47 +00:00
|
|
|
double spd = 1.0D;
|
|
|
|
if (temptSpeed != null)
|
|
|
|
spd = temptSpeed.getSingle(e).doubleValue();
|
|
|
|
boolean scared = false;
|
|
|
|
if (temptScared != null)
|
|
|
|
scared = temptScared.getSingle(e);
|
|
|
|
newGoal = goalTempt.getConstructor(entCreature, double.class, nmsItemClass, boolean.class).newInstance(nmsEnt, spd, nmsItem, scared);
|
2016-02-16 00:33:49 +00:00
|
|
|
} else if (mark == 32) {
|
|
|
|
target = true;
|
|
|
|
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
|
|
|
|
if (!(ent instanceof Tameable))
|
|
|
|
return;
|
|
|
|
EntityData<?> entityData;
|
|
|
|
String exprInput = nonTamedTarget.toString(e, false);
|
|
|
|
if (exprInput.startsWith("the ")) {
|
|
|
|
exprInput = exprInput.substring(4);
|
|
|
|
}
|
|
|
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
|
|
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String className = entityData.getType().getSimpleName();
|
|
|
|
if (className.equals("HumanEntity"))
|
|
|
|
className = "Human";
|
|
|
|
else if (className.equals("LivingEntity"))
|
|
|
|
className = "Living";
|
|
|
|
className = "Entity" + className;
|
|
|
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
|
|
|
if (nmsClass == null)
|
|
|
|
return;
|
|
|
|
newGoal = goalTargetNonTamed.getConstructor(entTameable, Class.class, boolean.class, Predicate.class).newInstance(nmsEnt, nmsClass, false, Predicates.alwaysTrue());
|
|
|
|
} else if (mark == 33) {
|
2016-02-17 23:15:11 +00:00
|
|
|
if (!(ent instanceof Guardian))
|
|
|
|
return;
|
|
|
|
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalGuardianAttack.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 34) {
|
|
|
|
if (!(ent instanceof PigZombie))
|
|
|
|
return;
|
|
|
|
target = true;
|
|
|
|
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalAnger.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 35) {
|
|
|
|
if (!(ent instanceof PigZombie))
|
|
|
|
return;
|
|
|
|
target = true;
|
|
|
|
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalAngerOther.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 36) {
|
|
|
|
if (!(ent instanceof Rabbit))
|
|
|
|
return;
|
|
|
|
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalEatCarrots.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 37) {
|
|
|
|
if (!(ent instanceof Rabbit))
|
|
|
|
return;
|
|
|
|
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalRabbitAttack.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 38) {
|
|
|
|
if (!(ent instanceof Slime))
|
|
|
|
return;
|
|
|
|
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalJump.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 39) {
|
|
|
|
if (!(ent instanceof Slime))
|
|
|
|
return;
|
|
|
|
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalRandomDir.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-17 23:15:11 +00:00
|
|
|
} else if (mark == 40) {
|
|
|
|
if (!(ent instanceof Slime))
|
|
|
|
return;
|
|
|
|
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
Constructor<?> constr = goalSlimeWander.getDeclaredConstructor(nmsEnt.getClass());
|
|
|
|
constr.setAccessible(true);
|
|
|
|
newGoal = constr.newInstance(nmsEnt);
|
2016-02-06 02:53:11 +00:00
|
|
|
}
|
2016-02-14 23:58:54 +00:00
|
|
|
if (newGoal == null)
|
|
|
|
return;
|
|
|
|
Class<?> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
|
|
|
|
Class<?> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
2016-02-20 05:50:47 +00:00
|
|
|
if (target) { //Target Selector
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
|
2016-02-20 05:50:47 +00:00
|
|
|
} else { //Goal Selector
|
2016-02-06 02:53:11 +00:00
|
|
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
2016-02-14 23:58:54 +00:00
|
|
|
|
2016-02-05 00:29:41 +00:00
|
|
|
}
|
2016-02-14 23:58:54 +00:00
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
2016-02-05 00:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|