Skip to content

Commit

Permalink
Fix removeGoalLimitedStrollLand
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Oct 26, 2023
1 parent a617dee commit 320e428
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 12 deletions.
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.server.v1_16_R2.EnumMoveType;
import net.minecraft.server.v1_16_R2.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_16_R2.PathfinderGoalFloat;
import net.minecraft.server.v1_16_R2.PathfinderGoalWrapped;
import net.minecraft.server.v1_16_R2.PlayerChunkMap;
import net.minecraft.server.v1_16_R2.Vec3D;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
EntityCreature h = ((CraftCreature) mob).getHandle();
h.goalSelector.getTasks().removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (PathfinderGoalWrapped wrappedGoal : h.goalSelector.getTasks()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand) {
wrappedGoal.d();
h.goalSelector.removeGoal(wrappedGoal.getGoal());
break;
}
}
}

@Override
Expand Down
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.server.v1_16_R3.EnumMoveType;
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_16_R3.PathfinderGoalFloat;
import net.minecraft.server.v1_16_R3.PathfinderGoalWrapped;
import net.minecraft.server.v1_16_R3.PlayerChunkMap;
import net.minecraft.server.v1_16_R3.Vec3D;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
EntityCreature h = ((CraftCreature) mob).getHandle();
h.goalSelector.getTasks().removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (PathfinderGoalWrapped wrappedGoal : h.goalSelector.getTasks()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand) {
wrappedGoal.d();
h.goalSelector.removeGoal(wrappedGoal.getGoal());
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -82,7 +83,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -82,7 +83,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.entity.Visibility;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.availableGoals.removeIf(wg -> wg.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.level.ChunkPos;
Expand Down Expand Up @@ -81,7 +82,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.removeAllGoals(g -> g instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.level.ChunkPos;
Expand Down Expand Up @@ -78,7 +79,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.removeAllGoals(g -> g instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.level.ChunkPos;
Expand Down Expand Up @@ -78,7 +79,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.removeAllGoals(g -> g instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.entity.MoverType;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.WrappedGoal;
import net.minecraft.world.entity.animal.Wolf;
import net.minecraft.world.entity.animal.camel.Camel;
import net.minecraft.world.level.ChunkPos;
Expand Down Expand Up @@ -78,7 +79,13 @@ public void addGoalLimitedStrollLand(Creature mob, double velocity, Function<Vec
@Override
public void removeGoalLimitedStrollLand(Creature mob) {
PathfinderMob h = ((CraftCreature) mob).getHandle();
h.goalSelector.removeAllGoals(g -> g instanceof PathfinderGoalLimitedRandomStrollLand);
for (WrappedGoal wrappedGoal : h.goalSelector.getAvailableGoals()) {
if (wrappedGoal.getGoal() instanceof PathfinderGoalLimitedRandomStrollLand goal) {
wrappedGoal.stop();
h.goalSelector.removeGoal(goal);
break;
}
}
}

@Override
Expand Down

0 comments on commit 320e428

Please sign in to comment.