diff --git a/.gitignore b/.gitignore
index d704bed..d60803b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
-/out
-/bin
-/target
+out
+bin
+target
/META-INF
/.settings
/.idea
diff --git a/.idea/artifacts/SkStuff_jar.xml b/.idea/artifacts/SkStuff_jar.xml
index b2f7fed..7298fb6 100644
--- a/.idea/artifacts/SkStuff_jar.xml
+++ b/.idea/artifacts/SkStuff_jar.xml
@@ -3,7 +3,6 @@
$PROJECT_DIR$/out/artifacts/SkStuff_jar
-
diff --git a/.idea/discord.xml b/.idea/discord.xml
index 59b11d1..a04e4e5 100644
--- a/.idea/discord.xml
+++ b/.idea/discord.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 181c53e..1c2a053 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
@@ -23,38 +47,26 @@
-
-
-
+
+
-
+
-
-
-
+
@@ -69,18 +81,18 @@
-
+
-
-
+
+
-
-
+
+
-
+
diff --git a/SkStuff.iml b/SkStuff.iml
index d9740d5..63e3572 100644
--- a/SkStuff.iml
+++ b/SkStuff.iml
@@ -28,33 +28,11 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -70,11 +48,11 @@
-
+
-
+
@@ -92,44 +70,33 @@
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -147,11 +114,33 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bin/me/TheBukor/SkStuff/SkStuff.class b/bin/me/TheBukor/SkStuff/SkStuff.class
index 518ab07..7f9bb6a 100644
Binary files a/bin/me/TheBukor/SkStuff/SkStuff.class and b/bin/me/TheBukor/SkStuff/SkStuff.class differ
diff --git a/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class b/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class
index 3732af1..807391d 100644
Binary files a/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class and b/bin/me/TheBukor/SkStuff/effects/EffClearPathGoals.class differ
diff --git a/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class b/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class
index 9458e1a..cf3be69 100644
Binary files a/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class and b/bin/me/TheBukor/SkStuff/effects/EffMakeJump.class differ
diff --git a/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class b/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class
index b6333f2..84f78a9 100644
Binary files a/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class and b/bin/me/TheBukor/SkStuff/effects/EffRemovePathGoal.class differ
diff --git a/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class b/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class
index f840860..c6dc35f 100644
Binary files a/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class and b/bin/me/TheBukor/SkStuff/effects/EffSetPathGoal.class differ
diff --git a/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class b/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class
index 0597016..ac14df1 100644
Binary files a/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class and b/bin/me/TheBukor/SkStuff/effects/EffShowEntityEffect.class differ
diff --git a/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class b/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class
index 49c7a37..10c34a1 100644
Binary files a/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class and b/bin/me/TheBukor/SkStuff/expressions/ExprFireProof.class differ
diff --git a/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class b/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class
index da7a114..2a807b1 100644
Binary files a/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class and b/bin/me/TheBukor/SkStuff/expressions/ExprNoClip.class differ
diff --git a/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class b/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class
index 708ca72..4ebc38a 100644
Binary files a/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class and b/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.class differ
diff --git a/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class b/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class
index dfb0de7..6893287 100644
Binary files a/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class and b/bin/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_14_R1.class differ
diff --git a/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class b/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class
index 4d9473c..a3485c5 100644
Binary files a/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class and b/bin/me/TheBukor/SkStuff/util/NMS_v1_13_R2.class differ
diff --git a/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class b/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class
index bdc296c..b76f5d3 100644
Binary files a/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class and b/bin/me/TheBukor/SkStuff/util/NMS_v1_14_R1.class differ
diff --git a/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class b/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class
index 0e3ad05..4f614c6 100644
Binary files a/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class and b/bin/me/TheBukor/SkStuff/util/NMS_v1_15_R1.class differ
diff --git a/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class b/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class
index 630a07a..38ce87a 100644
Binary files a/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class and b/bin/me/TheBukor/SkStuff/util/ReflectionUtils.class differ
diff --git a/plugin.yml b/plugin.yml
index f71e8ec..95f8c3a 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,6 +1,6 @@
-name: SkPathfinderGoals
+name: SkStuff
authors: [TheBukor, Govindas]
description: A Skript addon which adds extra functionalities such as pathfinder goals.
-version: "2.0"
+version: "2.2"
main: me.TheBukor.SkStuff.SkStuff
-softdepend: [Skript]
\ No newline at end of file
+depend: [Skript]
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/SkStuff.java b/src/me/TheBukor/SkStuff/SkStuff.java
index 0624d7d..48ccca7 100644
--- a/src/me/TheBukor/SkStuff/SkStuff.java
+++ b/src/me/TheBukor/SkStuff/SkStuff.java
@@ -19,11 +19,6 @@ import javax.annotation.Nullable;
import java.io.IOException;
public class SkStuff extends JavaPlugin {
- private int condAmount = 0;
- private int effAmount = 0;
- private int evtAmount = 0;
- private int exprAmount = 0;
- private int typeAmount = 0;
private static NMSInterface nmsMethods;
@@ -31,7 +26,7 @@ public class SkStuff extends JavaPlugin {
public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) {
Skript.registerAddon(this);
- getLogger().info("SkPathfinderGoals " + this.getDescription().getVersion() + " has been successfully enabled!");
+ getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
getLogger().info("Registering general non version specific stuff...");
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|5¦squid rotate|6¦totem resurrect|7¦rabbit jump) (at|on) %entity%");
if (setupNMSVersion()) {
@@ -85,11 +80,15 @@ public class SkStuff extends JavaPlugin {
break;
case "v1_14_R1.":
nmsMethods = new NMS_v1_14_R1();
- getLogger().info("It looks like you're running 1.14.2!");
+ getLogger().info("It looks like you're running 1.14.4!");
break;
case "v1_15_R1.":
nmsMethods = new NMS_v1_15_R1();
- getLogger().info("It looks like you're running 1.15.1!");
+ getLogger().info("It looks like you're running 1.15.2!");
+ break;
+ case "v1_16_R2.":
+ nmsMethods = new NMS_v1_16_R2();
+ getLogger().info("It looks like you're running 1.16.3!");
break;
default:
getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
@@ -103,6 +102,6 @@ public class SkStuff extends JavaPlugin {
}
public void onDisable() {
- getLogger().info("SkPathfinderGoals " + this.getDescription().getVersion() + " has been successfully disabled.");
+ getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled.");
}
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
index b496e2e..b43b3ff 100644
--- a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
+++ b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
@@ -7,6 +7,8 @@ import java.util.List;
import javax.annotation.Nullable;
+import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_15_R1;
+import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_16_R2;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
@@ -265,7 +267,7 @@ public final class EffSetPathGoal extends Effect {
newGoals.add(goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd));
} else if (mark == 8) {
target = true;
- boolean callHelp = (callForHelp == null ? false : callForHelp.getSingle(e));
+ boolean callHelp = (callForHelp != null && callForHelp.getSingle(e));
EntityData>[] types = typesToFightBack.getAll(e);
List> typesClasses = new ArrayList>();
for (EntityData> entData : types) {
@@ -327,7 +329,7 @@ public final class EffSetPathGoal extends Effect {
}
} else {
double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue());
- boolean memorize = (meleeMemorize == null ? false : meleeMemorize.getSingle(e));
+ boolean memorize = (meleeMemorize != null && meleeMemorize.getSingle(e));
Class> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
newGoals.add(goalMeleeAttack.getConstructor(entCreature, double.class, boolean.class).newInstance(nmsEnt, spd, memorize));
}
@@ -354,7 +356,7 @@ public final class EffSetPathGoal extends Effect {
newGoals.add(ReflectionUtils.getConstructor(goalSpiderNearTarget, nmsEnt.getClass(), Class.class).newInstance(nmsEnt, nmsClass));
}
} else {
- boolean checkView = (checkSight == null ? true : checkSight.getSingle(e));
+ boolean checkView = (checkSight == null || checkSight.getSingle(e));
Class> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
for (EntityData> entData : types) {
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
@@ -539,16 +541,21 @@ public final class EffSetPathGoal extends Effect {
}
Class> nmsClass = ReflectionUtils.getNMSClass("Entity" + className);
switch (version) {
- case "v1.12_R1.":
- newGoals.add(new PathfinderGoalFollow_v1_12_R1((net.minecraft.server.v1_12_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
- break;
+ //case "v1.12_R1.":
+ // newGoals.add(new PathfinderGoalFollow_v1_12_R1((net.minecraft.server.v1_12_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
+ // break;
case "v1.13_R2.":
newGoals.add(new PathfinderGoalFollow_v1_13_R2((net.minecraft.server.v1_13_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break;
case "v1.14_R1.":
newGoals.add(new PathfinderGoalFollow_v1_14_R1((net.minecraft.server.v1_14_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
break;
- }
+ case "v1.15_R1.":
+ newGoals.add(new PathfinderGoalFollow_v1_15_R1((net.minecraft.server.v1_15_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
+ break;
+ case "v1.16_R2.":
+ newGoals.add(new PathfinderGoalFollow_v1_16_R2((net.minecraft.server.v1_16_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
+ break;
}
}
} else if (mark == 42) {
diff --git a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java
index 13b67da..b0bb21f 100644
--- a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java
+++ b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_13_R2.java
@@ -1,10 +1,5 @@
package me.TheBukor.SkStuff.pathfinders;
-
-import me.TheBukor.SkStuff.util.ReflectionUtils;
import net.minecraft.server.v1_13_R2.*;
-
-import java.lang.reflect.Field;
-import java.util.LinkedHashSet;
import java.util.List;
public class PathfinderGoalFollow_v1_13_R2 extends PathfinderGoal {
diff --git a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R1.java b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R2.java
similarity index 86%
rename from src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R1.java
rename to src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R2.java
index 2a0a330..3a7fa45 100644
--- a/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R1.java
+++ b/src/me/TheBukor/SkStuff/pathfinders/PathfinderGoalFollow_v1_16_R2.java
@@ -1,13 +1,13 @@
package me.TheBukor.SkStuff.pathfinders;
-import net.minecraft.server.v1_16_R1.Entity;
-import net.minecraft.server.v1_16_R1.EntityCreature;
-import net.minecraft.server.v1_16_R1.EntityLiving;
-import net.minecraft.server.v1_16_R1.PathfinderGoal;
+import net.minecraft.server.v1_16_R2.Entity;
+import net.minecraft.server.v1_16_R2.EntityCreature;
+import net.minecraft.server.v1_16_R2.EntityLiving;
+import net.minecraft.server.v1_16_R2.PathfinderGoal;
import java.util.List;
-public class PathfinderGoalFollow_v1_16_R1 extends PathfinderGoal {
+public class PathfinderGoalFollow_v1_16_R2 extends PathfinderGoal {
private EntityCreature follower;
private EntityLiving followed;
private Class> followedClass;
@@ -16,7 +16,7 @@ public class PathfinderGoalFollow_v1_16_R1 extends PathfinderGoal {
private boolean isByName;
private String customName;
- public PathfinderGoalFollow_v1_16_R1(EntityCreature follower, Class> followedClass, float radius, double speed, boolean isByName, String customName) {
+ public PathfinderGoalFollow_v1_16_R2(EntityCreature follower, Class> followedClass, float radius, double speed, boolean isByName, String customName) {
this.follower = follower;
this.followedClass = followedClass;
this.radius = radius;
diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java
index 3a32207..0ef09a5 100644
--- a/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java
+++ b/src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java
@@ -2,13 +2,14 @@ package me.TheBukor.SkStuff.util;
import net.minecraft.server.v1_14_R1.EntityInsentient;
+import net.minecraft.server.v1_14_R1.BehaviorController;
import net.minecraft.server.v1_14_R1.PathfinderGoal;
import net.minecraft.server.v1_14_R1.PathfinderGoalSelector;
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
+import java.lang.reflect.Field;
+import java.util.*;
public class NMS_v1_14_R1 implements NMSInterface {
@@ -16,13 +17,48 @@ public class NMS_v1_14_R1 implements NMSInterface {
@Override
public void clearPathfinderGoals(Entity entity) {
- EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
+ EntityInsentient nmsEntity = (EntityInsentient) ((CraftEntity) entity).getHandle();
+ PathfinderGoalSelector goalSelector = nmsEntity.goalSelector;
+ PathfinderGoalSelector targetSelector = nmsEntity.targetSelector;
+ try {
+ BehaviorController> controller = nmsEntity.getBehaviorController();
+
+ Field memoriesField = BehaviorController.class.getDeclaredField("memories");
+ memoriesField.setAccessible(true);
+ memoriesField.set(controller, new HashMap<>());
+
+ Field sensorsField = BehaviorController.class.getDeclaredField("sensors");
+ sensorsField.setAccessible(true);
+ sensorsField.set(controller, new LinkedHashMap<>());
+
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
}
+
+ try {
+ Field dField;
+ dField = PathfinderGoalSelector.class.getDeclaredField("d");
+ dField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ dField.set(targetSelector, new LinkedHashSet<>());
+
+ Field cField;
+ cField = PathfinderGoalSelector.class.getDeclaredField("c");
+ cField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ cField.set(targetSelector, new EnumMap<>(net.minecraft.server.v1_16_R2.PathfinderGoal.Type.class));
+
+ Field fField;
+ fField = PathfinderGoalSelector.class.getDeclaredField("f");
+ fField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ fField.set(targetSelector, EnumSet.noneOf(PathfinderGoal.Type.class));
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+}
+
@Override
public void removePathfinderGoal(Object entity, Class> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {
diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java
index 50f04b2..cb1946d 100644
--- a/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java
+++ b/src/me/TheBukor/SkStuff/util/NMS_v1_15_R1.java
@@ -1,14 +1,15 @@
package me.TheBukor.SkStuff.util;
+import net.minecraft.server.v1_15_R1.BehaviorController;
import net.minecraft.server.v1_15_R1.EntityInsentient;
import net.minecraft.server.v1_15_R1.PathfinderGoal;
import net.minecraft.server.v1_15_R1.PathfinderGoalSelector;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
+import java.lang.reflect.Field;
+import java.util.*;
public class NMS_v1_15_R1 implements NMSInterface {
@@ -16,11 +17,46 @@ public class NMS_v1_15_R1 implements NMSInterface {
@Override
public void clearPathfinderGoals(Entity entity) {
- EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
+ EntityInsentient nmsEntity = (EntityInsentient) ((CraftEntity) entity).getHandle();
+ PathfinderGoalSelector goalSelector = nmsEntity.goalSelector;
+ PathfinderGoalSelector targetSelector = nmsEntity.targetSelector;
+ try {
+ BehaviorController> controller = nmsEntity.getBehaviorController();
+
+ Field memoriesField = BehaviorController.class.getDeclaredField("memories");
+ memoriesField.setAccessible(true);
+ memoriesField.set(controller, new HashMap<>());
+
+ Field sensorsField = BehaviorController.class.getDeclaredField("sensors");
+ sensorsField.setAccessible(true);
+ sensorsField.set(controller, new LinkedHashMap<>());
+
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+
+ try {
+ Field dField;
+ dField = PathfinderGoalSelector.class.getDeclaredField("d");
+ dField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ dField.set(targetSelector, new LinkedHashSet<>());
+
+ Field cField;
+ cField = PathfinderGoalSelector.class.getDeclaredField("c");
+ cField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ cField.set(targetSelector, new EnumMap<>(PathfinderGoal.Type.class));
+
+ Field fField;
+ fField = PathfinderGoalSelector.class.getDeclaredField("f");
+ fField.setAccessible(true);
+ dField.set(goalSelector, new LinkedHashSet<>());
+ fField.set(targetSelector, EnumSet.noneOf(PathfinderGoal.Type.class));
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
}
@Override
diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_16_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_16_R1.java
deleted file mode 100644
index c461475..0000000
--- a/src/me/TheBukor/SkStuff/util/NMS_v1_16_R1.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package me.TheBukor.SkStuff.util;
-
-
-import net.minecraft.server.v1_16_R1.EntityInsentient;
-import net.minecraft.server.v1_16_R1.PathfinderGoal;
-import net.minecraft.server.v1_16_R1.PathfinderGoalSelector;
-import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
-import org.bukkit.entity.Entity;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-
-public class NMS_v1_16_R1 implements NMSInterface {
-
-
-
- @Override
- public void clearPathfinderGoals(Entity entity) {
- EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
- ((LinkedHashSet>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
- }
-
- @Override
- public void removePathfinderGoal(Object entity, Class> goalClass, boolean isTargetSelector) {
- if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).setGoalTarget(null);
- if (isTargetSelector) {
- Iterator> goals = ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
- while (goals.hasNext()) {
- Object goal = goals.next();
- if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
- goals.remove();
- }
- }
- } else {
- Iterator> goals = ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
- while (goals.hasNext()) {
- Object goal = goals.next();
- if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
- goals.remove();
- }
- }
- }
- }
- }
-
- @Override
- public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector) {
- if (entity instanceof EntityInsentient && goal instanceof PathfinderGoal) {
- if (isTargetSelector)
- ((EntityInsentient) entity).targetSelector.a(priority, (PathfinderGoal) goal);
- else
- ((EntityInsentient) entity).goalSelector.a(priority, (PathfinderGoal) goal);
- }
- }
-
-
- @Override
- public boolean getNoClip(Entity entity) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- return nmsEntity.noclip;
- }
-
- @Override
- public void setNoClip(Entity entity, boolean noclip) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- nmsEntity.noclip = noclip;
- }
-
- @Override
- public boolean getFireProof(Entity entity) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- return nmsEntity.isFireProof();
- }
-
- @Override
- public void setFireProof(Entity entity, boolean fireProof) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
- }
- public float getEntityStepLength(Entity entity) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- return nmsEntity.G;
- }
-
- @Override
- public void setEntityStepLength(Entity entity, float length) {
- net.minecraft.server.v1_16_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- nmsEntity.G = length;
- }
-}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_16_R2.java b/src/me/TheBukor/SkStuff/util/NMS_v1_16_R2.java
new file mode 100644
index 0000000..1bc5368
--- /dev/null
+++ b/src/me/TheBukor/SkStuff/util/NMS_v1_16_R2.java
@@ -0,0 +1,79 @@
+package me.TheBukor.SkStuff.util;
+
+
+import net.minecraft.server.v1_16_R2.EntityInsentient;
+import net.minecraft.server.v1_16_R2.PathfinderGoal;
+import net.minecraft.server.v1_16_R2.PathfinderGoalSelector;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Mob;
+
+import java.util.LinkedHashSet;
+
+public class NMS_v1_16_R2 implements NMSInterface {
+
+ @Override
+ public void clearPathfinderGoals(Entity entity) {
+ Mob e = (Mob) entity;
+ Bukkit.getMobGoals().removeAllGoals(e);
+
+ }
+
+ @Override
+ public void removePathfinderGoal(Object entity, Class> goalClass, boolean isTargetSelector) {
+ if (entity instanceof EntityInsentient) {
+ ((EntityInsentient) entity).setGoalTarget(null);
+ if (isTargetSelector) {
+ ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).removeIf(goal -> ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass);
+ } else {
+ ((LinkedHashSet>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).removeIf(goal -> ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass);
+ }
+ }
+ }
+
+ @Override
+ public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector) {
+ if (entity instanceof EntityInsentient && goal instanceof PathfinderGoal) {
+ if (isTargetSelector)
+ ((EntityInsentient) entity).targetSelector.a(priority, (PathfinderGoal) goal);
+ else
+ ((EntityInsentient) entity).goalSelector.a(priority, (PathfinderGoal) goal);
+ }
+ }
+
+
+ @Override
+ public boolean getNoClip(Entity entity) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ return nmsEntity.noclip;
+ }
+
+ @Override
+ public void setNoClip(Entity entity, boolean noclip) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ nmsEntity.noclip = noclip;
+ }
+
+ @Override
+ public boolean getFireProof(Entity entity) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ return nmsEntity.isFireProof();
+ }
+
+ @Override
+ public void setFireProof(Entity entity, boolean fireProof) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
+ }
+ public float getEntityStepLength(Entity entity) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ return nmsEntity.G;
+ }
+
+ @Override
+ public void setEntityStepLength(Entity entity, float length) {
+ net.minecraft.server.v1_16_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
+ nmsEntity.G = length;
+ }
+}
\ No newline at end of file