From 8b411387f142b2cf848fcd1cd2fa62a5435a5695 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 9 May 2017 00:54:15 +0100 Subject: [PATCH] Fix several craches caused by incorrect NonNull annotations. Awfully sorry about this. It appears that Minecraft's annotations are occasionally wrong. IntelliJ will automatically add "not-null" checks on these annotations, resulting in crashes when they are actually null. --- .../computercraft/client/render/TurtleSmartItemModel.java | 3 ++- .../shared/computer/items/ItemCommandComputer.java | 3 ++- .../computercraft/shared/computer/items/ItemComputer.java | 3 ++- .../shared/peripheral/common/ItemAdvancedModem.java | 3 ++- .../computercraft/shared/peripheral/common/ItemCable.java | 3 ++- .../computercraft/shared/peripheral/common/ItemPeripheral.java | 3 ++- .../computercraft/shared/turtle/items/ItemTurtleBase.java | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java index 2a261d838..017bfc91e 100644 --- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java +++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java @@ -29,6 +29,7 @@ import net.minecraft.world.World; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.vecmath.Matrix4f; import java.util.ArrayList; import java.util.HashMap; @@ -103,7 +104,7 @@ public class TurtleSmartItemModel implements IBakedModel, IResourceManagerReload { @Nonnull @Override - public IBakedModel handleItemState( @Nonnull IBakedModel originalModel, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity) + public IBakedModel handleItemState( @Nonnull IBakedModel originalModel, ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { ItemTurtleBase turtle = (ItemTurtleBase) stack.getItem(); ComputerFamily family = turtle.getFamily( stack ); diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemCommandComputer.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemCommandComputer.java index 1f6ec1000..9acb74102 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemCommandComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemCommandComputer.java @@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemCommandComputer extends ItemComputer @@ -52,7 +53,7 @@ public class ItemCommandComputer extends ItemComputer } @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Command ) ); } diff --git a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java index 2d9d290bd..4c9650b3e 100644 --- a/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/items/ItemComputer.java @@ -22,6 +22,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemComputer extends ItemComputerBase @@ -72,7 +73,7 @@ public class ItemComputer extends ItemComputerBase } @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Normal ) ); list.add( ComputerItemFactory.create( -1, null, ComputerFamily.Advanced ) ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemAdvancedModem.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemAdvancedModem.java index 4ed99cc39..623bbc9ad 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemAdvancedModem.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemAdvancedModem.java @@ -14,6 +14,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemAdvancedModem extends ItemPeripheralBase @@ -49,7 +50,7 @@ public class ItemAdvancedModem extends ItemPeripheralBase } @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { list.add( PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 ) ); } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemCable.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemCable.java index 5228c8ec8..68b07f958 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemCable.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemCable.java @@ -24,6 +24,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemCable extends ItemPeripheralBase @@ -63,7 +64,7 @@ public class ItemCable extends ItemPeripheralBase } @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { list.add( PeripheralItemFactory.create( PeripheralType.WiredModem, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.Cable, null, 1 ) ); diff --git a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java index df3dbba5a..024400abb 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/common/ItemPeripheral.java @@ -14,6 +14,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; public class ItemPeripheral extends ItemPeripheralBase @@ -69,7 +70,7 @@ public class ItemPeripheral extends ItemPeripheralBase } @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { list.add( PeripheralItemFactory.create( PeripheralType.DiskDrive, null, 1 ) ); list.add( PeripheralItemFactory.create( PeripheralType.Printer, null, 1 ) ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtleBase.java b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtleBase.java index 146631f91..a8aa9d1a1 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtleBase.java +++ b/src/main/java/dan200/computercraft/shared/turtle/items/ItemTurtleBase.java @@ -28,6 +28,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; @@ -43,7 +44,7 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle public abstract ItemStack create( int id, String label, Colour colour, ITurtleUpgrade leftUpgrade, ITurtleUpgrade rightUpgrade, int fuelLevel, ResourceLocation overlay ); @Override - public void getSubItems( @Nonnull Item itemID, @Nonnull CreativeTabs tabs, @Nonnull List list ) + public void getSubItems( @Nonnull Item itemID, @Nullable CreativeTabs tabs, @Nonnull List list ) { List all = new ArrayList(); ComputerCraft.addAllUpgradedTurtles( all );