Prevent NPE

This commit is contained in:
tastybento 2021-10-11 17:27:24 -07:00
parent 8852b9d660
commit 907c6b3534

View File

@ -139,7 +139,7 @@ public class BlueprintClipboard {
Math.rint(e.getLocation().getY()),
Math.rint(e.getLocation().getZ())).equals(v))
.collect(Collectors.toList());
if (copyBlock(v.toLocation(world), origin, copyAir, ents)) {
if (copyBlock(v.toLocation(world), copyAir, ents)) {
count++;
}
});
@ -179,12 +179,13 @@ public class BlueprintClipboard {
return r;
}
private boolean copyBlock(Location l, @Nullable Vector origin2, boolean copyAir, Collection<LivingEntity> entities) {
private boolean copyBlock(Location l, boolean copyAir, Collection<LivingEntity> entities) {
Block block = l.getBlock();
if (!copyAir && block.getType().equals(Material.AIR) && entities.isEmpty()) {
return false;
}
// Create position
Vector origin2 = origin == null ? new Vector(0,0,0) : origin;
int x = l.getBlockX() - origin2.getBlockX();
int y = l.getBlockY() - origin2.getBlockY();
int z = l.getBlockZ() - origin2.getBlockZ();