fix a nullpointer

This commit is contained in:
Flemmli97 2020-09-15 12:51:46 +02:00
parent de78a4b0b6
commit 137ac03731

View File

@ -27,7 +27,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockInteractEvents { public class BlockInteractEvents {
@ -139,6 +138,8 @@ public class BlockInteractEvents {
if (entity instanceof ServerPlayerEntity) { if (entity instanceof ServerPlayerEntity) {
ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world);
Claim claim = storage.getClaimAt(landedPosition); Claim claim = storage.getClaimAt(landedPosition);
if(claim==null)
return false;
EnumPermission perm = BlockToPermissionMap.getFromBlock(landedState.getBlock()); EnumPermission perm = BlockToPermissionMap.getFromBlock(landedState.getBlock());
if (perm == EnumPermission.TRAMPLE) if (perm == EnumPermission.TRAMPLE)
return !claim.canInteract((ServerPlayerEntity) entity, perm, landedPosition, true); return !claim.canInteract((ServerPlayerEntity) entity, perm, landedPosition, true);
@ -162,12 +163,16 @@ public class BlockInteractEvents {
if (entity instanceof ServerPlayerEntity) { if (entity instanceof ServerPlayerEntity) {
ClaimStorage storage = ClaimStorage.get(serverWorld); ClaimStorage storage = ClaimStorage.get(serverWorld);
Claim claim = storage.getClaimAt(pos); Claim claim = storage.getClaimAt(pos);
if(claim==null)
return false;
return !claim.canInteract((ServerPlayerEntity) entity, EnumPermission.TRAMPLE, pos, true); return !claim.canInteract((ServerPlayerEntity) entity, EnumPermission.TRAMPLE, pos, true);
} else if (entity instanceof ProjectileEntity) { } else if (entity instanceof ProjectileEntity) {
Entity owner = ((ProjectileEntity) entity).getOwner(); Entity owner = ((ProjectileEntity) entity).getOwner();
if (owner instanceof ServerPlayerEntity) { if (owner instanceof ServerPlayerEntity) {
ClaimStorage storage = ClaimStorage.get(serverWorld); ClaimStorage storage = ClaimStorage.get(serverWorld);
Claim claim = storage.getClaimAt(pos); Claim claim = storage.getClaimAt(pos);
if(claim==null)
return false;
return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true); return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true);
} }
} else if (entity instanceof ItemEntity) { } else if (entity instanceof ItemEntity) {
@ -175,6 +180,8 @@ public class BlockInteractEvents {
if (owner instanceof ServerPlayerEntity) { if (owner instanceof ServerPlayerEntity) {
ClaimStorage storage = ClaimStorage.get(serverWorld); ClaimStorage storage = ClaimStorage.get(serverWorld);
Claim claim = storage.getClaimAt(pos); Claim claim = storage.getClaimAt(pos);
if(claim==null)
return false;
return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true); return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true);
} }
} }