From 137ac037318d2cdf566bf15068e575f8d96b46b8 Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Tue, 15 Sep 2020 12:51:46 +0200 Subject: [PATCH] fix a nullpointer --- .../com/flemmli97/flan/event/BlockInteractEvents.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/flemmli97/flan/event/BlockInteractEvents.java b/src/main/java/com/flemmli97/flan/event/BlockInteractEvents.java index 2e2b371..49bd3c7 100644 --- a/src/main/java/com/flemmli97/flan/event/BlockInteractEvents.java +++ b/src/main/java/com/flemmli97/flan/event/BlockInteractEvents.java @@ -27,7 +27,6 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; import net.minecraft.world.World; public class BlockInteractEvents { @@ -139,6 +138,8 @@ public class BlockInteractEvents { if (entity instanceof ServerPlayerEntity) { ClaimStorage storage = ClaimStorage.get((ServerWorld) entity.world); Claim claim = storage.getClaimAt(landedPosition); + if(claim==null) + return false; EnumPermission perm = BlockToPermissionMap.getFromBlock(landedState.getBlock()); if (perm == EnumPermission.TRAMPLE) return !claim.canInteract((ServerPlayerEntity) entity, perm, landedPosition, true); @@ -162,12 +163,16 @@ public class BlockInteractEvents { if (entity instanceof ServerPlayerEntity) { ClaimStorage storage = ClaimStorage.get(serverWorld); Claim claim = storage.getClaimAt(pos); + if(claim==null) + return false; return !claim.canInteract((ServerPlayerEntity) entity, EnumPermission.TRAMPLE, pos, true); } else if (entity instanceof ProjectileEntity) { Entity owner = ((ProjectileEntity) entity).getOwner(); if (owner instanceof ServerPlayerEntity) { ClaimStorage storage = ClaimStorage.get(serverWorld); Claim claim = storage.getClaimAt(pos); + if(claim==null) + return false; return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true); } } else if (entity instanceof ItemEntity) { @@ -175,6 +180,8 @@ public class BlockInteractEvents { if (owner instanceof ServerPlayerEntity) { ClaimStorage storage = ClaimStorage.get(serverWorld); Claim claim = storage.getClaimAt(pos); + if(claim==null) + return false; return !claim.canInteract((ServerPlayerEntity) owner, EnumPermission.TRAMPLE, pos, true); } }