Add setting for max minecraft pathfinder fall distance

This commit is contained in:
fullwall 2020-09-05 15:13:34 +08:00
parent 109beda4c5
commit 934f94e137
9 changed files with 21 additions and 12 deletions

View File

@ -114,6 +114,7 @@ public class Settings {
MAX_SPEED("npc.limits.max-speed", 100), MAX_SPEED("npc.limits.max-speed", 100),
MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500), MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500),
MAXIMUM_ASTAR_ITERATIONS("npc.pathfinding.maximum-new-pathfinder-iterations", 10000), MAXIMUM_ASTAR_ITERATIONS("npc.pathfinding.maximum-new-pathfinder-iterations", 10000),
MC_NAVIGATION_MAX_FALL_DISTANCE("npc.pathfinding.minecraft.max-fall-distance", 3),
MESSAGE_COLOUR("general.color-scheme.message", "<a>"), MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
NEW_PATHFINDER_CHECK_BOUNDING_BOXES("npc.pathfinding.new-finder.check-bounding-boxes", false), NEW_PATHFINDER_CHECK_BOUNDING_BOXES("npc.pathfinding.new-finder.check-bounding-boxes", false),
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder.open-doors", false), NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder.open-doors", false),

View File

@ -3,6 +3,7 @@ package net.citizensnpcs.nms.v1_10_R1.util;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_10_R1.AxisAlignedBB; import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block; import net.minecraft.server.v1_10_R1.Block;
@ -246,7 +247,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
int i = 0; int i = 0;
while ((paramInt2 > 0) && (localPathType == PathType.OPEN)) { while ((paramInt2 > 0) && (localPathType == PathType.OPEN)) {
paramInt2--; paramInt2--;
if (i++ >= this.b.aY()) { if (i++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null; return null;
} }
localPathType = a(this.b, paramInt1, paramInt2, paramInt3); localPathType = a(this.b, paramInt1, paramInt2, paramInt3);

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_11_R1.AxisAlignedBB; import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Block; import net.minecraft.server.v1_11_R1.Block;
@ -253,7 +254,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
int i = 0; int i = 0;
while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) { while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) {
paramInt2--; paramInt2--;
if (i++ >= this.b.aY()) { if (i++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null; return null;
} }
localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3); localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_12_R1.AxisAlignedBB; import net.minecraft.server.v1_12_R1.AxisAlignedBB;
import net.minecraft.server.v1_12_R1.Block; import net.minecraft.server.v1_12_R1.Block;
@ -249,7 +250,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
int i = 0; int i = 0;
while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) { while ((paramInt2 > 0) && (localPathType1 == PathType.OPEN)) {
paramInt2--; paramInt2--;
if (i++ >= this.b.bg()) { if (i++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null; return null;
} }
localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3); localPathType1 = a(this.b, paramInt1, paramInt2, paramInt3);

View File

@ -7,6 +7,7 @@ import java.util.Iterator;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
@ -185,9 +186,6 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
return var11; return var11;
} }
private static final Method BLOCK_POSITION_B_C = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "f", false,
int.class, int.class, int.class);
public PathType a(IBlockAccess var1, int var2, int var3, int var4, PathType var5) { public PathType a(IBlockAccess var1, int var2, int var3, int var4, PathType var5) {
if (var5 == PathType.WALKABLE) { if (var5 == PathType.WALKABLE) {
BlockPosition.PooledBlockPosition var6 = BlockPosition.PooledBlockPosition.r(); BlockPosition.PooledBlockPosition var6 = BlockPosition.PooledBlockPosition.r();
@ -312,7 +310,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
while (var2 > 0 && var12 == PathType.OPEN) { while (var2 > 0 && var12 == PathType.OPEN) {
--var2; --var2;
if (var22++ >= this.b.bn()) { if (var22++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null; return null;
} }
@ -516,8 +514,11 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
} }
} }
private static final Method BLOCK_POSITION_B_C = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "f", false,
int.class, int.class, int.class);
private static final Method GET_COLLISION_SHAPE = NMS.getMethod(IBlockData.class, "h", false, IBlockAccess.class, private static final Method GET_COLLISION_SHAPE = NMS.getMethod(IBlockData.class, "h", false, IBlockAccess.class,
BlockPosition.class); BlockPosition.class);
private static final Method IS_EMPTY = NMS.getMethod(VoxelShape.class, "b", false);
private static final Method GET_FLUID = NMS.getMethod(IBlockAccess.class, "b", false, BlockPosition.class); private static final Method GET_FLUID = NMS.getMethod(IBlockAccess.class, "b", false, BlockPosition.class);
private static final Method IS_EMPTY = NMS.getMethod(VoxelShape.class, "b", false);
} }

