Fix classcastexception

This commit is contained in:
fullwall 2019-05-14 22:13:30 +08:00
parent c901bb0ebe
commit d691416db1
2 changed files with 12 additions and 13 deletions

View File

@ -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 org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
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.IBlockAccess; import net.minecraft.server.v1_14_R1.IWorldReader;
import net.minecraft.server.v1_14_R1.MathHelper; import net.minecraft.server.v1_14_R1.MathHelper;
import net.minecraft.server.v1_14_R1.PathPoint; import net.minecraft.server.v1_14_R1.PathPoint;
import net.minecraft.server.v1_14_R1.PathfinderAbstract; import net.minecraft.server.v1_14_R1.PathfinderAbstract;
public abstract class PlayerPathfinderAbstract extends PathfinderAbstract { public abstract class PlayerPathfinderAbstract extends PathfinderAbstract {
protected IBlockAccess a; protected IWorldReader a;
protected EntityHumanNPC b; protected EntityHumanNPC b;
protected final Int2ObjectMap c = new Int2ObjectOpenHashMap(); protected final Int2ObjectMap c = new Int2ObjectOpenHashMap();
protected int d; protected int d;
@ -31,7 +31,14 @@ public abstract class PlayerPathfinderAbstract extends PathfinderAbstract {
this.g = var0; 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.a = var0;
this.b = var1; this.b = var1;
this.c.clear(); this.c.clear();
@ -40,13 +47,6 @@ public abstract class PlayerPathfinderAbstract extends PathfinderAbstract {
this.f = MathHelper.d(var1.getWidth() + 1.0F); 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 @Override
public void b(boolean var0) { public void b(boolean var0) {
this.h = var0; this.h = var0;

View File

@ -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.TagsBlock;
import net.minecraft.server.v1_14_R1.TagsFluid; import net.minecraft.server.v1_14_R1.TagsFluid;
import net.minecraft.server.v1_14_R1.VoxelShape; import net.minecraft.server.v1_14_R1.VoxelShape;
import net.minecraft.server.v1_14_R1.World;
public class PlayerPathfinderNormal extends PlayerPathfinderAbstract { public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
protected float j; protected float j;
@ -271,7 +270,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
var15 + var13, var15 + var13,
this.b.getHeight() + a(this.a, (new BlockPosition(var7.a, var7.b, var7.c))) - 0.002D, this.b.getHeight() + a(this.a, (new BlockPosition(var7.a, var7.b, var7.c))) - 0.002D,
var17 + var13); var17 + var13);
if (!((World) this.a).getCubes(this.b, var19)) { if (!(this.a).getCubes(this.b, var19)) {
var7 = null; var7 = null;
} }
} }
@ -298,7 +297,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
if (var11 == PathType.OPEN) { if (var11 == PathType.OPEN) {
AxisAlignedBB var15 = new AxisAlignedBB(var0 - var13 + 0.5D, var1 + 0.001D, var2 - var13 + 0.5D, 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); 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; return null;
} }