More goals, need testing, not ready for release.
This commit is contained in:
parent
06fbaf5a81
commit
679cdef6dd
@ -93,7 +93,7 @@ public class SkStuff extends JavaPlugin {
|
|||||||
getLogger().info("Trying to register version specific stuff...");
|
getLogger().info("Trying to register version specific stuff...");
|
||||||
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentity%");
|
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentity%");
|
||||||
// Skript.registerEffect(EffSetPathGoals.class, "add pathfind[er] goal leap at target to %livingentity% with [leap] height [of] %number%");
|
// Skript.registerEffect(EffSetPathGoals.class, "add pathfind[er] goal leap at target to %livingentity% with [leap] height [of] %number%");
|
||||||
Skript.registerEffect(EffSetPathGoals.class, "add pathfind[er] goal [priority %-integer%] (0¦(avoid|run away from) %entitydata%,[ ]radius %number%,[ ][at] speed %number%,[ ][at] speed if close %number%|1¦break door[s]|2¦breed,[ ][move to[wards] lover at] speed %number%|3¦eat grass|4¦(flee from the sun|seek shad(e|ow)),[ ][at] speed %number%|5¦float (in[side]|on) water|6¦follow (owner|tamer),[ ][at] speed %number%|7¦follow (adult[s]|parent[s]),[ ][at] speed %number%|8¦(fight back|react to|target) (damager|attacker) [[of] type %entitydata%]|9¦o(c|z)elot jump on blocks,[ ][at] speed %number%|10¦leap at target height %number%|11¦look at players,[ ]radius %number%|12¦melee attack %entitydata%,[ ][at] speed %number%|13¦(move|go) indoors|14¦move thr(u|ough) village,[ ][at] speed %number%|15¦move to[wards] target,[ ][at] speed %number%,[ ]radius %number%|16¦attack nearest entity [of] type %entitydata%|17¦o(c|z)elot attack [chicken]|18¦open door[s]|19¦(panic|flee),[ ][at] speed %number%|20¦look around randomly|21¦(walk around randomly|wander),[ ][at] speed %number%,[ ][with] %integer% ticks between mov(e[ment]|ing)|22¦sit|23¦[creeper] swell)");
|
Skript.registerEffect(EffSetPathGoals.class, "add pathfind[er] goal [priority %-integer%] (0¦(avoid|run away from) %entitydata%,[ ]radius %number%,[ ][at] speed %number%,[ ][at] speed if close %number%|1¦break door[s]|2¦breed,[ ][move to[wards] lover at] speed %number%|3¦eat grass|4¦(flee from the sun|seek shad(e|ow)),[ ][at] speed %number%|5¦float (in[side]|on) water|6¦follow (owner|tamer),[ ][at] speed %number%|7¦follow (adult[s]|parent[s]),[ ][at] speed %number%|8¦(fight back|react to|target) (damager|attacker) [[of] type %entitydata%]|9¦o(c|z)elot jump on blocks,[ ][at] speed %number%|10¦leap at target height %number%|11¦look at %entitydata%,[ ]radius %number%|12¦melee attack %entitydata%,[ ][at] speed %number%|13¦move to[wards] target,[ ][at] speed %number%,[ ]radius %number%|14¦attack nearest entity [of] type %entitydata%|15¦o(c|z)elot attack [chicken]|16¦open door[s]|17¦(panic|flee),[ ][at] speed %number%|18¦look around randomly|19¦(walk around randomly|wander),[ ][at] speed %number%,[ ][with] %timespan% between mov(e[ment]|ing)|20¦sit|21¦[creeper] swell) to %livingentity%");
|
||||||
Skript.registerEffect(EffMakeJump.class, "make %livingentity% jump");
|
Skript.registerEffect(EffMakeJump.class, "make %livingentity% jump");
|
||||||
Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
|
Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
|
||||||
Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
|
Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
|
||||||
|
@ -2,7 +2,6 @@ package me.TheBukor.SkStuff.effects;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -11,47 +10,36 @@ import ch.njol.skript.entity.EntityData;
|
|||||||
import ch.njol.skript.lang.Effect;
|
import ch.njol.skript.lang.Effect;
|
||||||
import ch.njol.skript.lang.Expression;
|
import ch.njol.skript.lang.Expression;
|
||||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
|
import ch.njol.skript.util.Timespan;
|
||||||
import ch.njol.util.Kleenean;
|
import ch.njol.util.Kleenean;
|
||||||
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
||||||
|
|
||||||
public class EffSetPathGoals extends Effect {
|
public class EffSetPathGoals extends Effect {
|
||||||
private Expression<Integer> goalPriority;
|
private Expression<Integer> goalPriority;
|
||||||
private Expression<EntityData<?>> entityToAvoid;
|
private Expression<EntityData<?>> typeToAvoid;
|
||||||
private Expression<Number> avoidRadius;
|
private Expression<Number> avoidRadius;
|
||||||
private Expression<Number> avoidSpeed1;
|
private Expression<Number> avoidSpeed1;
|
||||||
private Expression<Number> avoidSpeed2;
|
private Expression<Number> avoidSpeed2;
|
||||||
private Expression<Number> breedSpeed;
|
private Expression<Number> breedSpeed;
|
||||||
private Expression<Number> fleeSunSpeed;
|
private Expression<Number> fleeSunSpeed;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> followOwnerSpeed;
|
private Expression<Number> followOwnerSpeed;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> followAdultsSpeed;
|
private Expression<Number> followAdultsSpeed;
|
||||||
@SuppressWarnings("unused")
|
private Expression<EntityData<?>> typesToFightBack;
|
||||||
private Expression<EntityData<?>> entitiesToFightBack;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> jumpOnBlockSpeed;
|
private Expression<Number> jumpOnBlockSpeed;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> leapHeight;
|
private Expression<Number> leapHeight;
|
||||||
@SuppressWarnings("unused")
|
private Expression<EntityData<?>> lookType;
|
||||||
private Expression<Number> lookRadius;
|
private Expression<Number> lookRadius;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<EntityData<?>> meleeTarget;
|
private Expression<EntityData<?>> meleeTarget;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> meleeSpeed;
|
private Expression<Number> meleeSpeed;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> moveVillageSpeed;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> moveTargetSpeed;
|
private Expression<Number> moveTargetSpeed;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<Number> moveTargetRadius;
|
private Expression<Number> moveTargetRadius;
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Expression<EntityData<?>> nearTarget;
|
private Expression<EntityData<?>> nearTarget;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Expression<Number> panicSpeed;
|
private Expression<Number> panicSpeed;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Expression<Number> randomWalkSpeed;
|
private Expression<Number> randomWalkSpeed;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Expression<Integer> randomWalkInterval;
|
private Expression<Timespan> randomWalkInterval;
|
||||||
private Expression<LivingEntity> entity;
|
private Expression<LivingEntity> entity;
|
||||||
|
|
||||||
private int mark;
|
private int mark;
|
||||||
@ -63,12 +51,24 @@ public class EffSetPathGoals extends Effect {
|
|||||||
private Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
private Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
||||||
private Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
|
private Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
|
||||||
private Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
private Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
||||||
@SuppressWarnings("unused")
|
private Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
||||||
|
private Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
||||||
|
private Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParents", false);
|
||||||
|
private Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
||||||
|
private Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
||||||
private Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
private Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
||||||
|
private Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
||||||
|
private Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
||||||
|
private Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
||||||
|
private Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
||||||
|
private Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
||||||
|
private Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
||||||
|
|
||||||
private Class<?> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal", false);
|
private Class<?> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal", false);
|
||||||
private Class<?> entCreature = ReflectionUtils.getNMSClass("EntityCreature", false);
|
private Class<?> entCreature = ReflectionUtils.getNMSClass("EntityCreature", false);
|
||||||
private Class<?> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
|
private Class<?> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
|
||||||
|
private Class<?> entOcelot = ReflectionUtils.getNMSClass("EntityOcelot", false);
|
||||||
|
private Class<?> entTameable = ReflectionUtils.getNMSClass("EntityTameableAnimal", false);
|
||||||
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
|
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -77,11 +77,11 @@ public class EffSetPathGoals extends Effect {
|
|||||||
goalPriority = (Expression<Integer>) expr[0];
|
goalPriority = (Expression<Integer>) expr[0];
|
||||||
mark = result.mark;
|
mark = result.mark;
|
||||||
if (mark == 0) {
|
if (mark == 0) {
|
||||||
entityToAvoid = (Expression<EntityData<?>>) expr[1];
|
typeToAvoid = (Expression<EntityData<?>>) expr[1];
|
||||||
avoidRadius = (Expression<Number>) expr[2];
|
avoidRadius = (Expression<Number>) expr[2];
|
||||||
avoidSpeed1 = (Expression<Number>) expr[3];
|
avoidSpeed1 = (Expression<Number>) expr[3];
|
||||||
avoidSpeed2 = (Expression<Number>) expr[4];
|
avoidSpeed2 = (Expression<Number>) expr[4];
|
||||||
} else if (mark == 2) {
|
} else if (mark == 2) {
|
||||||
breedSpeed = (Expression<Number>) expr[5];
|
breedSpeed = (Expression<Number>) expr[5];
|
||||||
} else if (mark == 4) {
|
} else if (mark == 4) {
|
||||||
fleeSunSpeed = (Expression<Number>) expr[6];
|
fleeSunSpeed = (Expression<Number>) expr[6];
|
||||||
@ -90,28 +90,27 @@ public class EffSetPathGoals extends Effect {
|
|||||||
} else if (mark == 7) {
|
} else if (mark == 7) {
|
||||||
followAdultsSpeed = (Expression<Number>) expr[8];
|
followAdultsSpeed = (Expression<Number>) expr[8];
|
||||||
} else if (mark == 8) {
|
} else if (mark == 8) {
|
||||||
entitiesToFightBack = (Expression<EntityData<?>>) expr[9];
|
typesToFightBack = (Expression<EntityData<?>>) expr[9];
|
||||||
} else if (mark == 9) {
|
} else if (mark == 9) {
|
||||||
jumpOnBlockSpeed = (Expression<Number>) expr[10];
|
jumpOnBlockSpeed = (Expression<Number>) expr[10];
|
||||||
} else if (mark == 10) {
|
} else if (mark == 10) {
|
||||||
leapHeight = (Expression<Number>) expr[11];
|
leapHeight = (Expression<Number>) expr[11];
|
||||||
} else if (mark == 11) {
|
} else if (mark == 11) {
|
||||||
lookRadius = (Expression<Number>) expr[12];
|
lookType = (Expression<EntityData<?>>) expr[12];
|
||||||
|
lookRadius = (Expression<Number>) expr[13];
|
||||||
} else if (mark == 12) {
|
} else if (mark == 12) {
|
||||||
meleeTarget = (Expression<EntityData<?>>) expr[13];
|
meleeTarget = (Expression<EntityData<?>>) expr[14];
|
||||||
meleeSpeed = (Expression<Number>) expr[14];
|
meleeSpeed = (Expression<Number>) expr[15];
|
||||||
} else if (mark == 13) {
|
} else if (mark == 13) {
|
||||||
moveVillageSpeed = (Expression<Number>) expr[15];
|
|
||||||
} else if (mark == 15) {
|
|
||||||
moveTargetSpeed = (Expression<Number>) expr[16];
|
moveTargetSpeed = (Expression<Number>) expr[16];
|
||||||
moveTargetRadius = (Expression<Number>) expr[17];
|
moveTargetRadius = (Expression<Number>) expr[17];
|
||||||
} else if (mark == 16) {
|
} else if (mark == 14) {
|
||||||
nearTarget = (Expression<EntityData<?>>) expr[18];
|
nearTarget = (Expression<EntityData<?>>) expr[18];
|
||||||
} else if (mark == 19) {
|
} else if (mark == 17) {
|
||||||
panicSpeed = (Expression<Number>) expr[19];
|
panicSpeed = (Expression<Number>) expr[19];
|
||||||
} else if (mark == 21) {
|
} else if (mark == 19) {
|
||||||
randomWalkSpeed = (Expression<Number>) expr[20];
|
randomWalkSpeed = (Expression<Number>) expr[20];
|
||||||
randomWalkInterval = (Expression<Integer>) expr[21];
|
randomWalkInterval = (Expression<Timespan>) expr[21];
|
||||||
}
|
}
|
||||||
entity = (Expression<LivingEntity>) expr[22];
|
entity = (Expression<LivingEntity>) expr[22];
|
||||||
return true;
|
return true;
|
||||||
@ -140,15 +139,17 @@ public class EffSetPathGoals extends Effect {
|
|||||||
return;
|
return;
|
||||||
Object obcEnt = craftLivEnt.cast(ent);
|
Object obcEnt = craftLivEnt.cast(ent);
|
||||||
try {
|
try {
|
||||||
|
boolean target = false;
|
||||||
Object newGoal = null;
|
Object newGoal = null;
|
||||||
Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
|
Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
|
||||||
Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
||||||
|
Object targets = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
||||||
if (mark == 0) {
|
if (mark == 0) {
|
||||||
float radius = avoidRadius.getSingle(e).floatValue();
|
float radius = avoidRadius.getSingle(e).floatValue();
|
||||||
double spd1 = avoidSpeed1.getSingle(e).doubleValue();
|
double spd1 = avoidSpeed1.getSingle(e).doubleValue();
|
||||||
double spd2 = avoidSpeed2.getSingle(e).doubleValue();
|
double spd2 = avoidSpeed2.getSingle(e).doubleValue();
|
||||||
EntityData<?> entityData;
|
EntityData<?> entityData;
|
||||||
String exprInput = entityToAvoid.toString(e, false);
|
String exprInput = typeToAvoid.toString(e, false);
|
||||||
if (exprInput.startsWith("the ")) {
|
if (exprInput.startsWith("the ")) {
|
||||||
exprInput = exprInput.substring(4);
|
exprInput = exprInput.substring(4);
|
||||||
}
|
}
|
||||||
@ -161,25 +162,115 @@ public class EffSetPathGoals extends Effect {
|
|||||||
if (nmsClass == null)
|
if (nmsClass == null)
|
||||||
return;
|
return;
|
||||||
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd1, spd2);
|
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd1, spd2);
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
|
||||||
} else if (mark == 1) {
|
} else if (mark == 1) {
|
||||||
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
|
||||||
} else if (mark == 2) {
|
} else if (mark == 2) {
|
||||||
double spd = breedSpeed.getSingle(e).doubleValue();
|
double spd = breedSpeed.getSingle(e).doubleValue();
|
||||||
if (!(nmsEnt.getClass().isAssignableFrom(entAnimal)))
|
if (!(nmsEnt.getClass().isAssignableFrom(entAnimal)))
|
||||||
return;
|
return;
|
||||||
newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
|
||||||
} else if (mark == 3) {
|
} else if (mark == 3) {
|
||||||
newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
|
||||||
} else if (mark == 4) {
|
} else if (mark == 4) {
|
||||||
double spd = fleeSunSpeed.getSingle(e).doubleValue();
|
double spd = fleeSunSpeed.getSingle(e).doubleValue();
|
||||||
newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
} else if (mark == 5) {
|
||||||
|
newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
|
} else if (mark == 6) {
|
||||||
|
double spd = followOwnerSpeed.getSingle(e).doubleValue();
|
||||||
|
if (!(nmsEnt.getClass().isAssignableFrom(entTameable)))
|
||||||
|
return;
|
||||||
|
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, 20.0F, 5.0F);
|
||||||
|
} else if (mark == 7) {
|
||||||
|
double spd = followAdultsSpeed.getSingle(e).doubleValue();
|
||||||
|
if (!(nmsEnt.getClass().isAssignableFrom(entAnimal)))
|
||||||
|
return;
|
||||||
|
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
||||||
|
} else if (mark == 8) {
|
||||||
|
target = true;
|
||||||
|
EntityData<?> entityData;
|
||||||
|
String exprInput = typesToFightBack.toString(e, false);
|
||||||
|
if (exprInput.startsWith("the ")) {
|
||||||
|
exprInput = exprInput.substring(4);
|
||||||
|
}
|
||||||
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||||
|
String className = entityData.getType().getSimpleName();
|
||||||
|
if (className.equals("HumanEntity"))
|
||||||
|
className = "Human";
|
||||||
|
className = "Entity" + className;
|
||||||
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||||
|
if (nmsClass == null)
|
||||||
|
return;
|
||||||
|
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, false, nmsClass);
|
||||||
|
} else if (mark == 9) {
|
||||||
|
double spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
|
||||||
|
if (nmsEnt.getClass() != entOcelot)
|
||||||
|
return;
|
||||||
|
newGoal = goalJumpOnBlock.getConstructor(entOcelot, double.class).newInstance(nmsEnt, spd);
|
||||||
|
} else if (mark == 10) {
|
||||||
|
float height = leapHeight.getSingle(e).floatValue();
|
||||||
|
newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
|
||||||
|
} else if (mark == 11) {
|
||||||
|
EntityData<?> entityData;
|
||||||
|
String exprInput = lookType.toString(e, false);
|
||||||
|
if (exprInput.startsWith("the ")) {
|
||||||
|
exprInput = exprInput.substring(4);
|
||||||
|
}
|
||||||
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||||
|
String className = entityData.getType().getSimpleName();
|
||||||
|
if (className.equals("HumanEntity"))
|
||||||
|
className = "Human";
|
||||||
|
className = "Entity" + className;
|
||||||
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||||
|
if (nmsClass == null)
|
||||||
|
return;
|
||||||
|
float radius = lookRadius.getSingle(e).floatValue();
|
||||||
|
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);
|
||||||
|
String className = entityData.getType().getSimpleName();
|
||||||
|
if (className.equals("HumanEntity"))
|
||||||
|
className = "Human";
|
||||||
|
className = "Entity" + className;
|
||||||
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||||
|
if (nmsClass == null)
|
||||||
|
return;
|
||||||
|
double spd = meleeSpeed.getSingle(e).doubleValue();
|
||||||
|
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class).newInstance(nmsEnt, nmsClass, spd);
|
||||||
|
} else if (mark == 13) {
|
||||||
|
double spd = moveTargetSpeed.getSingle(e).doubleValue();
|
||||||
|
float radius = moveTargetRadius.getSingle(e).floatValue();
|
||||||
|
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
|
||||||
|
} else if (mark == 14) {
|
||||||
|
target = true;
|
||||||
|
EntityData<?> entityData;
|
||||||
|
String exprInput = nearTarget.toString(e, false);
|
||||||
|
if (exprInput.startsWith("the ")) {
|
||||||
|
exprInput = exprInput.substring(4);
|
||||||
|
}
|
||||||
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||||
|
String className = entityData.getType().getSimpleName();
|
||||||
|
if (className.equals("HumanEntity"))
|
||||||
|
className = "Human";
|
||||||
|
className = "Entity" + className;
|
||||||
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||||
|
if (nmsClass == null)
|
||||||
|
return;
|
||||||
|
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, false);
|
||||||
|
} else if (mark == 15) {
|
||||||
|
newGoal = goalOcelotAttack.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
|
} else if (mark == 16) {
|
||||||
|
newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt);
|
||||||
|
}
|
||||||
|
if (target) {
|
||||||
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.broadcastMessage("Not an Avoid, BreakDoor, Breed or FleeSun goal");
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user