Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
NPE checks
  • Loading branch information
SquidDev committed Mar 5, 2016
1 parent b59c027 commit 0dc4854
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ public boolean load(NBTTagCompound tag) {
if (tag.hasKey(ID)) {
setId(tag.getInteger(ID));
loaded = true;
} else {
removeId();
}

return loaded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public Object[] execute() throws LuaException {
boolean result = TurtleRegistry.instance.canSwing(access, player, stack, direction, hit);
if (result) return new Object[]{true};

if (hit.entityHit != null) {
if (hit != null && hit.entityHit != null) {
@SuppressWarnings("unchecked") Multimap<String, AttributeModifier> map = stack.getAttributeModifiers();
for (AttributeModifier modifier : map.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName())) {
if (modifier.getAmount() > 0) {
Expand All @@ -360,7 +360,7 @@ public Object[] execute() throws LuaException {
}
}

if (hit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
if (hit != null && hit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
Block block = access.getWorld().getBlockState(hit.getBlockPos()).getBlock();
if (block.canHarvestBlock(access.getWorld(), hit.getBlockPos(), player)) {
return new Object[]{true};
Expand Down

0 comments on commit 0dc4854

Please sign in to comment.