From d691416db11123e701047ba39a02e66931cdbcca Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 14 May 2019 22:13:30 +0800 Subject: [PATCH] Fix classcastexception --- .../util/PlayerPathfinderAbstract.java | 20 +++++++++---------- .../v1_14_R1/util/PlayerPathfinderNormal.java | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderAbstract.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderAbstract.java index b0deb9387..ad729c83f 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderAbstract.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderAbstract.java @@ -4,13 +4,13 @@ import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap; import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC; -import net.minecraft.server.v1_14_R1.IBlockAccess; +import net.minecraft.server.v1_14_R1.IWorldReader; import net.minecraft.server.v1_14_R1.MathHelper; import net.minecraft.server.v1_14_R1.PathPoint; import net.minecraft.server.v1_14_R1.PathfinderAbstract; public abstract class PlayerPathfinderAbstract extends PathfinderAbstract { - protected IBlockAccess a; + protected IWorldReader a; protected EntityHumanNPC b; protected final Int2ObjectMap c = new Int2ObjectOpenHashMap(); protected int d; @@ -31,7 +31,14 @@ public abstract class PlayerPathfinderAbstract extends PathfinderAbstract { this.g = var0; } - public void a(IBlockAccess var0, EntityHumanNPC var1) { + @Override + protected PathPoint a(int var0, int var1, int var2) { + return (PathPoint) this.c.computeIfAbsent(PathPoint.b(var0, var1, var2), (var3) -> { + return new PathPoint(var0, var1, var2); + }); + } + + public void a(IWorldReader var0, EntityHumanNPC var1) { this.a = var0; this.b = var1; this.c.clear(); @@ -40,13 +47,6 @@ public abstract class PlayerPathfinderAbstract extends PathfinderAbstract { this.f = MathHelper.d(var1.getWidth() + 1.0F); } - @Override - protected PathPoint a(int var0, int var1, int var2) { - return (PathPoint) this.c.computeIfAbsent(PathPoint.b(var0, var1, var2), (var3) -> { - return new PathPoint(var0, var1, var2); - }); - } - @Override public void b(boolean var0) { this.h = var0; diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderNormal.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderNormal.java index 4e0f08365..5afa03167 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderNormal.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerPathfinderNormal.java @@ -32,7 +32,6 @@ import net.minecraft.server.v1_14_R1.PathType; import net.minecraft.server.v1_14_R1.TagsBlock; import net.minecraft.server.v1_14_R1.TagsFluid; import net.minecraft.server.v1_14_R1.VoxelShape; -import net.minecraft.server.v1_14_R1.World; public class PlayerPathfinderNormal extends PlayerPathfinderAbstract { protected float j; @@ -271,7 +270,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract { var15 + var13, this.b.getHeight() + a(this.a, (new BlockPosition(var7.a, var7.b, var7.c))) - 0.002D, var17 + var13); - if (!((World) this.a).getCubes(this.b, var19)) { + if (!(this.a).getCubes(this.b, var19)) { var7 = null; } } @@ -298,7 +297,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract { if (var11 == PathType.OPEN) { AxisAlignedBB var15 = new AxisAlignedBB(var0 - var13 + 0.5D, var1 + 0.001D, var2 - var13 + 0.5D, var0 + var13 + 0.5D, var1 + this.b.getHeight(), var2 + var13 + 0.5D); - if (!((World) this.a).getCubes(this.b, var15)) { + if (!(this.a).getCubes(this.b, var15)) { return null; }