Hopefully the last 1.5 commit. Just needs testing.
This commit is contained in:
parent
a9467540f4
commit
042aaa6ceb
@ -100,10 +100,10 @@ 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(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)) from %livingentity%");
|
Skript.registerEffect(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)) from %livingentity%");
|
||||||
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %entitydata%,[ ]radius %number%,[ ][at] speed %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|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 [with [leap]] 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¦target 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] min[imum] [of] %-timespan% between mov(e[ment][s]|ing)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%, [at] speed %number%|32¦target [random] %entitydata% (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)) to %livingentity%");
|
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %entitydata%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %entitydata%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %entitydata%[, (radius|max[imum] distance) %-number%]|12¦melee attack %entitydata%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %entitydata%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %entitydata% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)) to %livingentity%");
|
||||||
Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
|
Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
|
||||||
Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%");
|
Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%");
|
||||||
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 %object%", "%object%'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%");
|
||||||
Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%");
|
Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%");
|
||||||
Skript.registerExpression(ExprFileNBT.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] from [file] %string%");
|
Skript.registerExpression(ExprFileNBT.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] from [file] %string%");
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.entity.Blaze;
|
import org.bukkit.entity.Blaze;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -52,6 +53,7 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
Object targetSelector = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
Object targetSelector = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
||||||
Object toRemove = null;
|
Object toRemove = null;
|
||||||
boolean target = false;
|
boolean target = false;
|
||||||
|
boolean resetGoalTarget = false;
|
||||||
if (mark == 0) {
|
if (mark == 0) {
|
||||||
if (ent instanceof Rabbit) {
|
if (ent instanceof Rabbit) {
|
||||||
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
|
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
|
||||||
@ -149,6 +151,7 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
|
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
|
||||||
toRemove = goalSquid;
|
toRemove = goalSquid;
|
||||||
} else if (mark == 23) {
|
} else if (mark == 23) {
|
||||||
|
resetGoalTarget = true;
|
||||||
if (ent instanceof Blaze) {
|
if (ent instanceof Blaze) {
|
||||||
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball", false);
|
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball", false);
|
||||||
toRemove = goalBlazeFireball;
|
toRemove = goalBlazeFireball;
|
||||||
@ -186,6 +189,7 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
|
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
|
||||||
toRemove = goalTargetNonTamed;
|
toRemove = goalTargetNonTamed;
|
||||||
} else if (mark == 33) {
|
} else if (mark == 33) {
|
||||||
|
resetGoalTarget = true;
|
||||||
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
|
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
|
||||||
toRemove = goalGuardianAttack;
|
toRemove = goalGuardianAttack;
|
||||||
} else if (mark == 34) {
|
} else if (mark == 34) {
|
||||||
@ -214,8 +218,21 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
}
|
}
|
||||||
if (toRemove == null)
|
if (toRemove == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* "Hey, why are you setting the entity's target to null?!"
|
||||||
|
*
|
||||||
|
* For some goals (Blaze/Ghast fireball and Guardian attack), if you remove the goal while the entity is attacking, it will not stop attacking imediatelly, it will keep attacking its target.
|
||||||
|
* So there's a "bug" with this behavior, as soon as the entity's target resets (null, A.K.A <none>) the server crashes. Because we messed with the entity's "attack target" goal, the game
|
||||||
|
* still thinks it needs to get the target's location for some reason, and since the target is null... It throws an unhandled NPE (it never happens in Vanilla behavior), crashing the server.
|
||||||
|
* So I'm just setting the target to null before removing the goal, so it stops attacking properly, and also prevents the said crash.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (resetGoalTarget) {
|
||||||
|
((Creature) entity.getSingle(e)).setTarget(null);
|
||||||
|
}
|
||||||
|
|
||||||
Class<?> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
Class<?> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||||
if (target) {
|
if (target) { //Target Selector
|
||||||
Iterator<?> targets = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).iterator();
|
Iterator<?> targets = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).iterator();
|
||||||
while (targets.hasNext()) {
|
while (targets.hasNext()) {
|
||||||
Object o = targets.next();
|
Object o = targets.next();
|
||||||
@ -223,7 +240,7 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
targets.remove();
|
targets.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else { //Goal Selector
|
||||||
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).iterator();
|
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).iterator();
|
||||||
while (goals.hasNext()) {
|
while (goals.hasNext()) {
|
||||||
Object o = goals.next();
|
Object o = goals.next();
|
||||||
|
@ -4,7 +4,6 @@ import java.lang.reflect.Constructor;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
import org.bukkit.entity.Blaze;
|
import org.bukkit.entity.Blaze;
|
||||||
@ -41,25 +40,32 @@ public class EffSetPathGoal extends Effect {
|
|||||||
private Expression<EntityData<?>> typeToAvoid;
|
private Expression<EntityData<?>> typeToAvoid;
|
||||||
private Expression<Number> avoidRadius;
|
private Expression<Number> avoidRadius;
|
||||||
private Expression<Number> avoidSpeed;
|
private Expression<Number> avoidSpeed;
|
||||||
|
private Expression<Number> avoidSpeedNear;
|
||||||
private Expression<Number> breedSpeed;
|
private Expression<Number> breedSpeed;
|
||||||
private Expression<Number> fleeSunSpeed;
|
private Expression<Number> fleeSunSpeed;
|
||||||
private Expression<Number> followOwnerSpeed;
|
private Expression<Number> followOwnerSpeed;
|
||||||
|
private Expression<Number> followMinDist;
|
||||||
|
private Expression<Number> followMaxDist;
|
||||||
private Expression<Number> followAdultsSpeed;
|
private Expression<Number> followAdultsSpeed;
|
||||||
private Expression<EntityData<?>> typesToFightBack;
|
private Expression<EntityData<?>> typesToFightBack;
|
||||||
|
private Expression<Boolean> callForHelp;
|
||||||
private Expression<Number> jumpOnBlockSpeed;
|
private Expression<Number> jumpOnBlockSpeed;
|
||||||
private Expression<Number> leapHeight;
|
private Expression<Number> leapHeight;
|
||||||
private Expression<EntityData<?>> lookType;
|
private Expression<EntityData<?>> lookType;
|
||||||
private Expression<Number> lookRadius;
|
private Expression<Number> lookRadius;
|
||||||
private Expression<EntityData<?>> meleeTarget;
|
private Expression<EntityData<?>> meleeTarget;
|
||||||
private Expression<Number> meleeSpeed;
|
private Expression<Number> meleeSpeed;
|
||||||
|
private Expression<Boolean> meleeMemorize;
|
||||||
private Expression<Number> moveTargetSpeed;
|
private Expression<Number> moveTargetSpeed;
|
||||||
private Expression<Number> moveTargetRadius;
|
private Expression<Number> moveTargetRadius;
|
||||||
private Expression<EntityData<?>> nearTarget;
|
private Expression<EntityData<?>> nearTarget;
|
||||||
|
private Expression<Boolean> checkSight;
|
||||||
private Expression<Number> panicSpeed;
|
private Expression<Number> panicSpeed;
|
||||||
private Expression<Number> randomWalkSpeed;
|
private Expression<Number> randomWalkSpeed;
|
||||||
private Expression<Timespan> randomWalkInterval;
|
private Expression<Timespan> randomWalkInterval;
|
||||||
private Expression<ItemStack> temptItem;
|
private Expression<ItemStack> temptItem;
|
||||||
private Expression<Number> temptSpeed;
|
private Expression<Number> temptSpeed;
|
||||||
|
private Expression<Boolean> temptScared;
|
||||||
private Expression<EntityData<?>> nonTamedTarget;
|
private Expression<EntityData<?>> nonTamedTarget;
|
||||||
private Expression<LivingEntity> entity;
|
private Expression<LivingEntity> entity;
|
||||||
|
|
||||||
@ -82,49 +88,56 @@ public class EffSetPathGoal extends Effect {
|
|||||||
typeToAvoid = (Expression<EntityData<?>>) expr[1];
|
typeToAvoid = (Expression<EntityData<?>>) expr[1];
|
||||||
avoidRadius = (Expression<Number>) expr[2];
|
avoidRadius = (Expression<Number>) expr[2];
|
||||||
avoidSpeed = (Expression<Number>) expr[3];
|
avoidSpeed = (Expression<Number>) expr[3];
|
||||||
|
avoidSpeedNear = (Expression<Number>) expr[4];
|
||||||
} else if (mark == 2) {
|
} else if (mark == 2) {
|
||||||
breedSpeed = (Expression<Number>) expr[4];
|
breedSpeed = (Expression<Number>) expr[5];
|
||||||
} else if (mark == 4) {
|
} else if (mark == 4) {
|
||||||
fleeSunSpeed = (Expression<Number>) expr[5];
|
fleeSunSpeed = (Expression<Number>) expr[6];
|
||||||
} else if (mark == 6) {
|
} else if (mark == 6) {
|
||||||
followOwnerSpeed = (Expression<Number>) expr[6];
|
followOwnerSpeed = (Expression<Number>) expr[7];
|
||||||
|
followMinDist = (Expression<Number>) expr[8];
|
||||||
|
followMaxDist = (Expression<Number>) expr[9];
|
||||||
} else if (mark == 7) {
|
} else if (mark == 7) {
|
||||||
followAdultsSpeed = (Expression<Number>) expr[7];
|
followAdultsSpeed = (Expression<Number>) expr[10];
|
||||||
} else if (mark == 8) {
|
} else if (mark == 8) {
|
||||||
typesToFightBack = (Expression<EntityData<?>>) expr[8];
|
typesToFightBack = (Expression<EntityData<?>>) expr[11];
|
||||||
|
callForHelp = (Expression<Boolean>) expr[12];
|
||||||
} else if (mark == 9) {
|
} else if (mark == 9) {
|
||||||
jumpOnBlockSpeed = (Expression<Number>) expr[9];
|
jumpOnBlockSpeed = (Expression<Number>) expr[13];
|
||||||
} else if (mark == 10) {
|
} else if (mark == 10) {
|
||||||
leapHeight = (Expression<Number>) expr[10];
|
leapHeight = (Expression<Number>) expr[14];
|
||||||
} else if (mark == 11) {
|
} else if (mark == 11) {
|
||||||
lookType = (Expression<EntityData<?>>) expr[11];
|
lookType = (Expression<EntityData<?>>) expr[15];
|
||||||
lookRadius = (Expression<Number>) expr[12];
|
lookRadius = (Expression<Number>) expr[16];
|
||||||
} else if (mark == 12) {
|
} else if (mark == 12) {
|
||||||
meleeTarget = (Expression<EntityData<?>>) expr[13];
|
meleeTarget = (Expression<EntityData<?>>) expr[17];
|
||||||
meleeSpeed = (Expression<Number>) expr[14];
|
meleeSpeed = (Expression<Number>) expr[18];
|
||||||
|
meleeMemorize = (Expression<Boolean>) expr[19];
|
||||||
} else if (mark == 13) {
|
} else if (mark == 13) {
|
||||||
moveTargetSpeed = (Expression<Number>) expr[15];
|
moveTargetSpeed = (Expression<Number>) expr[20];
|
||||||
moveTargetRadius = (Expression<Number>) expr[16];
|
moveTargetRadius = (Expression<Number>) expr[21];
|
||||||
} else if (mark == 14) {
|
} else if (mark == 14) {
|
||||||
nearTarget = (Expression<EntityData<?>>) expr[17];
|
nearTarget = (Expression<EntityData<?>>) expr[22];
|
||||||
|
checkSight = (Expression<Boolean>) expr[23];
|
||||||
} else if (mark == 17) {
|
} else if (mark == 17) {
|
||||||
panicSpeed = (Expression<Number>) expr[18];
|
panicSpeed = (Expression<Number>) expr[24];
|
||||||
} else if (mark == 19) {
|
} else if (mark == 19) {
|
||||||
randomWalkSpeed = (Expression<Number>) expr[19];
|
randomWalkSpeed = (Expression<Number>) expr[25];
|
||||||
randomWalkInterval = (Expression<Timespan>) expr[20];
|
randomWalkInterval = (Expression<Timespan>) expr[26];
|
||||||
} else if (mark == 31) {
|
} else if (mark == 31) {
|
||||||
temptItem = (Expression<ItemStack>) expr[21];
|
temptItem = (Expression<ItemStack>) expr[27];
|
||||||
temptSpeed = (Expression<Number>) expr[22];
|
temptSpeed = (Expression<Number>) expr[28];
|
||||||
|
temptScared = (Expression<Boolean>) expr[29];
|
||||||
} else if (mark == 32) {
|
} else if (mark == 32) {
|
||||||
nonTamedTarget = (Expression<EntityData<?>>) expr[23];
|
nonTamedTarget = (Expression<EntityData<?>>) expr[30];
|
||||||
}
|
}
|
||||||
entity = (Expression<LivingEntity>) expr[24];
|
entity = (Expression<LivingEntity>) expr[31];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(@Nullable Event e, boolean debug) {
|
public String toString(@Nullable Event e, boolean debug) {
|
||||||
return "add pathfinder goal to entity";
|
return "add pathfinder goal to" + entity.toString(e, debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -136,8 +149,8 @@ public class EffSetPathGoal extends Effect {
|
|||||||
} else {
|
} else {
|
||||||
priority = 4;
|
priority = 4;
|
||||||
}
|
}
|
||||||
if (priority < 1) {
|
if (priority < 0) {
|
||||||
priority = 1;
|
priority = 0;
|
||||||
} else if (priority > 9) {
|
} else if (priority > 9) {
|
||||||
priority = 9;
|
priority = 9;
|
||||||
}
|
}
|
||||||
@ -153,8 +166,15 @@ public class EffSetPathGoal extends Effect {
|
|||||||
Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
||||||
Object targets = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
Object targets = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
||||||
if (mark == 0) {
|
if (mark == 0) {
|
||||||
float radius = avoidRadius.getSingle(e).floatValue();
|
float radius = 6.0F;
|
||||||
double spd = avoidSpeed.getSingle(e).doubleValue();
|
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();
|
||||||
EntityData<?> entityData;
|
EntityData<?> entityData;
|
||||||
String exprInput = typeToAvoid.toString(e, false);
|
String exprInput = typeToAvoid.toString(e, false);
|
||||||
if (exprInput.startsWith("the ")) {
|
if (exprInput.startsWith("the ")) {
|
||||||
@ -175,17 +195,19 @@ public class EffSetPathGoal extends Effect {
|
|||||||
return;
|
return;
|
||||||
if (ent instanceof Rabbit) {
|
if (ent instanceof Rabbit) {
|
||||||
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
|
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
|
||||||
newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, spd);
|
newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
|
||||||
} else {
|
} else {
|
||||||
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
||||||
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, spd);
|
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
|
||||||
}
|
}
|
||||||
} else if (mark == 1) {
|
} else if (mark == 1) {
|
||||||
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
||||||
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
} else if (mark == 2) {
|
} else if (mark == 2) {
|
||||||
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
|
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
|
||||||
double spd = breedSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
|
if (breedSpeed != null)
|
||||||
|
spd = breedSpeed.getSingle(e).doubleValue();
|
||||||
if (!(ent instanceof Animals))
|
if (!(ent instanceof Animals))
|
||||||
return;
|
return;
|
||||||
newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
||||||
@ -194,25 +216,38 @@ public class EffSetPathGoal extends Effect {
|
|||||||
newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
} else if (mark == 4) {
|
} else if (mark == 4) {
|
||||||
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
||||||
double spd = fleeSunSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
|
if (fleeSunSpeed != null)
|
||||||
|
spd = fleeSunSpeed.getSingle(e).doubleValue();
|
||||||
newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
|
||||||
} else if (mark == 5) {
|
} else if (mark == 5) {
|
||||||
Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
||||||
newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
} else if (mark == 6) {
|
} else if (mark == 6) {
|
||||||
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
||||||
double spd = followOwnerSpeed.getSingle(e).doubleValue();
|
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();
|
||||||
if (!(ent instanceof Tameable))
|
if (!(ent instanceof Tameable))
|
||||||
return;
|
return;
|
||||||
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, 20.0F, 5.0F);
|
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, maxDist, minDist);
|
||||||
} else if (mark == 7) {
|
} else if (mark == 7) {
|
||||||
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
||||||
double spd = followAdultsSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
|
if (followAdultsSpeed != null)
|
||||||
|
spd = followAdultsSpeed.getSingle(e).doubleValue();
|
||||||
if (!(ent instanceof Animals))
|
if (!(ent instanceof Animals))
|
||||||
return;
|
return;
|
||||||
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
||||||
} else if (mark == 8) {
|
} else if (mark == 8) {
|
||||||
target = true;
|
target = true;
|
||||||
|
boolean callHelp = false;
|
||||||
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
||||||
EntityData<?> entityData;
|
EntityData<?> entityData;
|
||||||
String exprInput = typesToFightBack.toString(e, false);
|
String exprInput = typesToFightBack.toString(e, false);
|
||||||
@ -231,16 +266,22 @@ public class EffSetPathGoal extends Effect {
|
|||||||
Class<?>[] nmsClass = new Class<?>[] { ReflectionUtils.getNMSClass(className, false) };
|
Class<?>[] nmsClass = new Class<?>[] { ReflectionUtils.getNMSClass(className, false) };
|
||||||
if (nmsClass[0] == null)
|
if (nmsClass[0] == null)
|
||||||
return;
|
return;
|
||||||
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, false, nmsClass);
|
if (callForHelp != null)
|
||||||
|
callHelp = callForHelp.getSingle(e);
|
||||||
|
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, callHelp, nmsClass);
|
||||||
} else if (mark == 9) {
|
} else if (mark == 9) {
|
||||||
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
||||||
double spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
|
if (jumpOnBlockSpeed != null)
|
||||||
|
spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
|
||||||
if (!(ent instanceof Ocelot))
|
if (!(ent instanceof Ocelot))
|
||||||
return;
|
return;
|
||||||
newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
||||||
} else if (mark == 10) {
|
} else if (mark == 10) {
|
||||||
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
||||||
float height = leapHeight.getSingle(e).floatValue();
|
float height = 0.4F;
|
||||||
|
if (leapHeight != null)
|
||||||
|
height = leapHeight.getSingle(e).floatValue();
|
||||||
newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
|
newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
|
||||||
} else if (mark == 11) {
|
} else if (mark == 11) {
|
||||||
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
||||||
@ -261,7 +302,9 @@ public class EffSetPathGoal extends Effect {
|
|||||||
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||||
if (nmsClass == null)
|
if (nmsClass == null)
|
||||||
return;
|
return;
|
||||||
float radius = lookRadius.getSingle(e).floatValue();
|
float radius = 1.0F;
|
||||||
|
if (lookRadius != null)
|
||||||
|
radius = lookRadius.getSingle(e).floatValue();
|
||||||
newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, nmsClass, radius);
|
newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, nmsClass, radius);
|
||||||
} else if (mark == 12) {
|
} else if (mark == 12) {
|
||||||
EntityData<?> entityData;
|
EntityData<?> entityData;
|
||||||
@ -288,23 +331,31 @@ public class EffSetPathGoal extends Effect {
|
|||||||
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
||||||
} else {
|
} else {
|
||||||
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
||||||
double spd = meleeSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, false);
|
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);
|
||||||
}
|
}
|
||||||
} else if (mark == 13) {
|
} else if (mark == 13) {
|
||||||
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
||||||
double spd = moveTargetSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
float radius = moveTargetRadius.getSingle(e).floatValue();
|
if (moveTargetSpeed != null)
|
||||||
|
spd = moveTargetSpeed.getSingle(e).doubleValue();
|
||||||
|
float radius = 32.0F;
|
||||||
|
if (moveTargetRadius != null)
|
||||||
|
radius = moveTargetRadius.getSingle(e).floatValue();
|
||||||
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
|
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
|
||||||
} else if (mark == 14) {
|
} else if (mark == 14) {
|
||||||
target = true;
|
target = true;
|
||||||
|
boolean checkView = false;
|
||||||
EntityData<?> entityData;
|
EntityData<?> entityData;
|
||||||
EntityData<?> test = nearTarget.getSingle(e);
|
|
||||||
String exprInput = nearTarget.toString(e, false);
|
String exprInput = nearTarget.toString(e, false);
|
||||||
if (exprInput.startsWith("the ")) {
|
if (exprInput.startsWith("the ")) {
|
||||||
exprInput = exprInput.substring(4);
|
exprInput = exprInput.substring(4);
|
||||||
}
|
}
|
||||||
Bukkit.broadcastMessage("Unconverted expression to string: \u00A7a" + exprInput + "\n\u00A7rConverted expression to string: \u00A72" + test);
|
|
||||||
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||||
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
||||||
return;
|
return;
|
||||||
@ -323,8 +374,10 @@ public class EffSetPathGoal extends Effect {
|
|||||||
constr.setAccessible(true);
|
constr.setAccessible(true);
|
||||||
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
newGoal = constr.newInstance(nmsEnt, nmsClass);
|
||||||
} else {
|
} else {
|
||||||
|
if (checkSight != null)
|
||||||
|
checkView = checkSight.getSingle(e);
|
||||||
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
||||||
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, false);
|
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, checkView);
|
||||||
}
|
}
|
||||||
} else if (mark == 15) {
|
} else if (mark == 15) {
|
||||||
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
||||||
@ -333,7 +386,9 @@ public class EffSetPathGoal extends Effect {
|
|||||||
Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
||||||
newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt, false);
|
newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt, false);
|
||||||
} else if (mark == 17) {
|
} else if (mark == 17) {
|
||||||
double spd = panicSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
|
if (panicSpeed != null)
|
||||||
|
spd = panicSpeed.getSingle(e).doubleValue();
|
||||||
if (ent instanceof Rabbit) {
|
if (ent instanceof Rabbit) {
|
||||||
Class<?> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic", false);
|
Class<?> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic", false);
|
||||||
newGoal = goalRabbitPanic.getDeclaredConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
newGoal = goalRabbitPanic.getDeclaredConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
|
||||||
@ -347,8 +402,12 @@ public class EffSetPathGoal extends Effect {
|
|||||||
newGoal = goalRandomLook.getConstructor(entInsent).newInstance(nmsEnt);
|
newGoal = goalRandomLook.getConstructor(entInsent).newInstance(nmsEnt);
|
||||||
} else if (mark == 19) {
|
} else if (mark == 19) {
|
||||||
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
|
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
|
||||||
double spd = randomWalkSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
int interval = randomWalkInterval.getSingle(e).getTicks();
|
if (randomWalkSpeed != null)
|
||||||
|
spd = randomWalkSpeed.getSingle(e).doubleValue();
|
||||||
|
int interval = 120;
|
||||||
|
if (randomWalkInterval != null)
|
||||||
|
interval = randomWalkInterval.getSingle(e).getTicks();
|
||||||
newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
|
newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
|
||||||
} else if (mark == 20) {
|
} else if (mark == 20) {
|
||||||
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
||||||
@ -380,7 +439,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
newGoal = constr.newInstance(nmsEnt);
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
}
|
}
|
||||||
} else if (mark == 24) {
|
} else if (mark == 24) {
|
||||||
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlocks", false);
|
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock", false);
|
||||||
if (!(ent instanceof Silverfish))
|
if (!(ent instanceof Silverfish))
|
||||||
return;
|
return;
|
||||||
Constructor<?> constr = goalHideInBlock.getDeclaredConstructor(nmsEnt.getClass());
|
Constructor<?> constr = goalHideInBlock.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
@ -436,8 +495,13 @@ public class EffSetPathGoal extends Effect {
|
|||||||
return;
|
return;
|
||||||
Object nmsItemStack = craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(itemStack, itemStack);
|
Object nmsItemStack = craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(itemStack, itemStack);
|
||||||
Object nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
|
Object nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
|
||||||
double spd = temptSpeed.getSingle(e).doubleValue();
|
double spd = 1.0D;
|
||||||
newGoal = goalTempt.getConstructor(entCreature, double.class, nmsItemClass, boolean.class).newInstance(nmsEnt, spd, nmsItem, false);
|
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);
|
||||||
} else if (mark == 32) {
|
} else if (mark == 32) {
|
||||||
target = true;
|
target = true;
|
||||||
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
|
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
|
||||||
@ -466,52 +530,68 @@ public class EffSetPathGoal extends Effect {
|
|||||||
if (!(ent instanceof Guardian))
|
if (!(ent instanceof Guardian))
|
||||||
return;
|
return;
|
||||||
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
|
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
|
||||||
newGoal = goalGuardianAttack.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalGuardianAttack.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 34) {
|
} else if (mark == 34) {
|
||||||
if (!(ent instanceof PigZombie))
|
if (!(ent instanceof PigZombie))
|
||||||
return;
|
return;
|
||||||
target = true;
|
target = true;
|
||||||
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger", false);
|
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger", false);
|
||||||
newGoal = goalAnger.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalAnger.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 35) {
|
} else if (mark == 35) {
|
||||||
if (!(ent instanceof PigZombie))
|
if (!(ent instanceof PigZombie))
|
||||||
return;
|
return;
|
||||||
target = true;
|
target = true;
|
||||||
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther", false);
|
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther", false);
|
||||||
newGoal = goalAngerOther.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalAngerOther.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 36) {
|
} else if (mark == 36) {
|
||||||
if (!(ent instanceof Rabbit))
|
if (!(ent instanceof Rabbit))
|
||||||
return;
|
return;
|
||||||
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots", false);
|
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots", false);
|
||||||
newGoal = goalEatCarrots.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalEatCarrots.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 37) {
|
} else if (mark == 37) {
|
||||||
if (!(ent instanceof Rabbit))
|
if (!(ent instanceof Rabbit))
|
||||||
return;
|
return;
|
||||||
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack", false);
|
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack", false);
|
||||||
newGoal = goalRabbitAttack.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalRabbitAttack.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 38) {
|
} else if (mark == 38) {
|
||||||
if (!(ent instanceof Slime))
|
if (!(ent instanceof Slime))
|
||||||
return;
|
return;
|
||||||
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump", false);
|
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump", false);
|
||||||
newGoal = goalJump.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalJump.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 39) {
|
} else if (mark == 39) {
|
||||||
if (!(ent instanceof Slime))
|
if (!(ent instanceof Slime))
|
||||||
return;
|
return;
|
||||||
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection", false);
|
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection", false);
|
||||||
newGoal = goalRandomDir.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalRandomDir.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
} else if (mark == 40) {
|
} else if (mark == 40) {
|
||||||
if (!(ent instanceof Slime))
|
if (!(ent instanceof Slime))
|
||||||
return;
|
return;
|
||||||
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle", false);
|
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle", false);
|
||||||
newGoal = goalSlimeWander.getDeclaredConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
Constructor<?> constr = goalSlimeWander.getDeclaredConstructor(nmsEnt.getClass());
|
||||||
|
constr.setAccessible(true);
|
||||||
|
newGoal = constr.newInstance(nmsEnt);
|
||||||
}
|
}
|
||||||
if (newGoal == null)
|
if (newGoal == null)
|
||||||
return;
|
return;
|
||||||
Class<?> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
|
Class<?> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
|
||||||
Class<?> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
Class<?> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||||
if (target) {
|
if (target) { //Target Selector
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
|
||||||
} else {
|
} else { //Goal Selector
|
||||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package me.TheBukor.SkStuff.expressions;
|
package me.TheBukor.SkStuff.expressions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Enderman;
|
import org.bukkit.entity.Enderman;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -60,7 +63,7 @@ public class ExprEndermanBlocks extends SimpleExpression<ItemStack> {
|
|||||||
return null;
|
return null;
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
try {
|
try {
|
||||||
nmsEnt = craftEntClass.getMethod("getHandle").invoke(ent);
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -70,39 +73,89 @@ public class ExprEndermanBlocks extends SimpleExpression<ItemStack> {
|
|||||||
Object nmsBlockData;
|
Object nmsBlockData;
|
||||||
try {
|
try {
|
||||||
nmsBlockData = nmsBlockClass.getMethod("getBlockData").invoke(nmsBlock);
|
nmsBlockData = nmsBlockClass.getMethod("getBlockData").invoke(nmsBlock);
|
||||||
int dataValue = (int) nmsBlockClass.getMethod("toLegacyData", nmsIBlockData).invoke(nmsBlock, nmsBlockData);
|
int dataValue = (int) nmsBlockClass.getMethod("toLegacyData", nmsIBlockData).invoke(nmsBlock,
|
||||||
Object nmsItem = nmsItemClass.getConstructor(nmsBlockClass, int.class, int.class).newInstance(nmsBlock, 1, dataValue);
|
nmsBlockData);
|
||||||
ItemStack bukkitItem = (ItemStack) craftItemClass.getMethod("asCraftMirror", nmsItemClass).invoke(null, nmsItem);
|
Object nmsItem = nmsItemClass.getConstructor(nmsBlockClass, int.class, int.class).newInstance(nmsBlock,
|
||||||
|
1, dataValue);
|
||||||
|
ItemStack bukkitItem = (ItemStack) craftItemClass.getMethod("asCraftMirror", nmsItemClass).invoke(null,
|
||||||
|
nmsItem);
|
||||||
items.add(bukkitItem);
|
items.add(bukkitItem);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();;
|
ex.printStackTrace();
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ItemStack[]) items.toArray();
|
return Arrays.copyOf(items.toArray(), items.size(), ItemStack[].class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({ "unused", "unchecked" })
|
||||||
@Override
|
@Override
|
||||||
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
if (mode == ChangeMode.SET) {
|
Entity ent = entity.getSingle(e);
|
||||||
ItemStack[] toSet = (ItemStack[]) delta;
|
if (ent == null || !(ent instanceof Enderman))
|
||||||
// TODO Convert bukkit items to NMS items (blocks). Then clear the list and add the delta items.
|
return;
|
||||||
} else if (mode == ChangeMode.REMOVE) {
|
Object nmsEnt = null;
|
||||||
ItemStack[] toRemove = (ItemStack[]) delta;
|
try {
|
||||||
// TODO The code.
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent);
|
||||||
} else if (mode == ChangeMode.ADD) {
|
} catch (Exception ex) {
|
||||||
ItemStack[] toAdd = (ItemStack[]) delta;
|
ex.printStackTrace();
|
||||||
// TODO The code.
|
}
|
||||||
|
Set<Object> enderBlocks = (Set<Object>) ReflectionUtils.getField("c", endermanClass, nmsEnt);
|
||||||
|
if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET) {
|
||||||
|
ItemStack[] deltaItems = Arrays.copyOf(delta, delta.length, ItemStack[].class);
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
enderBlocks.clear();
|
||||||
|
}
|
||||||
|
for (ItemStack itemStack : deltaItems) {
|
||||||
|
if (itemStack.getType() == Material.AIR || itemStack == null)
|
||||||
|
continue;
|
||||||
|
Object nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
Object nmsItem = null;
|
||||||
|
try {
|
||||||
|
nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
if (mode == ChangeMode.ADD || mode == ChangeMode.SET)
|
||||||
|
enderBlocks.add(nmsItem);
|
||||||
|
else //ChangeMode.REMOVE
|
||||||
|
enderBlocks.remove(nmsItem);
|
||||||
|
}
|
||||||
} else if (mode == ChangeMode.RESET) {
|
} else if (mode == ChangeMode.RESET) {
|
||||||
// TODO The code.
|
ItemStack grass = new ItemStack(Material.GRASS);
|
||||||
|
ItemStack dirt = new ItemStack(Material.DIRT);
|
||||||
|
ItemStack sand = new ItemStack(Material.SAND);
|
||||||
|
ItemStack gravel = new ItemStack(Material.GRAVEL);
|
||||||
|
ItemStack dandelion = new ItemStack(Material.YELLOW_FLOWER);
|
||||||
|
ItemStack poppy = new ItemStack(Material.RED_ROSE);
|
||||||
|
ItemStack brownShroom = new ItemStack(Material.BROWN_MUSHROOM);
|
||||||
|
ItemStack redShroom = new ItemStack(Material.RED_MUSHROOM);
|
||||||
|
ItemStack tnt = new ItemStack(Material.TNT);
|
||||||
|
ItemStack cactus = new ItemStack(Material.CACTUS);
|
||||||
|
ItemStack clay = new ItemStack(Material.CLAY);
|
||||||
|
ItemStack pumpkin = new ItemStack(Material.PUMPKIN);
|
||||||
|
ItemStack melon = new ItemStack(Material.MELON_BLOCK);
|
||||||
|
ItemStack mycellium = new ItemStack(Material.MYCEL);
|
||||||
|
ItemStack[] defaultItems = new ItemStack[] { grass, dirt, gravel, dandelion, poppy, brownShroom, redShroom, tnt, cactus, clay, pumpkin, melon, mycellium };
|
||||||
|
enderBlocks.clear();
|
||||||
|
for (ItemStack itemStack : defaultItems) {
|
||||||
|
Object nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
Object nmsItem = null;
|
||||||
|
try {
|
||||||
|
nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
enderBlocks.add(nmsItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Class<?>[] acceptChange(ChangeMode mode) {
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
if (mode == ChangeMode.SET || mode == ChangeMode.REMOVE || mode == ChangeMode.ADD || mode == ChangeMode.RESET) {
|
if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.RESET|| mode == ChangeMode.SET) {
|
||||||
return CollectionUtils.array(ItemStack[].class);
|
return CollectionUtils.array(ItemStack[].class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.TheBukor.SkStuff.expressions;
|
package me.TheBukor.SkStuff.expressions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -50,17 +51,19 @@ public class ExprFireProof extends SimpleExpression<Boolean> {
|
|||||||
return null;
|
return null;
|
||||||
List<Boolean> fireProofStates = new ArrayList<Boolean>();
|
List<Boolean> fireProofStates = new ArrayList<Boolean>();
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
|
if (ent == null)
|
||||||
|
continue;
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
try {
|
try {
|
||||||
nmsEnt = craftEntClass.getMethod("getHandle").invoke(ent);
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
fireProofStates.add((Boolean) ReflectionUtils.getField("fireProof", nmsEnt.getClass(), nmsEnt));
|
fireProofStates.add((Boolean) ReflectionUtils.getField("fireProof", nmsEnt.getClass(), nmsEnt));
|
||||||
}
|
}
|
||||||
return (Boolean[]) fireProofStates.toArray();
|
return Arrays.copyOf(fireProofStates.toArray(), fireProofStates.size(), Boolean[].class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
Entity[] ents = entities.getAll(e);
|
Entity[] ents = entities.getAll(e);
|
||||||
@ -69,9 +72,11 @@ public class ExprFireProof extends SimpleExpression<Boolean> {
|
|||||||
if (mode == ChangeMode.SET) {
|
if (mode == ChangeMode.SET) {
|
||||||
Boolean newValue = (Boolean) delta[0];
|
Boolean newValue = (Boolean) delta[0];
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
|
if (ent == null)
|
||||||
|
continue;
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
try {
|
try {
|
||||||
nmsEnt = craftEntClass.getMethod("getHandle").invoke(ent);
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import me.TheBukor.SkStuff.util.NBTUtil;
|
|||||||
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
||||||
|
|
||||||
public class ExprNBTOf extends SimpleExpression<Object> {
|
public class ExprNBTOf extends SimpleExpression<Object> {
|
||||||
private Expression<?> target;
|
private Expression<Object> target;
|
||||||
|
|
||||||
private Class<?> nbtClass = ReflectionUtils.getNMSClass("NBTTagCompound", false);
|
private Class<?> nbtClass = ReflectionUtils.getNMSClass("NBTTagCompound", false);
|
||||||
private Class<?> nbtParserClass = ReflectionUtils.getNMSClass("MojangsonParser", false);
|
private Class<?> nbtParserClass = ReflectionUtils.getNMSClass("MojangsonParser", false);
|
||||||
@ -44,9 +44,10 @@ public class ExprNBTOf extends SimpleExpression<Object> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
target = expr[0];
|
target = (Expression<Object>) expr[0];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.TheBukor.SkStuff.expressions;
|
package me.TheBukor.SkStuff.expressions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -51,15 +52,17 @@ public class ExprNoClip extends SimpleExpression<Boolean> {
|
|||||||
return null;
|
return null;
|
||||||
List<Boolean> noClipStates = new ArrayList<Boolean>();
|
List<Boolean> noClipStates = new ArrayList<Boolean>();
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
|
if (ent == null)
|
||||||
|
continue;
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
try {
|
try {
|
||||||
nmsEnt = craftEntClass.getMethod("getHandle").invoke(ent);
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
noClipStates.add((Boolean) ReflectionUtils.getField("noclip", nmsEnt.getClass(), nmsEnt));
|
noClipStates.add((Boolean) ReflectionUtils.getField("noclip", nmsEnt.getClass(), nmsEnt));
|
||||||
}
|
}
|
||||||
return (Boolean[]) noClipStates.toArray();
|
return Arrays.copyOf(noClipStates.toArray(), noClipStates.size(), Boolean[].class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,9 +73,11 @@ public class ExprNoClip extends SimpleExpression<Boolean> {
|
|||||||
if (mode == ChangeMode.SET) {
|
if (mode == ChangeMode.SET) {
|
||||||
Boolean newValue = (Boolean) delta[0];
|
Boolean newValue = (Boolean) delta[0];
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
|
if (ent == null)
|
||||||
|
continue;
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
try {
|
try {
|
||||||
nmsEnt = craftEntClass.getMethod("getHandle").invoke(ent);
|
nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.Bukkit;
|
|||||||
public class ReflectionUtils {
|
public class ReflectionUtils {
|
||||||
|
|
||||||
public static Class<?> getNMSClass(String classString, boolean isArray) {
|
public static Class<?> getNMSClass(String classString, boolean isArray) {
|
||||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3] + ".";
|
String version = getVersion();
|
||||||
String name = "net.minecraft.server." + version + classString;
|
String name = "net.minecraft.server." + version + classString;
|
||||||
if (isArray)
|
if (isArray)
|
||||||
name = "[L" + name + ";";
|
name = "[L" + name + ";";
|
||||||
|
Loading…
Reference in New Issue
Block a user