Skip to content

Commit

Permalink
Don't store hashcode goal selector
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 6, 2020
1 parent 002b2b6 commit ed14153
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 0 additions & 3 deletions main/src/main/java/net/citizensnpcs/npc/CitizensNPC.java
Expand Up @@ -31,7 +31,6 @@
import net.citizensnpcs.api.event.SpawnReason;
import net.citizensnpcs.api.npc.AbstractNPC;
import net.citizensnpcs.api.npc.BlockBreaker;
import net.citizensnpcs.api.npc.MemoryNPCDataStore;
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
Expand All @@ -55,8 +54,6 @@
public class CitizensNPC extends AbstractNPC {
private ChunkCoord cachedCoord;
private EntityController entityController;
private final NPC nameHologram = null;
private final NPCRegistry registry = CitizensAPI.createAnonymousNPCRegistry(new MemoryNPCDataStore());
private final CitizensNavigator navigator = new CitizensNavigator(this);
private int updateCounter = 0;

Expand Down
Expand Up @@ -1433,7 +1433,7 @@ public static void clearGoals(NPC npc, PathfinderGoalSelector... goalSelectors)
try {
Collection<?> list = (Collection<?>) GOAL_SET_FIELD.invoke(selector);
if (!list.isEmpty()) {
npc.data().set("goal-selector-" + selector.hashCode(), Lists.newArrayList(list));
npc.data().set("goal-selector", Lists.newArrayList(list));
}
list.clear();
} catch (Exception e) {
Expand Down Expand Up @@ -1721,7 +1721,7 @@ public static void restoreGoals(NPC npc, PathfinderGoalSelector... goalSelectors
try {
Collection<Object> list = (Collection<Object>) GOAL_SET_FIELD.invoke(selector);
list.clear();
Collection<Object> old = npc.data().get("goal-selector-" + selector.hashCode());
Collection<Object> old = npc.data().get("goal-selector");
if (old != null) {
list.addAll(old);
}
Expand Down
Expand Up @@ -1451,7 +1451,7 @@ public static void clearGoals(NPC npc, PathfinderGoalSelector... goalSelectors)
try {
Collection<?> list = (Collection<?>) GOAL_SET_FIELD.invoke(selector);
if (!list.isEmpty()) {
npc.data().set("goal-selector-" + selector.hashCode(), Lists.newArrayList(list));
npc.data().set("goal-selector", Lists.newArrayList(list));
}
list.clear();
} catch (Exception e) {
Expand Down Expand Up @@ -1676,7 +1676,8 @@ public static void restoreGoals(NPC npc, PathfinderGoalSelector... goalSelectors
try {
Collection<Object> list = (Collection<Object>) GOAL_SET_FIELD.invoke(selector);
list.clear();
Collection<Object> old = npc.data().get("goal-selector-" + selector.hashCode());

Collection<Object> old = npc.data().get("goal-selector");
if (old != null) {
list.addAll(old);
}
Expand Down

0 comments on commit ed14153

Please sign in to comment.