From 24779ded1c14cc1f4925efdcfd83056347eacfcb Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Thu, 5 Jan 2017 03:44:13 -0600 Subject: [PATCH] Ton of null fixes --- .../api/item/IManaProficiencyArmor.java | 2 +- .../api/lexicon/LexiconRecipeMappings.java | 2 +- .../core/handler/AstrolabePreviewHandler.java | 4 ++-- .../core/handler/BaubleRenderHandler.java | 10 +++++----- .../core/handler/BoundTileRenderer.java | 6 +++--- .../client/core/handler/ColorHandler.java | 2 +- .../client/core/handler/HUDHandler.java | 16 +++++++-------- .../handler/ItemsRemainingRenderHandler.java | 6 +++--- .../core/handler/MultiblockBlockAccess.java | 3 ++- .../client/core/handler/RenderLexicon.java | 2 +- .../TooltipAdditionDisplayHandler.java | 4 ++-- .../client/gui/bag/ContainerFlowerBag.java | 1 + .../client/gui/lexicon/GuiLexicon.java | 2 +- .../lexicon/button/GuiButtonInvisible.java | 2 +- .../botania/client/model/ModelBrewery.java | 4 ++-- .../render/entity/RenderThornChakram.java | 3 +++ .../achievement/AchievementTriggerer.java | 4 ++-- .../botania/common/block/BlockAltGrass.java | 1 + .../botania/common/block/BlockAltar.java | 4 ++-- .../common/block/BlockAnimatedTorch.java | 6 +++++- .../botania/common/block/BlockAvatar.java | 4 ++-- .../common/block/BlockEnchantedSoil.java | 1 + .../botania/common/block/BlockFakeAir.java | 2 +- .../botania/common/block/BlockGaiaHead.java | 1 + .../common/block/BlockModDoubleFlower.java | 4 +++- .../botania/common/block/BlockPlatform.java | 2 +- .../botania/common/block/BlockRoot.java | 1 + .../common/block/decor/BlockBuriedPetals.java | 1 + .../decor/quartz/BlockSpecialQuartz.java | 1 + .../decor/quartz/BlockSpecialQuartzSlab.java | 2 ++ .../block/decor/slabs/BlockModSlab.java | 2 ++ .../common/block/mana/BlockEnchanter.java | 1 + .../subtile/functional/SubTileOrechid.java | 2 +- .../functional/SubTileRannuncarpus.java | 2 +- .../generating/SubTileGourmaryllis.java | 2 +- .../subtile/generating/SubTileSpectrolus.java | 4 ++-- .../botania/common/block/tile/TileAltar.java | 14 +++++++------ .../botania/common/block/tile/TileAvatar.java | 8 +++++--- .../common/block/tile/TileBrewery.java | 4 ++-- .../common/block/tile/TileCraftCrate.java | 17 ++++++++-------- .../common/block/tile/TileEnderEye.java | 2 +- .../common/block/tile/TileHourglass.java | 11 ++++++---- .../common/block/tile/TileIncensePlate.java | 16 +++++++++------ .../common/block/tile/TileOpenCrate.java | 4 ++-- .../common/block/tile/TileRuneAltar.java | 20 +++++++++---------- .../block/tile/TileSimpleInventory.java | 11 +++++----- .../common/block/tile/TileSparkChanger.java | 15 ++++++++------ .../corporea/TileCorporeaCrystalCube.java | 5 ++--- .../tile/corporea/TileCorporeaFunnel.java | 4 ++-- .../tile/corporea/TileCorporeaIndex.java | 2 +- .../corporea/TileCorporeaInterceptor.java | 4 ++-- .../common/block/tile/mana/TilePool.java | 2 +- .../common/block/tile/mana/TilePrism.java | 11 ++++++---- .../common/block/tile/mana/TilePump.java | 5 ++--- .../common/block/tile/mana/TileSpreader.java | 13 ++++++------ .../tile/string/TileRedStringContainer.java | 5 ++--- .../common/core/helper/InventoryHelper.java | 6 +++--- .../common/core/helper/ItemNBTHelper.java | 2 +- .../crafting/recipe/AesirRingRecipe.java | 14 +++++++------ .../crafting/recipe/AncientWillRecipe.java | 12 ++++++----- .../crafting/recipe/ArmorUpgradeRecipe.java | 2 +- .../BlackHoleTalismanExtractRecipe.java | 12 ++++++----- .../crafting/recipe/CompositeLensRecipe.java | 20 ++++++++++--------- .../crafting/recipe/CosmeticAttachRecipe.java | 18 +++++++++-------- .../crafting/recipe/CosmeticRemoveRecipe.java | 12 ++++++----- .../common/crafting/recipe/HeadRecipe.java | 2 +- .../crafting/recipe/HelmRevealingRecipe.java | 14 +++++++------ .../crafting/recipe/LensDyeingRecipe.java | 14 +++++++------ .../crafting/recipe/ManaGunClipRecipe.java | 14 +++++++------ .../crafting/recipe/ManaGunLensRecipe.java | 16 ++++++++------- .../recipe/ManaGunRemoveLensRecipe.java | 10 ++++++---- .../crafting/recipe/ManaUpgradeRecipe.java | 2 +- .../crafting/recipe/PhantomInkRecipe.java | 12 ++++++----- .../recipe/SpecialFloatingFlowerRecipe.java | 14 +++++++------ .../crafting/recipe/SpellClothRecipe.java | 14 +++++++------ .../recipe/TerraPickTippingRecipe.java | 14 +++++++------ .../common/entity/EntityDoppleganger.java | 4 ++-- .../common/entity/EntityManaBurst.java | 4 ++-- .../botania/common/item/ItemAstrolabe.java | 6 +++++- .../botania/common/item/ItemBaubleBox.java | 9 +++++---- .../common/item/ItemBlackHoleTalisman.java | 8 ++++---- .../botania/common/item/ItemBottledMana.java | 5 +++-- .../botania/common/item/ItemCraftingHalo.java | 18 ++++++++--------- .../botania/common/item/ItemFlowerBag.java | 9 +++++---- .../botania/common/item/ItemKeepIvy.java | 4 ++-- .../botania/common/item/ItemLexicon.java | 6 +++--- .../botania/common/item/ItemManaGun.java | 6 +++--- .../botania/common/item/ItemSextant.java | 2 +- .../common/item/ItemTemperanceStone.java | 2 +- .../botania/common/item/ItemThornChakram.java | 2 +- .../armor/elementium/ItemElementiumArmor.java | 4 +++- .../armor/manasteel/ItemManasteelArmor.java | 9 ++++----- .../armor/manaweave/ItemManaweaveArmor.java | 4 ++-- .../armor/terrasteel/ItemTerrasteelArmor.java | 2 +- .../armor/terrasteel/ItemTerrasteelHelm.java | 2 +- .../item/equipment/bauble/ItemBauble.java | 2 +- .../equipment/bauble/ItemBloodPendant.java | 2 +- .../equipment/bauble/ItemCloudPendant.java | 2 +- .../item/equipment/bauble/ItemDivaCharm.java | 2 +- .../item/equipment/bauble/ItemDodgeRing.java | 4 ++-- .../equipment/bauble/ItemFlightTiara.java | 2 +- .../equipment/bauble/ItemGoddessCharm.java | 2 +- .../equipment/bauble/ItemGoldenLaurel.java | 6 +++--- .../item/equipment/bauble/ItemHolyCloak.java | 4 ++-- .../item/equipment/bauble/ItemIcePendant.java | 2 +- .../item/equipment/bauble/ItemItemFinder.java | 4 ++-- .../equipment/bauble/ItemLavaPendant.java | 2 +- .../item/equipment/bauble/ItemMagnetRing.java | 4 ++-- .../item/equipment/bauble/ItemMonocle.java | 4 ++-- .../bauble/ItemSuperCloudPendant.java | 2 +- .../bauble/ItemSuperLavaPendant.java | 2 +- .../item/equipment/bauble/ItemSwapRing.java | 4 ++-- .../item/equipment/bauble/ItemThirdEye.java | 2 +- .../item/equipment/bauble/ItemTravelBelt.java | 4 ++-- .../item/equipment/bauble/ItemWaterRing.java | 2 +- .../item/equipment/tool/ItemGlassPick.java | 2 +- .../equipment/tool/bow/ItemLivingwoodBow.java | 2 +- .../tool/elementium/ItemElementiumAxe.java | 2 +- .../tool/elementium/ItemElementiumPick.java | 4 ++-- .../item/material/ItemManaResource.java | 4 ++-- .../common/item/relic/ItemAesirRing.java | 4 ++-- .../common/item/relic/ItemFlugelEye.java | 1 + .../common/item/rod/ItemExchangeRod.java | 2 +- .../common/item/rod/ItemGravityRod.java | 2 +- .../common/item/rod/ItemRainbowRod.java | 2 +- .../botania/common/item/rod/ItemSmeltRod.java | 4 ++-- .../botania/common/lexicon/page/PageBrew.java | 2 +- .../common/lexicon/page/PageElvenRecipe.java | 4 ++-- .../common/lexicon/page/PageRecipe.java | 6 +++--- .../botania/common/network/PacketDodge.java | 4 ++-- .../botania/common/network/PacketJump.java | 4 ++-- .../common/world/WorldTypeSkyblock.java | 2 +- 132 files changed, 403 insertions(+), 325 deletions(-) diff --git a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java index 31890976d..b89c6ca6b 100644 --- a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java +++ b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java @@ -51,7 +51,7 @@ public interface IManaProficiencyArmor { if(e.getSlotType() != EntityEquipmentSlot.Type.ARMOR) continue; ItemStack armor = player.getItemStackFromSlot(e); - if(armor != null) { + if(!armor.isEmpty()) { Item item = armor.getItem(); if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) { proficient = true; diff --git a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java index ef9f778ee..a700bfff2 100644 --- a/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java +++ b/src/main/java/vazkii/botania/api/lexicon/LexiconRecipeMappings.java @@ -59,7 +59,7 @@ public final class LexiconRecipeMappings { } public static String stackToString(ItemStack stack, boolean forceIgnore) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return "NULL"; if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) diff --git a/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java b/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java index 894e8b8f8..adb508681 100644 --- a/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java @@ -40,10 +40,10 @@ public final class AstrolabePreviewHandler { List playerEntities = world.playerEntities; for (EntityPlayer player : playerEntities) { ItemStack currentStack = player.getHeldItemMainhand(); - if(currentStack == null || !(currentStack.getItem() instanceof ItemAstrolabe)) + if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ItemAstrolabe)) currentStack = player.getHeldItemOffhand(); - if(currentStack != null && currentStack.getItem() instanceof ItemAstrolabe) { + if(!currentStack.isEmpty() && currentStack.getItem() instanceof ItemAstrolabe) { Block block = ItemAstrolabe.getBlock(currentStack); if(block != Blocks.AIR) renderPlayerLook(player, currentStack); diff --git a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java index 79aaee9b9..74cf7f6ed 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java @@ -46,7 +46,7 @@ public final class BaubleRenderHandler implements LayerRenderer { IInventory inv = BaublesApi.getBaubles(player); dispatchRenders(inv, player, RenderType.BODY, partialTicks); - if(inv.getStackInSlot(3) != null) + if(!inv.getStackInSlot(3).isEmpty()) renderManaTablet(player); float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; @@ -60,7 +60,7 @@ public final class BaubleRenderHandler implements LayerRenderer { dispatchRenders(inv, player, RenderType.HEAD, partialTicks); ItemStack helm = player.inventory.armorItemInSlot(3); - if(helm != null && helm.getItem() instanceof ItemTerrasteelHelm) + if(!helm.isEmpty() && helm.getItem() instanceof ItemTerrasteelHelm) ItemTerrasteelHelm.renderOnPlayer(helm, player); GlStateManager.popMatrix(); @@ -69,7 +69,7 @@ public final class BaubleRenderHandler implements LayerRenderer { private void dispatchRenders(IInventory inv, EntityPlayer player, RenderType type, float partialTicks) { for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { Item item = stack.getItem(); if(item instanceof IPhantomInkable) { @@ -107,11 +107,11 @@ public final class BaubleRenderHandler implements LayerRenderer { boolean renderedOne = false; for(int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() == ModItems.manaTablet) { + if(!stack.isEmpty() && stack.getItem() == ModItems.manaTablet) { GlStateManager.pushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.LEGS).isEmpty(); GlStateManager.rotate(90, 0, 1, 0); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(0, -0.6, 0); diff --git a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java index f999ee522..8896e93e6 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java @@ -53,13 +53,13 @@ public final class BoundTileRenderer { EntityPlayer player = Minecraft.getMinecraft().player; int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - if(player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) { + if(!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) { BlockPos coords = ((ICoordBoundItem) player.getHeldItemMainhand().getItem()).getBinding(player.getHeldItemMainhand()); if(coords != null) renderBlockOutlineAt(coords, color); } - if(player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() instanceof ICoordBoundItem) { + if(!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ICoordBoundItem) { BlockPos coords = ((ICoordBoundItem) player.getHeldItemOffhand().getItem()).getBinding(player.getHeldItemOffhand()); if(coords != null) renderBlockOutlineAt(coords, color); @@ -72,7 +72,7 @@ public final class BoundTileRenderer { for(int i = 0; i < joined.getSlots(); i++) { ItemStack stackInSlot = joined.getStackInSlot(i); - if(stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { + if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); List coordsList = provider.getWireframesToDraw(player, stackInSlot); if(coordsList != null) diff --git a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java index a3b0f2068..6953721f3 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java @@ -138,7 +138,7 @@ public final class ColorHandler { items.registerItemColorHandler((s, t) -> { ItemStack lens = ItemManaGun.getLens(s); - if(lens != null && t == 0) + if(!lens.isEmpty() && t == 0) return Minecraft.getMinecraft().getItemColors().getColorFromItemstack(lens, t); if(t == 2) { diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 886c99e33..790865b9f 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -90,7 +90,7 @@ public final class HUDHandler { profiler.startSection("botania-hud"); IInventory baublesInv = BaublesApi.getBaubles(mc.player); ItemStack headpiece = baublesInv.getStackInSlot(4); - if(headpiece != null && headpiece.getItem() == ModItems.flightTiara) { + if(!headpiece.isEmpty() && headpiece.getItem() == ModItems.flightTiara) { profiler.startSection("flugelTiara"); ItemFlightTiara.renderHUD(event.getResolution(), mc.player, headpiece); profiler.endSection(); @@ -98,9 +98,9 @@ public final class HUDHandler { dodgeRing: { ItemStack ring = baublesInv.getStackInSlot(1); - if(ring == null || !(ring.getItem() instanceof ItemDodgeRing)) { + if(ring.isEmpty() || !(ring.getItem() instanceof ItemDodgeRing)) { ring = baublesInv.getStackInSlot(2); - if(ring == null || !(ring.getItem() instanceof ItemDodgeRing)) + if(ring.isEmpty() || !(ring.getItem() instanceof ItemDodgeRing)) break dodgeRing; } @@ -140,7 +140,7 @@ public final class HUDHandler { } } else if(block != null && PlayerHelper.hasHeldItemClass(mc.player, ILexicon.class)) drawLexiconHUD(PlayerHelper.getFirstHeldItemClass(mc.player, ILexicon.class), state, pos, event.getResolution()); - if(tile != null && tile instanceof TilePool && mc.player.getHeldItemMainhand() != null) + if(tile != null && tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) renderPoolRecipeHUD(event.getResolution(), (TilePool) tile, mc.player.getHeldItemMainhand()); } if(tile != null && tile instanceof TileAltar) @@ -166,17 +166,17 @@ public final class HUDHandler { profiler.endSection(); } - if(main != null && main.getItem() instanceof ItemCraftingHalo) { + if(!main.isEmpty() && main.getItem() instanceof ItemCraftingHalo) { profiler.startSection("craftingHalo_main"); ItemCraftingHalo.renderHUD(event.getResolution(), mc.player, main); profiler.endSection(); - } else if(offhand != null && offhand.getItem() instanceof ItemCraftingHalo) { + } else if(!offhand.isEmpty() && offhand.getItem() instanceof ItemCraftingHalo) { profiler.startSection("craftingHalo_off"); ItemCraftingHalo.renderHUD(event.getResolution(), mc.player, offhand); profiler.endSection(); } - if(main != null && main.getItem() instanceof ItemSextant) { + if(!main.isEmpty() && main.getItem() instanceof ItemSextant) { profiler.startSection("sextant"); ItemSextant.renderHUD(event.getResolution(), mc.player, main); profiler.endSection(); @@ -216,7 +216,7 @@ public final class HUDHandler { IInventory inv = useBaubles ? baublesInv : mainInv; ItemStack stack = inv.getStackInSlot(i - (useBaubles ? invSize : 0)); - if(stack != null) { + if(!stack.isEmpty()) { Item item = stack.getItem(); if(item instanceof IManaUsingItem) anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); diff --git a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java index 99b14d023..98b972555 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java @@ -29,13 +29,13 @@ public final class ItemsRemainingRenderHandler { private static final int maxTicks = 30; private static final int leaveTicks = 20; - private static ItemStack stack; + private static ItemStack stack = ItemStack.EMPTY; private static String customString; private static int ticks, count; @SideOnly(Side.CLIENT) public static void render(ScaledResolution resolution, float partTicks) { - if(ticks > 0 && stack != null) { + if(ticks > 0 && !stack.isEmpty()) { int pos = maxTicks - ticks; Minecraft mc = Minecraft.getMinecraft(); int x = resolution.getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); @@ -64,7 +64,7 @@ public final class ItemsRemainingRenderHandler { String text = ""; if(customString == null) { - if(stack != null && stack.getItem() != null) { + if(!stack.isEmpty()) { text = TextFormatting.GREEN + stack.getDisplayName(); if(count >= 0) { int max = stack.getMaxStackSize(); diff --git a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java index e5be50d3e..aeb8ccddf 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java +++ b/src/main/java/vazkii/botania/client/core/handler/MultiblockBlockAccess.java @@ -13,6 +13,7 @@ package vazkii.botania.client.core.handler; import javax.annotation.Nonnull; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -88,7 +89,7 @@ public class MultiblockBlockAccess implements IBlockAccess { public Biome getBiome(@Nonnull BlockPos pos) { if(hasBlockAccess) return originalBlockAccess.getBiome(pos); - return null; + return Biomes.DEFAULT; } @Override diff --git a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java index 403977921..8dc54b0b9 100644 --- a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java +++ b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java @@ -44,7 +44,7 @@ public class RenderLexicon { Minecraft mc = Minecraft.getMinecraft(); if(!ConfigHandler.lexicon3dModel || mc.gameSettings.thirdPersonView != 0 - || mc.player.getHeldItem(evt.getHand()) == null + || mc.player.getHeldItem(evt.getHand()).isEmpty() || mc.player.getHeldItem(evt.getHand()).getItem() != ModItems.lexicon) return; evt.setCanceled(true); diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java index a6d2e5c92..52199ea27 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java @@ -44,7 +44,7 @@ public final class TooltipAdditionDisplayHandler { @SubscribeEvent public static void onToolTipRender(RenderTooltipEvent.PostText evt) { - if(evt.getStack() == null) + if(evt.getStack().isEmpty()) return; ItemStack stack = evt.getStack(); @@ -67,7 +67,7 @@ public final class TooltipAdditionDisplayHandler { for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++) { ItemStack stackAt = mc.player.inventory.getStackInSlot(i); - if(stackAt != null && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { + if(!stackAt.isEmpty() && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) { lexiconStack = stackAt; lexSlot = i; break; diff --git a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java index 8989072d5..47b60a21f 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java @@ -54,6 +54,7 @@ public class ContainerFlowerBag extends Container { || player.getHeldItemOffhand() == flowerBagInv.bag; } + @Nonnull @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { ItemStack itemstack = ItemStack.EMPTY; diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java index 70b9bc45e..352ec17f7 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/GuiLexicon.java @@ -76,7 +76,7 @@ import vazkii.botania.common.lib.LibMisc; public class GuiLexicon extends GuiScreen { public static GuiLexicon currentOpenLexicon = new GuiLexicon(); - public static ItemStack stackUsed; + public static ItemStack stackUsed = ItemStack.EMPTY; public static final Map notes = new HashMap<>(); diff --git a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java index bcacd6a2e..16ae01611 100644 --- a/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java +++ b/src/main/java/vazkii/botania/client/gui/lexicon/button/GuiButtonInvisible.java @@ -32,7 +32,7 @@ public class GuiButtonInvisible extends GuiButtonLexicon { private static final ResourceLocation dogResource = new ResourceLocation(LibResources.GUI_DOG); final GuiLexiconIndex gui; - public ItemStack displayStack = null; + public ItemStack displayStack = ItemStack.EMPTY; public boolean dog = false; float timeHover = 0; diff --git a/src/main/java/vazkii/botania/client/model/ModelBrewery.java b/src/main/java/vazkii/botania/client/model/ModelBrewery.java index 8c5db4d0b..0b64a8447 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBrewery.java +++ b/src/main/java/vazkii/botania/client/model/ModelBrewery.java @@ -55,7 +55,7 @@ public class ModelBrewery extends ModelBase { GlStateManager.translate(0F, offset, 0F); GlStateManager.rotate(polerot, 0F, 1F, 0F); - if(hasTile && render.brewery.getItemHandler().getStackInSlot(0) != null) { + if(hasTile && !render.brewery.getItemHandler().getStackInSlot(0).isEmpty()) { GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(0, -0.45, 0); //GlStateManager.translate(-1F / 8F, -0.5F, 1F / 128F); @@ -78,7 +78,7 @@ public class ModelBrewery extends ModelBase { offset1 = 0F; GlStateManager.translate(0F, offset1, 0F); - if(hasTile && render.brewery.getItemHandler().getStackInSlot(i + 1) != null) { + if(hasTile && !render.brewery.getItemHandler().getStackInSlot(i + 1).isEmpty()) { float rot = Plate.rotateAngleY * 180F / (float) Math.PI; float transX = 0.3125F; float transY = 1.06F; diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java index 3680e5dd1..ce666bd92 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderThornChakram.java @@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack; import vazkii.botania.common.entity.EntityThornChakram; import vazkii.botania.common.item.ModItems; +import javax.annotation.Nonnull; + // Basically a bit of an extension of RenderSnowball public class RenderThornChakram extends RenderSnowball { @@ -24,6 +26,7 @@ public class RenderThornChakram extends RenderSnowball { super(renderManager, ModItems.thornChakram, Minecraft.getMinecraft().getRenderItem()); } + @Nonnull @Override public ItemStack getStackToRender(EntityThornChakram entityIn) { return new ItemStack(ModItems.thornChakram, 1, entityIn.isFire() ? 1 : 0); diff --git a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java index 8399a1bcd..ccd0e2567 100644 --- a/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java +++ b/src/main/java/vazkii/botania/common/achievement/AchievementTriggerer.java @@ -23,7 +23,7 @@ public final class AchievementTriggerer { @SubscribeEvent public static void onItemPickedUp(ItemPickupEvent event) { ItemStack stack = event.pickedUp.getEntityItem(); - if(stack != null && stack.getItem() instanceof IPickupAchievement) { + if(!stack.isEmpty() && stack.getItem() instanceof IPickupAchievement) { Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); if(achievement != null) event.player.addStat(achievement, 1); @@ -32,7 +32,7 @@ public final class AchievementTriggerer { @SubscribeEvent public static void onItemCrafted(ItemCraftedEvent event) { - if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { + if(!event.crafting.isEmpty() && event.crafting.getItem() instanceof ICraftAchievement) { Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); if(achievement != null) event.player.addStat(achievement, 1); diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 6947352d0..da55f5bc7 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -110,6 +110,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable { } } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Blocks.DIRT.getItemDropped(state, rand, fortune); diff --git a/src/main/java/vazkii/botania/common/block/BlockAltar.java b/src/main/java/vazkii/botania/common/block/BlockAltar.java index 05e57af3c..1a6f7f3ab 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltar.java @@ -174,7 +174,7 @@ public class BlockAltar extends BlockMod implements ILexiconable { } return true; - } else if(stack != null && stack.getItem() == Items.LAVA_BUCKET) { + } else if(!stack.isEmpty() && stack.getItem() == Items.LAVA_BUCKET) { if(!player.capabilities.isCreativeMode) drain(FluidRegistry.LAVA, stack); @@ -184,7 +184,7 @@ public class BlockAltar extends BlockMod implements ILexiconable { world.checkLight(pos); return true; - } else if(stack != null && stack.getItem() == Items.BUCKET && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) { + } else if(!stack.isEmpty() && stack.getItem() == Items.BUCKET && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) { ItemStack bucket = tile.hasLava ? new ItemStack(Items.LAVA_BUCKET) : new ItemStack(Items.WATER_BUCKET); if(stack.getCount() == 1) player.setHeldItem(hand, bucket); diff --git a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java index 274773e0b..6c17f7f19 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java +++ b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java @@ -37,6 +37,8 @@ import vazkii.botania.common.block.tile.TileAnimatedTorch; import vazkii.botania.common.lexicon.LexiconData; import vazkii.botania.common.lib.LibBlockNames; +import javax.annotation.Nonnull; + public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrigger, IHourglassTrigger, IWandHUD, ILexiconable { private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.25, 1); @@ -102,6 +104,7 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig return 0; } + @Nonnull @Override public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; @@ -117,13 +120,14 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig return false; } + @Nonnull @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { return AABB; } @Override - public TileEntity createTileEntity(World world, IBlockState state) { + public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { return new TileAnimatedTorch(); } diff --git a/src/main/java/vazkii/botania/common/block/BlockAvatar.java b/src/main/java/vazkii/botania/common/block/BlockAvatar.java index 79a646e3b..1fa4cee2e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAvatar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAvatar.java @@ -93,13 +93,13 @@ public class BlockAvatar extends BlockMod implements ILexiconable { TileAvatar avatar = (TileAvatar) world.getTileEntity(pos); ItemStack stackOnAvatar = avatar.getItemHandler().getStackInSlot(0); ItemStack stackOnPlayer = player.getHeldItem(hand); - if(stackOnAvatar != null) { + if(!stackOnAvatar.isEmpty()) { ItemStack copyStack = stackOnAvatar.copy(); avatar.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); if(!player.inventory.addItemStackToInventory(copyStack)) player.dropItem(copyStack, true); return true; - } else if(stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) { + } else if(!stackOnPlayer.isEmpty() && stackOnPlayer.getItem() instanceof IAvatarWieldable) { ItemStack copyStack = stackOnPlayer.copy(); avatar.getItemHandler().setStackInSlot(0, copyStack); stackOnPlayer.shrink(1); diff --git a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java index 442a8b517..b97cd151c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java @@ -45,6 +45,7 @@ public class BlockEnchantedSoil extends BlockMod implements ILexiconable { return false; } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Blocks.DIRT.getItemDropped(state, rand, fortune); diff --git a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java index 5d2d586ed..328038bdb 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java @@ -104,7 +104,7 @@ public class BlockFakeAir extends BlockMod { } @Override - public boolean canBeReplacedByLeaves(IBlockState state, IBlockAccess world, BlockPos pos) { + public boolean canBeReplacedByLeaves(@Nonnull IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) { return true; } diff --git a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java index 2a497f50a..83d6fcefe 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java @@ -71,6 +71,7 @@ public class BlockGaiaHead extends BlockSkull implements IModelRegister { return ret; } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return ModItems.gaiaHead; diff --git a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java index 41be916b4..c9dc35373 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java @@ -28,6 +28,7 @@ import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -88,9 +89,10 @@ public abstract class BlockModDoubleFlower extends BlockDoublePlant implements I @Override public abstract IBlockState getStateFromMeta(int meta); + @Nonnull @Override public Item getItemDropped(IBlockState state, @Nonnull Random rand, int fortune) { - return null; + return Items.AIR; } @Override diff --git a/src/main/java/vazkii/botania/common/block/BlockPlatform.java b/src/main/java/vazkii/botania/common/block/BlockPlatform.java index 938c30afd..cf56cf96c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPlatform.java +++ b/src/main/java/vazkii/botania/common/block/BlockPlatform.java @@ -146,7 +146,7 @@ public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable, } @Override - public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { + public float getExplosionResistance(World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion) { return world.getBlockState(pos).getValue(BotaniaStateProps.PLATFORM_VARIANT) != PlatformVariant.INFRANGIBLE ? super.getExplosionResistance(world, pos, exploder, explosion) : Float.MAX_VALUE; } diff --git a/src/main/java/vazkii/botania/common/block/BlockRoot.java b/src/main/java/vazkii/botania/common/block/BlockRoot.java index 2712253d1..0d17cea0a 100644 --- a/src/main/java/vazkii/botania/common/block/BlockRoot.java +++ b/src/main/java/vazkii/botania/common/block/BlockRoot.java @@ -43,6 +43,7 @@ public class BlockRoot extends BlockMod implements ILexiconable { return new ItemStack(this); } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return ModItems.manaResource; diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java index 7215a946f..3e0529661 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java @@ -67,6 +67,7 @@ public class BlockBuriedPetals extends BlockModFlower { return false; } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return ModItems.petal; diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java index 7c0b53667..6d2d531d0 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartz.java @@ -114,6 +114,7 @@ public class BlockSpecialQuartz extends BlockMod implements ILexiconable { return getMetaFromState(state); } + @Nonnull @Override public ItemStack getSilkTouchDrop(@Nonnull IBlockState state) { return new ItemStack(this, 1, damageDropped(state)); diff --git a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java index 920e90a84..7ee9d9946 100644 --- a/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/quartz/BlockSpecialQuartzSlab.java @@ -86,11 +86,13 @@ public class BlockSpecialQuartzSlab extends BlockModSlab { return new ItemStack(getSingleBlock()); } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(getSingleBlock()); } + @Nonnull @Override public ItemStack getSilkTouchDrop(@Nonnull IBlockState par1) { return new ItemStack(getSingleBlock()); diff --git a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java index c2d4fdbeb..4350d5e06 100644 --- a/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java +++ b/src/main/java/vazkii/botania/common/block/decor/slabs/BlockModSlab.java @@ -90,11 +90,13 @@ public abstract class BlockModSlab extends BlockSlab implements ILexiconable, IM return new ItemStack(getSingleBlock()); } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(getSingleBlock()); } + @Nonnull @Override public ItemStack getSilkTouchDrop(@Nonnull IBlockState par1) { return new ItemStack(getSingleBlock()); diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java index 7d44d226c..1a2f10522 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java @@ -100,6 +100,7 @@ public class BlockEnchanter extends BlockMod implements IWandable, ILexiconable, return new TileEnchanter(); } + @Nonnull @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(Blocks.LAPIS_BLOCK); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java index 782a01781..b802417f2 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java @@ -54,7 +54,7 @@ public class SubTileOrechid extends SubTileFunctional { BlockPos coords = getCoordsToPut(); if(coords != null) { ItemStack stack = getOreToPut(); - if(stack != null && stack.getItem() != null) { + if(!stack.isEmpty()) { Block block = Block.getBlockFromItem(stack.getItem()); int meta = stack.getItemDamage(); supertile.getWorld().setBlockState(coords, block.getStateFromMeta(meta), 1 | 2); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java index 2c326d259..ef3c0e44f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java @@ -175,7 +175,7 @@ public class SubTileRannuncarpus extends SubTileFunctional { GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(recieverStack.getItem() != null) { + if(!recieverStack.isEmpty()) { String stackName = recieverStack.getDisplayName(); int width = 16 + mc.fontRendererObj.getStringWidth(stackName) / 2; int x = res.getScaledWidth() / 2 - width; diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java index 9c75af2a3..56036d78c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java @@ -64,7 +64,7 @@ public class SubTileGourmaryllis extends SubTileGenerating { continue; } - if(stack != null && stack.getItem() instanceof ItemFood && !item.isDead && age >= slowdown) { + if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.isDead && age >= slowdown) { if(cooldown <= 0) { int val = Math.min(12, ((ItemFood) stack.getItem()).getHealAmount(stack)); storedMana = val * val * 64; diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java index 14d4d61f1..3c77e3e73 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java @@ -62,7 +62,7 @@ public class SubTileSpectrolus extends SubTileGenerating { continue; } - if(stack != null && stack.getItem() == wool && !item.isDead && age >= slowdown) { + if(!stack.isEmpty() && stack.getItem() == wool && !item.isDead && age >= slowdown) { int meta = stack.getItemDamage(); if(meta == nextColor) { if(!remote) { @@ -116,7 +116,7 @@ public class SubTileSpectrolus extends SubTileGenerating { GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(stack != null && stack.getItem() != null) { + if(!stack.isEmpty()) { String stackName = stack.getDisplayName(); int width = 16 + mc.fontRendererObj.getStringWidth(stackName) / 2; int x = res.getScaledWidth() / 2 - width; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index 527236778..33166ee84 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -51,6 +51,8 @@ import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.Botania; +import javax.annotation.Nonnull; + public class TileAltar extends TileSimpleInventory implements IPetalApothecary { private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); @@ -69,7 +71,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { public boolean collideEntityItem(EntityItem item) { ItemStack stack = item.getEntityItem(); - if(stack == null || item.isDead) + if(stack.isEmpty() || item.isDead) return false; if(!isMossy && world.getBlockState(getPos()).getValue(BotaniaStateProps.ALTAR_VARIANT) == AltarVariant.DEFAULT) { @@ -139,7 +141,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { break; } } - } else if(stack.getItem() != null && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) { + } else if(!stack.isEmpty() && SEED_PATTERN.matcher(stack.getItem().getUnlocalizedName(stack)).find()) { for(RecipePetals recipe : BotaniaAPI.petalRecipes) { if(recipe.matches(itemHandler)) { saveLastRecipe(); @@ -237,7 +239,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { public boolean isEmpty() { for(int i = 0; i < getSizeInventory(); i++) - if(itemHandler.getStackInSlot(i) != null) + if(!itemHandler.getStackInSlot(i).isEmpty()) return false; return true; @@ -256,7 +258,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { for(int i = 0; i < getSizeInventory(); i++) { ItemStack stackAt = itemHandler.getStackInSlot(i); - if(stackAt == null) + if(stackAt.isEmpty()) break; if(Math.random() >= 0.97) { @@ -309,7 +311,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, false) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } }; @@ -344,7 +346,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary { int radius = 24; int amt = 0; for(int i = 0; i < getSizeInventory(); i++) { - if(itemHandler.getStackInSlot(i) == null) + if(itemHandler.getStackInSlot(i).isEmpty()) break; amt++; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java index cb5be528d..bcd365475 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java @@ -18,6 +18,8 @@ import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.state.BotaniaStateProps; +import javax.annotation.Nonnull; + public class TileAvatar extends TileSimpleInventory implements IAvatarTile { private static final int MAX_MANA = 6400; @@ -42,7 +44,7 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile { } ItemStack stack = itemHandler.getStackInSlot(0); - if(stack != null && stack.getItem() instanceof IAvatarWieldable) { + if(!stack.isEmpty() && stack.getItem() instanceof IAvatarWieldable) { IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); wieldable.onAvatarUpdate(this, stack); } @@ -76,7 +78,7 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile { protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, false) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } }; @@ -94,7 +96,7 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile { @Override public boolean canRecieveManaFromBursts() { - return itemHandler.getStackInSlot(0) != null; + return !itemHandler.getStackInSlot(0).isEmpty(); } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java index fef368e53..2eaba9bb2 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java @@ -48,7 +48,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver { public int signal = 0; public boolean addItem(@Nullable EntityPlayer player, ItemStack stack, @Nullable EnumHand hand) { - if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer) + if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer) return false; boolean did = false; @@ -205,7 +205,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver { protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, false) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } }; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java index ee269a100..81497942f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -83,12 +83,13 @@ public class TileCraftCrate extends TileOpenCrate { protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if(slot != 9 && !isLocked(slot)) return super.insertItem(slot, stack, simulate); else return stack; @@ -110,7 +111,7 @@ public class TileCraftCrate extends TileOpenCrate { int newSignal = 0; for(; newSignal < 9; newSignal++) // dis for loop be derpy - if(!isLocked(newSignal) && itemHandler.getStackInSlot(newSignal) == null) + if(!isLocked(newSignal) && itemHandler.getStackInSlot(newSignal).isEmpty()) break; if(newSignal != signal) { @@ -132,7 +133,7 @@ public class TileCraftCrate extends TileOpenCrate { for(int i = 0; i < 9; i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack == null || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) + if(stack.isEmpty() || isLocked(i) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 11) continue; craft.setInventorySlotContents(i, stack.copy()); @@ -145,7 +146,7 @@ public class TileCraftCrate extends TileOpenCrate { for(int i = 0; i < 9; i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack == null) + if(stack.isEmpty()) continue; ItemStack container = stack.getItem().getContainerItem(stack); @@ -159,7 +160,7 @@ public class TileCraftCrate extends TileOpenCrate { boolean isFull() { for(int i = 0; i < 9; i++) - if(!isLocked(i) && itemHandler.getStackInSlot(i) == null) + if(!isLocked(i) && itemHandler.getStackInSlot(i).isEmpty()) return false; return true; @@ -168,9 +169,9 @@ public class TileCraftCrate extends TileOpenCrate { private void ejectAll() { for(int i = 0; i < getSizeInventory(); ++i) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack != null) + if(!stack.isEmpty()) eject(stack, false); - itemHandler.setStackInSlot(i, null); + itemHandler.setStackInSlot(i, ItemStack.EMPTY); } markDirty(); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java index 3f524a055..bd945a1b1 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java @@ -38,7 +38,7 @@ public class TileEnderEye extends TileMod { boolean looking = false; for(EntityPlayer player : players) { ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); - if(helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN)) + if(!helm.isEmpty() && helm.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN)) continue; RayTraceResult pos = ToolCommons.raytraceFromEntity(world, player, true, 64); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java index 928ca1e0d..dabe63ca2 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java @@ -30,6 +30,8 @@ import vazkii.botania.api.item.IHourglassTrigger; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.item.ModItems; +import javax.annotation.Nonnull; + public class TileHourglass extends TileSimpleInventory { private static final String TAG_TIME = "time"; @@ -52,7 +54,7 @@ public class TileHourglass extends TileSimpleInventory { public void update() { int totalTime = getTotalTime(); ItemStack dustStack = itemHandler.getStackInSlot(0); - dust = dustStack != null && dustStack.getItem() == ModItems.manaResource; + dust = !dustStack.isEmpty() && dustStack.getItem() == ModItems.manaResource; if(totalTime > 0 || dust) { if(move && !dust) @@ -134,9 +136,10 @@ public class TileHourglass extends TileSimpleInventory { @Override protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if(stack != null && (stack.getItem() == Item.getItemFromBlock(Blocks.SAND) || stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 23) + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if(!stack.isEmpty() && (stack.getItem() == Item.getItemFromBlock(Blocks.SAND) || stack.getItem() == Item.getItemFromBlock(Blocks.SOUL_SAND)) || stack.getItem() == ModItems.manaResource && stack.getItemDamage() == 23) return super.insertItem(slot, stack, simulate); else return stack; } @@ -185,7 +188,7 @@ public class TileHourglass extends TileSimpleInventory { int y = res.getScaledHeight() / 2 - 10; ItemStack stack = itemHandler.getStackInSlot(0); - if(stack != null) { + if(!stack.isEmpty()) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableRescaleNormal(); mc.getRenderItem().renderItemIntoGUI(stack, x, y); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java index 214bdbd8f..92b188503 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java @@ -28,6 +28,8 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.brew.ItemIncenseStick; +import javax.annotation.Nonnull; + public class TileIncensePlate extends TileSimpleInventory { private static final String TAG_TIME_LEFT = "timeLeft"; @@ -42,7 +44,7 @@ public class TileIncensePlate extends TileSimpleInventory { @Override public void update() { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack != null && burning) { + if(!stack.isEmpty() && burning) { Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); PotionEffect effect = brew.getPotionEffects(stack).get(0); if(timeLeft > 0) { @@ -72,14 +74,14 @@ public class TileIncensePlate extends TileSimpleInventory { Botania.proxy.wispFX(x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.2F, 0.2F, 0.2F, 0.05F + (float) Math.random() * 0.02F, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); } } else { - itemHandler.setStackInSlot(0, null); + itemHandler.setStackInSlot(0, ItemStack.EMPTY); burning = false; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } } else timeLeft = 0; int newComparator = 0; - if(stack != null) + if(!stack.isEmpty()) newComparator = 1; if(burning) newComparator = 2; @@ -91,7 +93,7 @@ public class TileIncensePlate extends TileSimpleInventory { public void ignite() { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack == null || burning) + if(stack.isEmpty() || burning) return; burning = true; @@ -125,16 +127,18 @@ public class TileIncensePlate extends TileSimpleInventory { @Override protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if(acceptsItem(stack)) return super.insertItem(slot, stack, simulate); else return stack; } + @Nonnull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { - return null; + return ItemStack.EMPTY; } }; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java index 653668150..7fdb36038 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java @@ -56,7 +56,7 @@ public class TileOpenCrate extends TileSimpleInventory { if(canEject()) { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack != null) + if(!stack.isEmpty()) eject(stack, redstone); } } @@ -80,7 +80,7 @@ public class TileOpenCrate extends TileSimpleInventory { } - itemHandler.setStackInSlot(0, null); + itemHandler.setStackInSlot(0, ItemStack.EMPTY); world.spawnEntity(item); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index 5b1c009bc..8d8f8a2a5 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -83,7 +83,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver boolean did = false; for(int i = 0; i < getSizeInventory(); i++) - if(itemHandler.getStackInSlot(i) == null) { + if(itemHandler.getStackInSlot(i).isEmpty()) { did = true; ItemStack stackToAdd = stack.copy(); stackToAdd.setCount(1); @@ -92,7 +92,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver if(player == null || !player.capabilities.isCreativeMode) { stack.shrink(1); if(stack.isEmpty() && player != null) - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); } break; @@ -113,7 +113,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver if(!world.isRemote && manaToGet == 0) { List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); for(EntityItem item : items) - if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { + if(!item.isDead && !item.getEntityItem().isEmpty() && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { ItemStack stack = item.getEntityItem(); if(addItem(null, stack, null) && stack.isEmpty()) item.setDead(); @@ -179,7 +179,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver lastRecipe = new ArrayList<>(); for(int i = 0; i < getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack == null) + if(stack.isEmpty()) break; lastRecipe.add(stack.copy()); } @@ -216,7 +216,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); EntityItem livingrock = null; for(EntityItem item : items) - if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { + if(!item.isDead && !item.getEntityItem().isEmpty() && item.getEntityItem().getItem() == Item.getItemFromBlock(ModBlocks.livingrock)) { livingrock = item; break; } @@ -236,13 +236,13 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver if(!world.isRemote) { for(int i = 0; i < getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == ModItems.rune && (player == null || !player.capabilities.isCreativeMode)) { EntityItem outputItem = new EntityItem(world, getPos().getX() + 0.5, getPos().getY() + 1.5, getPos().getZ() + 0.5, stack.copy()); world.spawnEntity(outputItem); } - itemHandler.setStackInSlot(i, null); + itemHandler.setStackInSlot(i, ItemStack.EMPTY); } } @@ -269,7 +269,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver public boolean isEmpty() { for(int i = 0; i < getSizeInventory(); i++) - if(itemHandler.getStackInSlot(i) != null) + if(!itemHandler.getStackInSlot(i).isEmpty()) return false; return true; @@ -306,7 +306,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, false) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } }; @@ -340,7 +340,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver int radius = 24; int amt = 0; for(int i = 0; i < getSizeInventory(); i++) { - if(itemHandler.getStackInSlot(i) == null) + if(itemHandler.getStackInSlot(i).isEmpty()) break; amt++; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java index 4417dc316..bb38319f6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java @@ -46,13 +46,12 @@ public abstract class TileSimpleInventory extends TileMod { } @Override - public boolean hasCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public boolean hasCapability(@Nonnull Capability cap, EnumFacing side) { return cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(cap, side); } - @Nonnull @Override - public T getCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public T getCapability(@Nonnull Capability cap, EnumFacing side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemHandler); return super.getCapability(cap, side); @@ -71,18 +70,20 @@ public abstract class TileSimpleInventory extends TileMod { tile = inv; } + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if(allowWrite) { return super.insertItem(slot, stack, simulate); } else return stack; } + @Nonnull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { if(allowWrite) { return super.extractItem(slot, amount, simulate); - } else return null; + } else return ItemStack.EMPTY; } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java index 7720a23ed..3139759fa 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java @@ -23,6 +23,8 @@ import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkUpgradeType; import vazkii.botania.common.item.ModItems; +import javax.annotation.Nonnull; + public class TileSparkChanger extends TileSimpleInventory { public void doSwap() { @@ -38,7 +40,7 @@ public class TileSparkChanger extends TileSimpleInventory { ISparkEntity spark = attach.getAttachedSpark(); if(spark != null) { SparkUpgradeType upg = spark.getUpgrade(); - SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1]; + SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1]; if(upg != newUpg) attachables.add(attach); } @@ -49,8 +51,8 @@ public class TileSparkChanger extends TileSimpleInventory { ISparkAttachable attach = attachables.get(world.rand.nextInt(attachables.size())); ISparkEntity spark = attach.getAttachedSpark(); SparkUpgradeType upg = spark.getUpgrade(); - ItemStack sparkStack = upg == SparkUpgradeType.NONE ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg.ordinal() - 1); - SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1]; + ItemStack sparkStack = upg == SparkUpgradeType.NONE ? ItemStack.EMPTY : new ItemStack(ModItems.sparkUpgrade, 1, upg.ordinal() - 1); + SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1]; spark.setUpgrade(newUpg); Collection transfers = spark.getTransfers(); if(transfers != null) @@ -70,13 +72,14 @@ public class TileSparkChanger extends TileSimpleInventory { protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if(stack != null && stack.getItem() == ModItems.sparkUpgrade) + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if(!stack.isEmpty() && stack.getItem() == ModItems.sparkUpgrade) return super.insertItem(slot, stack, simulate); else return stack; } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index 4b859738e..c4341e7a3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -173,13 +173,12 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor } @Override - public boolean hasCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public boolean hasCapability(@Nonnull Capability cap, EnumFacing side) { return cap == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(cap, side); } - @Nonnull @Override - public T getCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public T getCapability(@Nonnull Capability cap, EnumFacing side) { if(cap == CapabilityAnimation.ANIMATION_CAPABILITY) { return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); } else return super.getCapability(cap, side); diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java index ae8d8e58a..373160d80 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java @@ -54,7 +54,7 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq EnumFacing orientation = frame.facingDirection; if(orientation == dir) { ItemStack stack = frame.getDisplayedItem(); - if(stack != null) { + if(!stack.isEmpty()) { ItemStack copy = stack.copy(); copy.setCount(rotationToStackSize[frame.getRotation()]); filter.add(copy); @@ -86,7 +86,7 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq List stacks = CorporeaHelper.requestItem(request, count, spark, true, true); spark.onItemsRequested(stacks); for(ItemStack reqStack : stacks) { - if(inv != null && ItemHandlerHelper.insertItemStacked(inv, reqStack, true) == null) + if(inv != null && ItemHandlerHelper.insertItemStacked(inv, reqStack, true).isEmpty()) ItemHandlerHelper.insertItemStacked(inv, reqStack, false); else { EntityItem item = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, reqStack); diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java index 5c224af04..3c9a20cb8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java @@ -260,7 +260,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ if(name.equals("this")) { ItemStack stack = event.getPlayer().getHeldItemMainhand(); - if(stack != null) + if(!stack.isEmpty()) name = stack.getDisplayName().toLowerCase().trim(); } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java index 7087d567e..0b7b15a98 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java @@ -66,12 +66,12 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor } public boolean requestMatches(Object request, ItemStack filter) { - if(filter == null) + if(filter.isEmpty()) return false; if(request instanceof ItemStack) { ItemStack stack = (ItemStack) request; - return stack != null && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); + return !stack.isEmpty() && stack.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(filter, stack); } String name = (String) request; diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java index 8911e5b80..638acb73f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java @@ -249,7 +249,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt continue; ItemStack stack = item.getEntityItem(); - if(stack != null && stack.getItem() instanceof IManaItem) { + if(!stack.isEmpty() && stack.getItem() instanceof IManaItem) { IManaItem mana = (IManaItem) stack.getItem(); if(outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) { boolean didSomething = false; diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java index 7f1f0584d..349d2aa58 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java @@ -20,15 +20,17 @@ import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.TileSimpleInventory; +import javax.annotation.Nonnull; + public class TilePrism extends TileSimpleInventory { public void onBurstCollision(IManaBurst burst) { ItemStack lens = itemHandler.getStackInSlot(0); boolean active = !world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED); - boolean valid = lens != null && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); + boolean valid = !lens.isEmpty() && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); if(active) { - burst.setSourceLens(valid ? lens.copy() : null); + burst.setSourceLens(valid ? lens.copy() : ItemStack.EMPTY); burst.setColor(0xFFFFFF); burst.setGravity(0F); @@ -56,9 +58,10 @@ public class TilePrism extends TileSimpleInventory { @Override protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if(stack != null && stack.getItem() instanceof ILens) + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if(!stack.isEmpty() && stack.getItem() instanceof ILens) return super.insertItem(slot, stack, simulate); else return stack; } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java index 732ae4089..1091fd51d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java @@ -56,13 +56,12 @@ public class TilePump extends TileMod { } @Override - public boolean hasCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public boolean hasCapability(@Nonnull Capability cap, EnumFacing side) { return cap == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(cap, side); } - @Nonnull @Override - public T getCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public T getCapability(@Nonnull Capability cap, EnumFacing side) { if (cap == CapabilityAnimation.ANIMATION_CAPABILITY) { return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java index 9912623ac..19a68b86f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java @@ -510,7 +510,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); ItemStack lens = itemHandler.getStackInSlot(0); - if(lens != null && lens.getItem() instanceof ILensEffect) + if(!lens.isEmpty() && lens.getItem() instanceof ILensEffect) ((ILensEffect) lens.getItem()).apply(lens, props); burst.setSourceLens(lens); @@ -578,7 +578,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res); ItemStack lens = itemHandler.getStackInSlot(0); - if(lens != null) { + if(!lens.isEmpty()) { GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); String lensName = lens.getDisplayName(); @@ -599,7 +599,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, ItemStack recieverStack = new ItemStack(world.getBlockState(receiverTile.getPos()).getBlock(), 1, receiverTile.getBlockMetadata()); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - if(recieverStack != null && recieverStack.getItem() != null) { + if(!recieverStack.isEmpty()) { String stackName = recieverStack.getDisplayName(); int width = 16 + mc.fontRendererObj.getStringWidth(stackName) / 2; int x = res.getScaledWidth() / 2 - width; @@ -640,13 +640,14 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, protected SimpleItemStackHandler createItemHandler() { return new SimpleItemStackHandler(this, true) { @Override - protected int getStackLimit(int slot, ItemStack stack) { + protected int getStackLimit(int slot, @Nonnull ItemStack stack) { return 1; } + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if(stack != null && stack.getItem() instanceof ILens) + public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { + if(!stack.isEmpty() && stack.getItem() instanceof ILens) return super.insertItem(slot, stack, simulate); else return stack; } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java index 0c3ee7de0..15f33d771 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java @@ -31,7 +31,7 @@ public class TileRedStringContainer extends TileRedString { } @Override - public boolean hasCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public boolean hasCapability(@Nonnull Capability cap, EnumFacing side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && getTileAtBinding() != null && getTileAtBinding().hasCapability(cap, side)) @@ -39,9 +39,8 @@ public class TileRedStringContainer extends TileRedString { return super.hasCapability(cap, side); } - @Nonnull @Override - public T getCapability(@Nonnull Capability cap, @Nonnull EnumFacing side) { + public T getCapability(@Nonnull Capability cap, EnumFacing side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && getTileAtBinding() != null && getTileAtBinding().hasCapability(cap, side)) diff --git a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java index f789d26d2..b382d7f53 100644 --- a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java @@ -60,7 +60,7 @@ public class InventoryHelper { for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { ItemStack itemstack = inv.getItemHandler().getStackInSlot(j1); - if(itemstack != null) { + if(!itemstack.isEmpty()) { net.minecraft.inventory.InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } @@ -72,10 +72,10 @@ public class InventoryHelper { public static void withdrawFromInventory(TileSimpleInventory inv, EntityPlayer player) { for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { ItemStack stackAt = inv.getItemHandler().getStackInSlot(i); - if(stackAt != null) { + if(!stackAt.isEmpty()) { ItemStack copy = stackAt.copy(); ItemHandlerHelper.giveItemToPlayer(player, copy); - inv.getItemHandler().setStackInSlot(i, null); + inv.getItemHandler().setStackInSlot(i, ItemStack.EMPTY); player.world.updateComparatorOutputLevel(inv.getPos(), null); break; } diff --git a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 449012319..4a43c7128 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java @@ -101,7 +101,7 @@ public final class ItemNBTHelper { // GETTERS /////////////////////////////////////////////////////////////////// public static boolean verifyExistance(ItemStack stack, String tag) { - return stack != null && getNBT(stack).hasKey(tag); + return !stack.isEmpty() && getNBT(stack).hasKey(tag); } public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) { diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java index 6aa5bbde8..c01bda203 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AesirRingRecipe.java @@ -33,7 +33,7 @@ public class AesirRingRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == ModItems.thorRing && !foundThorRing) foundThorRing = true; else if(stack.getItem() == ModItems.odinRing && !foundOdinRing) @@ -47,6 +47,7 @@ public class AesirRingRecipe implements IRecipe { return foundThorRing && foundOdinRing && foundLokiRing; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { String soulbind = null; @@ -55,7 +56,7 @@ public class AesirRingRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof IRelic) { if(((IRelic) stack.getItem()).hasUUID(stack)) { hasUUID = true; @@ -63,16 +64,16 @@ public class AesirRingRecipe implements IRecipe { if(soulbindUUID == null) soulbindUUID = bindUUID; else if(!soulbindUUID.equals(bindUUID)) - return null; + return ItemStack.EMPTY; } else { String bind = ((IRelic) stack.getItem()).getSoulbindUsername(stack); if(soulbind == null) soulbind = bind; else if(!soulbind.equals(bind)) - return null; + return ItemStack.EMPTY; } - } else return null; + } else return ItemStack.EMPTY; } } @@ -89,9 +90,10 @@ public class AesirRingRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java index 2ce0157ff..2c5c73e8b 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java @@ -30,7 +30,7 @@ public class AncientWillRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == ModItems.ancientWill && !foundWill) foundWill = true; else if(!foundItem) { @@ -44,14 +44,15 @@ public class AncientWillRecipe implements IRecipe { return foundWill && foundItem; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack item = null; + ItemStack item = ItemStack.EMPTY; int will = -1; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof IAncientWillContainer && item == null) item = stack; else will = stack.getItemDamage(); @@ -60,7 +61,7 @@ public class AncientWillRecipe implements IRecipe { IAncientWillContainer container = (IAncientWillContainer) item.getItem(); if(container.hasAncientWill(item, will)) - return null; + return ItemStack.EMPTY; ItemStack copy = item.copy(); container.addAncientWill(copy, will); @@ -72,9 +73,10 @@ public class AncientWillRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java index cc4ce7a43..55ece2aa9 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java @@ -28,7 +28,7 @@ public class ArmorUpgradeRecipe extends ShapedOreRecipe { ItemStack out = output.copy(); for (int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof ItemArmor && stack.hasTagCompound()) { + if (!stack.isEmpty() && stack.getItem() instanceof ItemArmor && stack.hasTagCompound()) { EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(stack), out); byte runicHardening = ItemNBTHelper.getByte(stack, "RS.HARDEN", (byte)0); if (runicHardening != 0) diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java index 29133c44b..7499078f4 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java @@ -30,7 +30,7 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) foundTalisman = true; else return false; @@ -40,13 +40,14 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { return foundTalisman; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack talisman = null; + ItemStack talisman = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) + if(!stack.isEmpty()) talisman = stack; } @@ -57,7 +58,7 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { return new ItemStack(block, Math.min(64, count), meta); } - return null; + return ItemStack.EMPTY; } @Override @@ -65,9 +66,10 @@ public class BlackHoleTalismanExtractRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java index 5692ddc5d..77535bdbd 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java @@ -33,7 +33,7 @@ public class CompositeLensRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ICompositableLens && !foundSecondLens) { if(foundLens) foundSecondLens = true; @@ -47,16 +47,17 @@ public class CompositeLensRecipe implements IRecipe { return foundSecondLens && foundSlimeball; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack lens = null; - ItemStack secondLens = null; + ItemStack lens = ItemStack.EMPTY; + ItemStack secondLens = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ICompositableLens) - if(lens == null) + if(lens.isEmpty()) lens = stack; else secondLens = stack; } @@ -64,8 +65,8 @@ public class CompositeLensRecipe implements IRecipe { if(lens.getItem() instanceof ICompositableLens) { ICompositableLens lensItem = (ICompositableLens) lens.getItem(); - if(secondLens == null || !lensItem.canCombineLenses(lens, secondLens) || lensItem.getCompositeLens(lens) != null || lensItem.getCompositeLens(secondLens) != null) - return null; + if(secondLens.isEmpty() || !lensItem.canCombineLenses(lens, secondLens) || lensItem.getCompositeLens(lens) != null || lensItem.getCompositeLens(secondLens) != null) + return ItemStack.EMPTY; ItemStack lensCopy = lens.copy(); ((ItemLens) ModItems.lens).setCompositeLens(lensCopy, secondLens); @@ -73,7 +74,7 @@ public class CompositeLensRecipe implements IRecipe { return lensCopy; } - return null; + return ItemStack.EMPTY; } @Override @@ -81,9 +82,10 @@ public class CompositeLensRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java index 6517a9a2b..138ef8d16 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java @@ -30,7 +30,7 @@ public class CosmeticAttachRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) foundCosmetic = true; else if(!foundAttachable) { @@ -44,14 +44,15 @@ public class CosmeticAttachRecipe implements IRecipe { return foundCosmetic && foundAttachable; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack cosmeticItem = null; - ItemStack attachableItem = null; + ItemStack cosmeticItem = ItemStack.EMPTY; + ItemStack attachableItem = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ICosmeticBauble && cosmeticItem == null) cosmeticItem = stack; else attachableItem = stack; @@ -59,11 +60,11 @@ public class CosmeticAttachRecipe implements IRecipe { } if(!(attachableItem.getItem() instanceof ICosmeticAttachable)) - return null; + return ItemStack.EMPTY; ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if(attachable.getCosmeticItem(attachableItem) != null) - return null; + if(!attachable.getCosmeticItem(attachableItem).isEmpty()) + return ItemStack.EMPTY; ItemStack copy = attachableItem.copy(); attachable.setCosmeticItem(copy, cosmeticItem); @@ -75,9 +76,10 @@ public class CosmeticAttachRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java index 9319badb4..e4e71c26c 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java @@ -29,7 +29,7 @@ public class CosmeticRemoveRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack) != null) foundAttachable = true; else return false; @@ -39,19 +39,20 @@ public class CosmeticRemoveRecipe implements IRecipe { return foundAttachable; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack attachableItem = null; + ItemStack attachableItem = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) + if(!stack.isEmpty()) attachableItem = stack; } ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); if(attachable.getCosmeticItem(attachableItem) == null) - return null; + return ItemStack.EMPTY; ItemStack copy = attachableItem.copy(); attachable.setCosmeticItem(copy, null); @@ -63,9 +64,10 @@ public class CosmeticRemoveRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java index 38f733185..14a8b0b0b 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java @@ -32,7 +32,7 @@ public class HeadRecipe extends RecipeRuneAltar { if(matches) { for(int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack == null) + if(stack.isEmpty()) break; if(stack.getItem() == Items.NAME_TAG) { diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java index d1a83d4f2..0b3655918 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java @@ -36,7 +36,7 @@ public class HelmRevealingRecipe implements IRecipe { boolean foundHelm = false; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(checkHelm(stack)) foundHelm = true; else if(stack.getItem() == goggles) @@ -47,18 +47,19 @@ public class HelmRevealingRecipe implements IRecipe { return foundGoggles && foundHelm; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack helm = null; + ItemStack helm = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && checkHelm(stack)) + if(!stack.isEmpty() && checkHelm(stack)) helm = stack; } - if(helm == null) - return null; + if(helm.isEmpty()) + return ItemStack.EMPTY; ItemStack helmCopy = helm.copy(); Item helmItem = helmCopy.getItem(); @@ -71,7 +72,7 @@ public class HelmRevealingRecipe implements IRecipe { newHelm = new ItemStack(ModItems.terrasteelHelmRevealing); else if(helmItem == ModItems.elementiumHelm) newHelm = new ItemStack(ModItems.elementiumHelmRevealing); - else return null; + else return ItemStack.EMPTY; //Copy Ancient Wills for(int i = 0; i < 6; i++) @@ -95,6 +96,7 @@ public class HelmRevealingRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { return new ItemStack(ModItems.manasteelHelmRevealing); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java index b101e0ada..e14175089 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java @@ -37,7 +37,7 @@ public class LensDyeingRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ILens && !foundLens) foundLens = true; else if(!foundDye) { @@ -53,15 +53,16 @@ public class LensDyeingRecipe implements IRecipe { return foundLens && foundDye; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack lens = null; + ItemStack lens = ItemStack.EMPTY; int color = -1; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { - if(stack.getItem() instanceof ILens && lens == null) + if(!stack.isEmpty()) { + if(stack.getItem() instanceof ILens && lens.isEmpty()) lens = stack; else color = getStackColor(stack);//We can assume if its not a lens its a dye because we checked it in matches() } @@ -75,7 +76,7 @@ public class LensDyeingRecipe implements IRecipe { return lensCopy; } - return null; + return ItemStack.EMPTY; } @Override @@ -83,9 +84,10 @@ public class LensDyeingRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } int getStackColor(ItemStack stack) { diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java index 470253e76..513556216 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java @@ -30,7 +30,7 @@ public class ManaGunClipRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) foundGun = true; @@ -44,18 +44,19 @@ public class ManaGunClipRecipe implements IRecipe { return foundGun && foundClip; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack gun = null; + ItemStack gun = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemManaGun) + if(!stack.isEmpty() && stack.getItem() instanceof ItemManaGun) gun = stack; } - if(gun == null) - return null; + if(gun.isEmpty()) + return ItemStack.EMPTY; ItemStack lens = ItemManaGun.getLens(gun); ItemManaGun.setLens(gun, null); @@ -70,9 +71,10 @@ public class ManaGunClipRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java index d4f69a68f..e644301e1 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java @@ -31,7 +31,7 @@ public class ManaGunLensRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null) foundGun = true; @@ -48,14 +48,15 @@ public class ManaGunLensRecipe implements IRecipe { return foundLens && foundGun; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack lens = null; - ItemStack gun = null; + ItemStack lens = ItemStack.EMPTY; + ItemStack gun = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemManaGun) gun = stack; else if(stack.getItem() instanceof ILens) @@ -63,8 +64,8 @@ public class ManaGunLensRecipe implements IRecipe { } } - if(lens == null || gun == null) - return null; + if(lens.isEmpty() || gun.isEmpty()) + return ItemStack.EMPTY; ItemStack gunCopy = gun.copy(); ItemManaGun.setLens(gunCopy, lens); @@ -78,9 +79,10 @@ public class ManaGunLensRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java index 3b47fedc5..8a6f1d92d 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java @@ -28,7 +28,7 @@ public class ManaGunRemoveLensRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null) foundGun = true; @@ -39,13 +39,14 @@ public class ManaGunRemoveLensRecipe implements IRecipe { return foundGun; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack gun = null; + ItemStack gun = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemManaGun) gun = stack; } @@ -62,9 +63,10 @@ public class ManaGunRemoveLensRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java index 7ae17d6f2..bbcc1c3d0 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java @@ -27,7 +27,7 @@ public class ManaUpgradeRecipe extends ShapedOreRecipe { IManaItem outItem = (IManaItem) out.getItem(); for (int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if (stack != null) { + if (!stack.isEmpty()) { if (stack.getItem() instanceof IManaItem) { IManaItem item = (IManaItem) stack.getItem(); outItem.addMana(out, item.getMana(stack)); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java index 6ead0a3b0..b09676b7f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java @@ -30,11 +30,11 @@ public class PhantomInkRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == ModItems.phantomInk && !foundInk) foundInk = true; else if(!foundItem) { - if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack) == null) + if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack).isEmpty()) foundItem = true; else return false; } else return false; @@ -44,13 +44,14 @@ public class PhantomInkRecipe implements IRecipe { return foundInk && foundItem; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack item = null; + ItemStack item = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof IPhantomInkable && item == null) + if(!stack.isEmpty() && stack.getItem() instanceof IPhantomInkable && item.isEmpty()) item = stack; } @@ -65,9 +66,10 @@ public class PhantomInkRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java index 04370ea53..8a9ae7b2f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpecialFloatingFlowerRecipe.java @@ -31,7 +31,7 @@ public class SpecialFloatingFlowerRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() == Item.getItemFromBlock(ModBlocks.floatingFlower)) foundFloatingFlower = true; @@ -45,18 +45,19 @@ public class SpecialFloatingFlowerRecipe implements IRecipe { return foundFloatingFlower && foundSpecialFlower; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack specialFlower = null; + ItemStack specialFlower = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) + if(!stack.isEmpty() && stack.getItem() == Item.getItemFromBlock(ModBlocks.specialFlower)) specialFlower = stack; } - if(specialFlower == null) - return null; + if(specialFlower.isEmpty()) + return ItemStack.EMPTY; return ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower.getType(specialFlower)); } @@ -66,9 +67,10 @@ public class SpecialFloatingFlowerRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java index 0a7f04733..cc62146e7 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -30,7 +30,7 @@ public class SpellClothRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.isItemEnchanted() && !foundEnchanted && stack.getItem() != ModItems.spellCloth) foundEnchanted = true; @@ -44,19 +44,20 @@ public class SpellClothRecipe implements IRecipe { return foundCloth && foundEnchanted; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack stackToDisenchant = null; + ItemStack stackToDisenchant = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.isItemEnchanted()) { + if(!stack.isEmpty() && stack.isItemEnchanted()) { stackToDisenchant = stack.copy(); break; } } - if(stackToDisenchant == null) - return null; + if(stackToDisenchant.isEmpty()) + return ItemStack.EMPTY; NBTTagCompound cmp = stackToDisenchant.getTagCompound().copy(); cmp.removeTag("ench"); // Remove enchantments @@ -70,9 +71,10 @@ public class SpellClothRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java index 11b53db04..e63b8cb38 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java @@ -30,7 +30,7 @@ public class TerraPickTippingRecipe implements IRecipe { for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { if(stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) foundTerraPick = true; @@ -44,18 +44,19 @@ public class TerraPickTippingRecipe implements IRecipe { return foundTerraPick && foundElementiumPick; } + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { - ItemStack terraPick = null; + ItemStack terraPick = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemTerraPick) + if(!stack.isEmpty() && stack.getItem() instanceof ItemTerraPick) terraPick = stack; } - if(terraPick == null) - return null; + if(terraPick.isEmpty()) + return ItemStack.EMPTY; ItemStack terraPickCopy = terraPick.copy(); ItemTerraPick.setTipped(terraPickCopy); @@ -67,9 +68,10 @@ public class TerraPickTippingRecipe implements IRecipe { return 10; } + @Nonnull @Override public ItemStack getRecipeOutput() { - return null; + return ItemStack.EMPTY; } @Nonnull diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index 010097e4a..102c1cfee 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -464,7 +464,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss { super.dropEquipment(wasRecentlyHit, lootingModifier); for (EntityEquipmentSlot e : EntityEquipmentSlot.values()) { - setItemStackToSlot(e, null); + setItemStackToSlot(e, ItemStack.EMPTY); } // Generate loot table for every single attacking player @@ -606,7 +606,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss { else { for(EntityPlayer player : players) { for(EntityEquipmentSlot e : EntityEquipmentSlot.values()) { - if(e.getSlotType() == EntityEquipmentSlot.Type.ARMOR && player.getItemStackFromSlot(e) != null) { + if(e.getSlotType() == EntityEquipmentSlot.Type.ARMOR && !player.getItemStackFromSlot(e).isEmpty()) { anyWithArmor = true; break; } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java index c215e7195..f1e012139 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java @@ -418,9 +418,9 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst { NBTTagCompound lensCmp = par1nbtTagCompound.getCompoundTag(TAG_LENS_STACK); ItemStack stack = new ItemStack(lensCmp); - if(stack != null) + if(!stack.isEmpty()) setSourceLens(stack); - else setSourceLens(new ItemStack(Blocks.STONE, 0, 0)); + else setSourceLens(ItemStack.EMPTY); int x = par1nbtTagCompound.getInteger(TAG_SPREADER_X); int y = par1nbtTagCompound.getInteger(TAG_SPREADER_Y); diff --git a/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java b/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java index b481675af..9ed2629f0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java +++ b/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java @@ -41,6 +41,8 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.rod.ItemExchangeRod; import vazkii.botania.common.lib.LibItemNames; +import javax.annotation.Nonnull; + public class ItemAstrolabe extends ItemMod { private static final String TAG_BLOCK_NAME = "blockName"; @@ -52,6 +54,7 @@ public class ItemAstrolabe extends ItemMod { setMaxStackSize(1); } + @Nonnull @Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); @@ -78,8 +81,9 @@ public class ItemAstrolabe extends ItemMod { return EnumActionResult.PASS; } + @Nonnull @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) { ItemStack stack = playerIn.getHeldItem(hand); if(playerIn.isSneaking()) { int size = getSize(stack); diff --git a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java index e7e93e75c..19467a1f6 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java +++ b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java @@ -55,9 +55,10 @@ public class ItemBaubleBox extends ItemMod { private static class InvProvider implements ICapabilitySerializable { private final IItemHandler inv = new ItemStackHandler(24) { + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack toInsert, boolean simulate) { - if(toInsert != null && + public ItemStack insertItem(int slot, @Nonnull ItemStack toInsert, boolean simulate) { + if(!toInsert.isEmpty() && (toInsert.getItem() instanceof IManaItem || toInsert.getItem() instanceof IBauble)) return super.insertItem(slot, toInsert, simulate); @@ -66,12 +67,12 @@ public class ItemBaubleBox extends ItemMod { }; @Override - public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; } @Override - public T getCapability(Capability capability, @Nullable EnumFacing facing) { + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inv); else return null; diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java index d2f151bc4..8f10a60cc 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java @@ -165,7 +165,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { continue; add(itemstack, count); - player.inventory.setInventorySlotContents(i, null); + player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } /*int countInHighest = counts[highest]; @@ -187,7 +187,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { int meta = getBlockMeta(par1ItemStack); ItemStack stack = new ItemStack(block, 1, meta); - return super.getItemStackDisplayName(par1ItemStack) + (stack == null || stack.getItem() == null ? "" : " (" + TextFormatting.GREEN + stack.getDisplayName() + TextFormatting.RESET + ")"); + return super.getItemStackDisplayName(par1ItemStack) + (stack.isEmpty() ? "" : " (" + TextFormatting.GREEN + stack.getDisplayName() + TextFormatting.RESET + ")"); } @Nonnull @@ -195,7 +195,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { public ItemStack getContainerItem(@Nonnull ItemStack itemStack) { int count = getBlockCount(itemStack); if(count == 0) - return null; + return ItemStack.EMPTY; int extract = Math.min(64, count); ItemStack copy = itemStack.copy(); @@ -210,7 +210,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider { @Override public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; + return !getContainerItem(stack).isEmpty(); } private boolean setBlock(ItemStack stack, Block block, int meta) { diff --git a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java index 61990ee40..46cb0ba41 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java +++ b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java @@ -102,9 +102,9 @@ public class ItemBottledMana extends ItemMod { for(int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackAt = player.inventory.getStackInSlot(i); if(stackAt != stack) { - if(stackAt != null) + if(!stackAt.isEmpty()) player.entityDropItem(stackAt, 0); - player.inventory.setInventorySlotContents(i, null); + player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } } } @@ -223,6 +223,7 @@ public class ItemBottledMana extends ItemMod { return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } + @Nonnull @Override public ItemStack onItemUseFinish(@Nonnull ItemStack par1ItemStack, World world, EntityLivingBase living) { randomEffect(living, par1ItemStack); diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java index e951d577b..41ff6a677 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java @@ -93,7 +93,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); int segment = getSegmentLookedAt(stack, player); ItemStack itemForPos = getItemForSlot(stack, segment); @@ -176,7 +176,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { if(recipe == null) return false; - if(ItemHandlerHelper.insertItemStacked(inv, recipe[9], true) != null) + if(!ItemHandlerHelper.insertItemStacked(inv, recipe[9], true).isEmpty()) return false; return consumeRecipeIngredients(recipe, inv, null); @@ -210,11 +210,11 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { private static boolean consumeFromInventory(ItemStack stack, IItemHandler inv, EntityPlayer player) { for(int i = 0; i < inv.getSlots(); i++) { ItemStack stackAt = inv.getStackInSlot(i); - if(stackAt != null && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { + if(!stackAt.isEmpty() && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { boolean consume = true; ItemStack container = stackAt.getItem().getContainerItem(stackAt); - if(container != null) { + if(!container.isEmpty()) { if(container == stackAt) consume = false; else { @@ -292,14 +292,14 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { if(slot == 0) return craftingTable; else if(slot >= SEGMENTS) - return null; + return ItemStack.EMPTY; else { NBTTagCompound cmp = getStoredRecipeCompound(stack, slot); if(cmp != null) { ItemStack cmpStack = getLastCraftingItem(cmp, 9); return cmpStack; - } else return null; + } else return ItemStack.EMPTY; } } @@ -317,7 +317,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) { ItemStack stack = event.player.inventory.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemCraftingHalo) + if(!stack.isEmpty() && stack.getItem() instanceof ItemCraftingHalo) saveRecipeToStack(event, stack); } } @@ -327,7 +327,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { NBTTagCompound cmp1 = new NBTTagCompound(); ItemStack result = CraftingManager.getInstance().findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.world); - if(result != null) { + if(!result.isEmpty()) { result.writeToNBT(cmp1); cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1); @@ -335,7 +335,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement { cmp1 = new NBTTagCompound(); ItemStack stackSlot = event.craftMatrix.getStackInSlot(i); - if(stackSlot != null) { + if(!stackSlot.isEmpty()) { ItemStack writeStack = stackSlot.copy(); writeStack.setCount(1); writeStack.writeToNBT(cmp1); diff --git a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java index 4bb5f345d..67b437493 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java +++ b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java @@ -69,9 +69,10 @@ public class ItemFlowerBag extends ItemMod { private static class InvProvider implements ICapabilitySerializable { private final IItemHandler inv = new ItemStackHandler(16) { + @Nonnull @Override - public ItemStack insertItem(int slot, ItemStack toInsert, boolean simulate) { - if(toInsert != null + public ItemStack insertItem(int slot, @Nonnull ItemStack toInsert, boolean simulate) { + if(!toInsert.isEmpty() && toInsert.getItem() == Item.getItemFromBlock(ModBlocks.flower) && toInsert.getItemDamage() == slot) return super.insertItem(slot, toInsert, simulate); @@ -80,12 +81,12 @@ public class ItemFlowerBag extends ItemMod { }; @Override - public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; } @Override - public T getCapability(Capability capability, @Nullable EnumFacing facing) { + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inv); else return null; diff --git a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java index 6bcfb6975..0bb324a92 100644 --- a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java @@ -48,7 +48,7 @@ public class ItemKeepIvy extends ItemMod { List keeps = new ArrayList<>(); for(EntityItem item : event.getDrops()) { ItemStack stack = item.getEntityItem(); - if(stack != null && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) + if(!stack.isEmpty() && ItemNBTHelper.detectNBT(stack) && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) keeps.add(item); } @@ -87,7 +87,7 @@ public class ItemKeepIvy extends ItemMod { for(int i = 0; i < count; i++) { NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i); ItemStack stack = new ItemStack(cmp2); - if(stack != null) { + if(!stack.isEmpty()) { ItemStack copy = stack.copy(); ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); event.player.inventory.addItemStackToInventory(copy); diff --git a/src/main/java/vazkii/botania/common/item/ItemLexicon.java b/src/main/java/vazkii/botania/common/item/ItemLexicon.java index 66a13e1d7..3c0ddfb04 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLexicon.java +++ b/src/main/java/vazkii/botania/common/item/ItemLexicon.java @@ -147,7 +147,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); String force = getForcedPage(stack); if(force != null && !force.isEmpty()) { @@ -241,8 +241,8 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem { } public static String getTitle(ItemStack stack) { - String title = ModItems.lexicon.getItemStackDisplayName(null); - if(stack != null) + String title = ModItems.lexicon.getItemStackDisplayName(ItemStack.EMPTY); + if(!stack.isEmpty()) title = stack.getDisplayName(); String akashicTomeNBT = "akashictome:displayName"; diff --git a/src/main/java/vazkii/botania/common/item/ItemManaGun.java b/src/main/java/vazkii/botania/common/item/ItemManaGun.java index 275dddde6..1bdbd911b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaGun.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaGun.java @@ -77,7 +77,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); int effCd = COOLDOWN; PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE); @@ -260,7 +260,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem { if(cmp != null) { return new ItemStack(cmp); } - return null; + return ItemStack.EMPTY; } public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { @@ -288,7 +288,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem { if(cmp != null) { return new ItemStack(cmp); } - return null; + return ItemStack.EMPTY; } public static List getAllLens(ItemStack stack) { diff --git a/src/main/java/vazkii/botania/common/item/ItemSextant.java b/src/main/java/vazkii/botania/common/item/ItemSextant.java index 6a81ee33e..435316365 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSextant.java +++ b/src/main/java/vazkii/botania/common/item/ItemSextant.java @@ -104,7 +104,7 @@ public class ItemSextant extends ItemMod { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { Botania.proxy.removeSextantMultiblock(); ItemStack stack = player.getHeldItem(hand); diff --git a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java index f933f929c..56b082e19 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java +++ b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java @@ -69,7 +69,7 @@ public class ItemTemperanceStone extends ItemMod { IInventory inv = player.inventory; for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack != null && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) + if(!stack.isEmpty() && stack.getItem() == ModItems.temperanceStone && stack.getItemDamage() == 1) return true; } diff --git a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java index 7a487e440..082edfdcf 100644 --- a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java +++ b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java @@ -58,7 +58,7 @@ public class ItemThornChakram extends ItemMod implements ICraftAchievement { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(!world.isRemote) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java index c337f77ac..00d89ce8f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java @@ -17,6 +17,8 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; +import javax.annotation.Nonnull; + public abstract class ItemElementiumArmor extends ItemManasteelArmor implements IPixieSpawner { public ItemElementiumArmor(EntityEquipmentSlot type, String name) { @@ -36,7 +38,7 @@ public abstract class ItemElementiumArmor extends ItemManasteelArmor implements } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + public boolean getIsRepairable(ItemStack par1ItemStack, @Nonnull ItemStack par2ItemStack) { return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 7 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java index b89424b90..a7d56b4d7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java @@ -80,14 +80,14 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan } @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + public ArmorProperties getProperties(EntityLivingBase player, @Nonnull ItemStack armor, DamageSource source, double damage, int slot) { if(source.isUnblockable()) return new ArmorProperties(0, 0, 0); return new ArmorProperties(0, damageReduceAmount / 25D, armor.getMaxDamage() + 1 - armor.getItemDamage()); } @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + public int getArmorDisplay(EntityPlayer player, @Nonnull ItemStack armor, int slot) { return damageReduceAmount; } @@ -104,7 +104,7 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan } @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + public void damageArmor(EntityLivingBase entity, @Nonnull ItemStack stack, DamageSource source, int damage, int slot) { ToolCommons.damageItem(stack, damage, entity, MANA_PER_DAMAGE); } @@ -118,7 +118,6 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan return ConfigHandler.enableArmorModels ? LibResources.MODEL_MANASTEEL_NEW : slot == EntityEquipmentSlot.LEGS ? LibResources.MODEL_MANASTEEL_1 : LibResources.MODEL_MANASTEEL_0; } - @Nonnull @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, ModelBiped original) { @@ -151,7 +150,7 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + public boolean getIsRepairable(ItemStack par1ItemStack, @Nonnull ItemStack par2ItemStack) { return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 0 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java index d477b655c..05fa886e1 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java @@ -64,7 +64,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchi } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + public boolean getIsRepairable(ItemStack par1ItemStack, @Nonnull ItemStack par2ItemStack) { return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 22 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } @@ -86,7 +86,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchi @Override public boolean hasArmorSetItem(EntityPlayer player, int i) { ItemStack stack = player.inventory.armorInventory.get(3 - i); - if(stack == null) + if(stack.isEmpty()) return false; switch(i) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java index 64da5df2c..e573dc373 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java @@ -52,7 +52,7 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor { } @Override - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { + public boolean getIsRepairable(ItemStack par1ItemStack, @Nonnull ItemStack par2ItemStack) { return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 || super.getIsRepairable(par1ItemStack, par2ItemStack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java index ad711c04b..6341a6e56 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java @@ -128,7 +128,7 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc if(hasArmorSet(player)) { boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(MobEffects.BLINDNESS) && !player.isRiding(); ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); - if(crit && stack != null && stack.getItem() instanceof ItemTerrasteelHelm) { + if(crit && !stack.isEmpty() && stack.getItem() instanceof ItemTerrasteelHelm) { boolean ahrim = hasAncientWill(stack, 0); boolean dharok = hasAncientWill(stack, 1); boolean guthan = hasAncientWill(stack, 2); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java index d4449dbed..e27b94d93 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java @@ -172,7 +172,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt @Override public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; + return !getContainerItem(stack).isEmpty(); } @Nonnull diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index 37cfed80d..e1efed2ad 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -154,7 +154,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.26F, -0.4F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java index b30b966d0..0b6d388b4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java @@ -88,7 +88,7 @@ public class ItemCloudPendant extends CloudPendantShim implements IBaubleRender if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.2F, -0.3F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java index f1a87ae93..03d6d2ac4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java @@ -55,7 +55,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble if(event.getSource().getEntity() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) { EntityPlayer player = (EntityPlayer) event.getSource().getEntity(); ItemStack amulet = BaublesApi.getBaubles(player).getStackInSlot(6); - if(amulet != null && amulet.getItem() == this) { + if(!amulet.isEmpty() && amulet.getItem() == this) { final int cost = 250; if(ManaItemHandler.requestManaExact(amulet, player, cost, false)) { final int range = 20; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java index ef83ac534..d2f6dc872 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java @@ -55,9 +55,9 @@ public class ItemDodgeRing extends ItemBauble { IInventory baublesInv = BaublesApi.getBaubles(mc.player); ItemStack ringStack = baublesInv.getStackInSlot(1); - if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) { + if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) { ringStack = baublesInv.getStackInSlot(2); - if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) + if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) return; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index 92723e747..f4a70d5bc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -282,7 +282,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub private boolean shouldPlayerHaveFlight(EntityPlayer player) { ItemStack armor = BaublesApi.getBaubles(player).getStackInSlot(4); - if(armor != null && armor.getItem() == this) { + if(!armor.isEmpty() && armor.getItem() == this) { int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItemStack(new ItemStack(ModItems.flugelEye))) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java index 54a5d72ee..edf2c4425 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java @@ -51,7 +51,7 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem, IBau for(EntityPlayer player : players) { IInventory inv = BaublesApi.getBaubles(player); ItemStack charm = inv.getStackInSlot(6); - if(charm != null && charm.getItem() instanceof ItemGoddessCharm && ManaItemHandler.requestManaExact(charm, player, COST, true)) { + if(!charm.isEmpty() && charm.getItem() instanceof ItemGoddessCharm && ManaItemHandler.requestManaExact(charm, player, COST, true)) { event.getAffectedBlocks().clear(); return; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java index 0f1bc48c1..4a75afbba 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoldenLaurel.java @@ -46,13 +46,13 @@ public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack headgear = BaublesApi.getBaubles(player).getStackInSlot(4); - if(headgear != null && headgear.getItem() == this) { + if(!headgear.isEmpty() && headgear.getItem() == this) { event.setCanceled(true); player.setHealth(player.getMaxHealth()); player.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 300, 6)); player.sendMessage(new TextComponentTranslation("botaniamisc.savedByLaurel")); player.world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.goldenLaurel, SoundCategory.PLAYERS, 1F, 0.3F); - BaublesApi.getBaubles(player).setInventorySlotContents(4, null); + BaublesApi.getBaubles(player).setInventorySlotContents(4, ItemStack.EMPTY); } } } @@ -66,7 +66,7 @@ public class ItemGoldenLaurel extends ItemBauble implements IBaubleRender { @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.HEAD) { - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); Helper.translateToHeadLevel(player); Helper.defaultTransforms(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index 2379315e6..267dc366a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -61,7 +61,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); IInventory baubles = BaublesApi.getBaubles(player); ItemStack belt = baubles.getStackInSlot(5); - if(belt != null && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { + if(!belt.isEmpty() && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) { ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem(); int cooldown = getCooldown(belt); @@ -138,7 +138,7 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender { public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.translate(0F, armor ? -0.07F : -0.01F, 0F); float s = 1F / 16F; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index 3077c2253..e82a67b9f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -57,7 +57,7 @@ public class ItemIcePendant extends ItemBauble implements IBaubleRender { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.36F, -0.3F, armor ? 0.2F : 0.15F); GlStateManager.rotate(-45F, 0F, 0F, 1F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index e2cdca0ec..e8779a073 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -198,7 +198,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender { for(int l = 0; l < inv.getSlots(); l++) { ItemStack istack = inv.getStackInSlot(l); - if(istack != null && equalStacks(istack, pstack)) + if(!istack.isEmpty() && equalStacks(istack, pstack)) return true; } @@ -230,7 +230,7 @@ public class ItemItemFinder extends ItemBauble implements IBaubleRender { float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); Helper.translateToHeadLevel(player); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.rotate(90F, 0F, 1F, 0F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java index 707713dfc..319cde724 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java @@ -50,7 +50,7 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.scale(0.5, 0.5, 0.5); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 3ddb020a0..38855f3b4 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -62,7 +62,7 @@ public class ItemMagnetRing extends ItemBauble { IInventory inv = BaublesApi.getBaubles(event.getPlayer()); for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack != null && stack.getItem() instanceof ItemMagnetRing) { + if(!stack.isEmpty() && stack.getItem() instanceof ItemMagnetRing) { setCooldown(stack, 100); BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.getPlayer(), i); } @@ -110,7 +110,7 @@ public class ItemMagnetRing extends ItemBauble { return false; ItemStack stack = item.getEntityItem(); - if(stack == null || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(Item.REGISTRY.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) + if(stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(Item.REGISTRY.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack)) return false; BlockPos pos = new BlockPos(item); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java index 74fb4f0a9..d92215532 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java @@ -52,7 +52,7 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.HEAD) { - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.translateToHeadLevel(player); @@ -105,7 +105,7 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm public static boolean hasMonocle(EntityPlayer player) { for(int i = 0; i < 7; i++) { ItemStack stack = BaublesApi.getBaubles(player).getStackInSlot(i); - if(stack != null) { + if(!stack.isEmpty()) { Item item = stack.getItem(); if(item instanceof IBurstViewerBauble) return true; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java index 0b83c310b..630ff2969 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java @@ -43,7 +43,7 @@ public class ItemSuperCloudPendant extends ItemCloudPendant { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.2F, -0.45F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java index c4335ef15..56977b350 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java @@ -61,7 +61,7 @@ public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.scale(0.5, 0.5, 0.5); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java index db53be1f8..c20f20b92 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java @@ -36,7 +36,7 @@ public class ItemSwapRing extends ItemBauble { EntityPlayer player = (EntityPlayer) entity; ItemStack currentStack = player.getHeldItemMainhand(); - if(currentStack == null || !(currentStack.getItem() instanceof ISortableTool)) + if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool)) return; ISortableTool tool = (ISortableTool) currentStack.getItem(); @@ -65,7 +65,7 @@ public class ItemSwapRing extends ItemBauble { for(int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if (stackInSlot != null && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { int priority = toolInSlot.getSortingPriority(stackInSlot); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java index a13175967..a7ea23275 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java @@ -81,7 +81,7 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem, IBaubleR if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); - boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null; + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); double scale = 0.6; GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.3, -0.6, armor ? -0.18 : -0.12); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java index 9d9d29c71..24fa7d903 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java @@ -118,7 +118,7 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ItemStack belt = BaublesApi.getBaubles(player).getStackInSlot(3); - if(belt != null && belt.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(belt, player, COST, false)) { + if(!belt.isEmpty() && belt.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(belt, player, COST, false)) { player.motionY += ((ItemTravelBelt) belt.getItem()).jump; player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; } @@ -127,7 +127,7 @@ public class ItemTravelBelt extends ItemBauble implements IBaubleRender, IManaUs private boolean shouldPlayerHaveStepup(EntityPlayer player) { ItemStack armor = BaublesApi.getBaubles(player).getStackInSlot(3); - return armor != null && armor.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(armor, player, COST, false); + return !armor.isEmpty() && armor.getItem() instanceof ItemTravelBelt && ManaItemHandler.requestManaExact(armor, player, COST, false); } @SubscribeEvent diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java index ed7330796..c06260c19 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java @@ -38,7 +38,7 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem { if(player.isInsideOfMaterial(Material.WATER)) { if(player instanceof EntityPlayer) { ItemStack firstRing = BaublesApi.getBaubles((EntityPlayer) player).getStackInSlot(1); - if(firstRing != null && firstRing.getItem() instanceof ItemWaterRing && firstRing != stack) { + if(!firstRing.isEmpty() && firstRing.getItem() instanceof ItemWaterRing && firstRing != stack) { return; } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java index a795d3d8e..dc746a77c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java @@ -36,7 +36,7 @@ public class ItemGlassPick extends ItemManasteelPick { @SubscribeEvent public void onBlockDrops(HarvestDropsEvent event) { - if(event.getHarvester() != null && event.getState() != null && event.getDrops() != null && event.getDrops().isEmpty() && event.getHarvester().getHeldItemMainhand() != null && event.getHarvester().getHeldItemMainhand().getItem() == this && event.getState().getMaterial() == Material.GLASS && event.getState().getBlock().canSilkHarvest(event.getWorld(), event.getPos(), event.getState(), event.getHarvester())) + if(event.getHarvester() != null && event.getState() != null && event.getDrops() != null && event.getDrops().isEmpty() && !event.getHarvester().getHeldItemMainhand().isEmpty() && event.getHarvester().getHeldItemMainhand().getItem() == this && event.getState().getMaterial() == Material.GLASS && event.getState().getBlock().canSilkHarvest(event.getWorld(), event.getPos(), event.getState(), event.getHarvester())) event.getDrops().add(new ItemStack(event.getState().getBlock(), 1, event.getState().getBlock().getMetaFromState(event.getState()))); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java index 41cf91fc6..e3084f977 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/bow/ItemLivingwoodBow.java @@ -72,7 +72,7 @@ public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem, IModel else { ItemStack itemstack = entityIn.getActiveItemStack(); - return itemstack != null && itemstack.getItem() instanceof ItemLivingwoodBow ? (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F; + return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemLivingwoodBow ? (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F; } }); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java index 9b439e430..250206279 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java @@ -38,7 +38,7 @@ public class ItemElementiumAxe extends ItemManasteelAxe { public void onEntityDrops(LivingDropsEvent event) { if(event.isRecentlyHit() && event.getSource().getEntity() != null && event.getSource().getEntity() instanceof EntityPlayer) { ItemStack weapon = ((EntityPlayer) event.getSource().getEntity()).getHeldItemMainhand(); - if(weapon != null && weapon.getItem() == this) { + if(!weapon.isEmpty() && weapon.getItem() == this) { Random rand = event.getEntityLiving().world.rand; int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, weapon); diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java index ad31db14b..c8e28c650 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumPick.java @@ -23,7 +23,7 @@ public class ItemElementiumPick extends ItemManasteelPick { public void onHarvestDrops(HarvestDropsEvent event) { if(event.getHarvester() != null) { ItemStack stack = event.getHarvester().getHeldItemMainhand(); - if(stack != null && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { + if(!stack.isEmpty() && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { for(int i = 0; i < event.getDrops().size(); i++) { ItemStack drop = event.getDrops().get(i); if(drop != null) { @@ -40,7 +40,7 @@ public class ItemElementiumPick extends ItemManasteelPick { } private static boolean isDisposable(ItemStack stack) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return false; for(int id : OreDictionary.getOreIDs(stack)) { diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java index d024a0ee1..4bacecaf0 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java @@ -105,7 +105,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if(stack.getItemDamage() == 15) { if(!player.capabilities.isCreativeMode) @@ -159,7 +159,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve @Nonnull @Override public ItemStack getContainerItem(@Nonnull ItemStack itemStack) { - return itemStack.getItemDamage() == 11 ? itemStack.copy() : null; + return itemStack.getItemDamage() == 11 ? itemStack.copy() : ItemStack.EMPTY; } @Override diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java index 21cb6d206..848b67db1 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemAesirRing.java @@ -54,9 +54,9 @@ public class ItemAesirRing extends ItemRelicBauble implements IWireframeCoordina @SubscribeEvent public void onDropped(ItemTossEvent event) { - if(event.getEntityItem() != null && event.getEntityItem().getEntityItem() != null && !event.getEntityItem().world.isRemote) { + if(event.getEntityItem() != null && !event.getEntityItem().getEntityItem().isEmpty() && !event.getEntityItem().world.isRemote) { ItemStack stack = event.getEntityItem().getEntityItem(); - if(stack.getItem() != null && stack.getItem() == this) { + if(stack.getItem() == this) { event.getEntityItem().setDead(); UUID user = getSoulbindUUID(stack); diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java index 96073d198..5fbc4de70 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java @@ -85,6 +85,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } + @Nonnull @Override public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World world, EntityLivingBase living) { if(!(living instanceof EntityPlayer)) diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java index 76f4e2144..42b01e2c9 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java @@ -251,7 +251,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra List providers = new ArrayList<>(); for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { ItemStack invStack = inv.getStackInSlot(i); - if(invStack == null) + if(invStack.isEmpty()) continue; Item item = invStack.getItem(); diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java index d067d87fd..fe91bc4b9 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java @@ -185,7 +185,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem { public static void leftClick(EntityPlayer player) { ItemStack stack = player.getHeldItemMainhand(); - if(stack != null && stack.getItem() == ModItems.gravityRod) { + if(!stack.isEmpty() && stack.getItem() == ModItems.gravityRod) { int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); ItemNBTHelper.getDouble(stack, TAG_DIST, -1); Entity item; diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java index cc446955f..7e31c6a84 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java @@ -133,7 +133,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi @Override public boolean hasContainerItem(ItemStack stack) { - return getContainerItem(stack) != null; + return !getContainerItem(stack).isEmpty(); } @Override diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java index 344d6ca84..895bb7cc2 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java @@ -64,7 +64,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem { @Nonnull @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { player.setActiveHand(hand); return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } @@ -85,7 +85,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem { ItemStack blockStack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack); - if(result != null && result.getItem() instanceof ItemBlock) { + if(!result.isEmpty() && result.getItem() instanceof ItemBlock) { boolean decremented = false; if(playerData.containsKey(p)) { diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java index 2ac2b48a1..452df7924 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageBrew.java @@ -82,7 +82,7 @@ public class PageBrew extends PageRecipe implements ITwoNamedPage { @SideOnly(Side.CLIENT) public void renderItemAtLinePos(IGuiLexiconEntry gui, int offset, int pos, int yPos, ItemStack stack) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return; stack = stack.copy(); diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java index a3031fdc1..812ddc7d7 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageElvenRecipe.java @@ -83,7 +83,7 @@ public class PageElvenRecipe extends PageRecipe { @SideOnly(Side.CLIENT) public void renderItemAtInputPos(IGuiLexiconEntry gui, int x, ItemStack stack) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return; stack = stack.copy(); @@ -101,7 +101,7 @@ public class PageElvenRecipe extends PageRecipe { @SideOnly(Side.CLIENT) public void renderItemAtOutputPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return; stack = stack.copy(); diff --git a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java index 9ebb7223d..b6e5d41c5 100644 --- a/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java +++ b/src/main/java/vazkii/botania/common/lexicon/page/PageRecipe.java @@ -99,7 +99,7 @@ public class PageRecipe extends LexiconPage { @SideOnly(Side.CLIENT) public void renderItemAtAngle(IGuiLexiconEntry gui, float angle, ItemStack stack) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return; ItemStack workStack = stack.copy(); @@ -117,7 +117,7 @@ public class PageRecipe extends LexiconPage { @SideOnly(Side.CLIENT) public void renderItemAtGridPos(IGuiLexiconEntry gui, int x, int y, ItemStack stack, boolean accountForContainer) { - if(stack == null || stack.getItem() == null) + if(stack.isEmpty()) return; stack = stack.copy(); @@ -172,7 +172,7 @@ public class PageRecipe extends LexiconPage { if(accountForContainer) { ItemStack containerStack = stack.getItem().getContainerItem(stack); - if(containerStack != null && containerStack.getItem() != null) + if(!containerStack.isEmpty()) tooltipContainerStack = containerStack; } } diff --git a/src/main/java/vazkii/botania/common/network/PacketDodge.java b/src/main/java/vazkii/botania/common/network/PacketDodge.java index e13ad249d..336d66074 100644 --- a/src/main/java/vazkii/botania/common/network/PacketDodge.java +++ b/src/main/java/vazkii/botania/common/network/PacketDodge.java @@ -41,9 +41,9 @@ public class PacketDodge implements IMessage { IInventory baublesInv = BaublesApi.getBaubles(player); ItemStack ringStack = baublesInv.getStackInSlot(1); - if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) { + if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) { ringStack = baublesInv.getStackInSlot(2); - if(ringStack == null || !(ringStack.getItem() instanceof ItemDodgeRing)) + if(ringStack.isEmpty() || !(ringStack.getItem() instanceof ItemDodgeRing)) ctx.getServerHandler().disconnect("Invalid Dodge Packet"); } diff --git a/src/main/java/vazkii/botania/common/network/PacketJump.java b/src/main/java/vazkii/botania/common/network/PacketJump.java index e03737c34..da7f0867e 100644 --- a/src/main/java/vazkii/botania/common/network/PacketJump.java +++ b/src/main/java/vazkii/botania/common/network/PacketJump.java @@ -43,13 +43,13 @@ public class PacketJump implements IMessage { IInventory baublesInv = BaublesApi.getBaubles(player); ItemStack amuletStack = baublesInv.getStackInSlot(0); - if(amuletStack != null && amuletStack.getItem() instanceof CloudPendantShim) { + if(!amuletStack.isEmpty() && amuletStack.getItem() instanceof CloudPendantShim) { player.addExhaustion(0.3F); player.fallDistance = 0; ItemStack belt = BaublesApi.getBaubles(player).getStackInSlot(3); - if(belt != null && belt.getItem() instanceof ItemTravelBelt) + if(!belt.isEmpty() && belt.getItem() instanceof ItemTravelBelt) player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((CloudPendantShim) amuletStack.getItem()).getMaxAllowedJumps(); } }); diff --git a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java index 722b4ea55..142a0b180 100644 --- a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java +++ b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java @@ -36,7 +36,7 @@ public class WorldTypeSkyblock extends WorldType { } @Override - public int getMinimumSpawnHeight(World world) { + public int getMinimumSpawnHeight(@Nonnull World world) { return 86; }