View File

@ -6,6 +6,7 @@ import java.util.Set;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_14_R1.AxisAlignedBB; import net.minecraft.server.v1_14_R1.AxisAlignedBB;
import net.minecraft.server.v1_14_R1.Block; import net.minecraft.server.v1_14_R1.Block;
@ -326,7 +327,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
} }
var18 = this.a(var0, var1, var2); var18 = this.a(var0, var1, var2);
if (var16++ >= this.b.bv()) { if (var16++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
var18.l = PathType.BLOCKED; var18.l = PathType.BLOCKED;
var18.k = -1.0F; var18.k = -1.0F;
return var18; return var18;

View File

@ -6,6 +6,7 @@ import java.util.Set;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC;
import net.minecraft.server.v1_15_R1.AxisAlignedBB; import net.minecraft.server.v1_15_R1.AxisAlignedBB;
import net.minecraft.server.v1_15_R1.Block; import net.minecraft.server.v1_15_R1.Block;
@ -266,7 +267,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
} }
var18 = this.a(var0, var1, var2); var18 = this.a(var0, var1, var2);
if (var16++ >= this.b.bD()) { if (var16++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
var18.l = PathType.BLOCKED; var18.l = PathType.BLOCKED;
var18.k = -1.0F; var18.k = -1.0F;
return var18; return var18;

View File

@ -7,6 +7,7 @@ import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.longs.Long2ObjectOpenHa
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2BooleanMap; import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2BooleanMap;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.nms.v1_16_R2.entity.EntityHumanNPC; import net.citizensnpcs.nms.v1_16_R2.entity.EntityHumanNPC;
import net.minecraft.server.v1_16_R2.AxisAlignedBB; import net.minecraft.server.v1_16_R2.AxisAlignedBB;
import net.minecraft.server.v1_16_R2.Block; import net.minecraft.server.v1_16_R2.Block;
@ -219,7 +220,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
var18.k = -1.0F; var18.k = -1.0F;
return var18; return var18;
} }
if (var16++ >= this.b.bO()) { if (var16++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
PathPoint var18 = a(var0, var1, var2); PathPoint var18 = a(var0, var1, var2);
var18.l = PathType.BLOCKED; var18.l = PathType.BLOCKED;
var18.k = -1.0F; var18.k = -1.0F;

View File

@ -1,5 +1,6 @@
package net.citizensnpcs.nms.v1_8_R3.util; package net.citizensnpcs.nms.v1_8_R3.util;
import net.citizensnpcs.Settings.Setting;
import net.minecraft.server.v1_8_R3.Block; import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockCobbleWall; import net.minecraft.server.v1_8_R3.BlockCobbleWall;
import net.minecraft.server.v1_8_R3.BlockDoor; import net.minecraft.server.v1_8_R3.BlockDoor;
@ -84,7 +85,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
return null; return null;
} }
if (n == 1) { if (n == 1) {
if (m++ >= paramEntity.aE()) { if (m++ >= Setting.MC_NAVIGATION_MAX_FALL_DISTANCE.asInt()) {
return null; return null;
} }
paramInt2--; paramInt2--;