From da5879b667be990ea990e10aa9c750611bc6ba86 Mon Sep 17 00:00:00 2001 From: Gunther De Wachter Date: Mon, 26 Jun 2017 05:15:25 +0200 Subject: [PATCH] First batch of null -> isEmpty() checks. I most likely still missed a ton of checks... --- .../block/crafting/ItemCraftingStorage.java | 2 +- .../appeng/block/qnb/QnbFormedBakedModel.java | 1 + .../java/appeng/client/gui/AEBaseGui.java | 20 ++--- .../java/appeng/client/gui/AEBaseMEGui.java | 4 +- .../java/appeng/client/gui/Size1Slot.java | 2 +- .../gui/implementations/GuiCellWorkbench.java | 2 +- .../gui/implementations/GuiCraftAmount.java | 8 +- .../implementations/GuiCraftingStatus.java | 12 +-- src/main/java/appeng/client/me/ItemRepo.java | 2 +- .../appeng/client/me/SlotDisconnected.java | 4 +- src/main/java/appeng/client/me/SlotME.java | 6 +- .../client/render/StackSizeRenderer.java | 2 +- .../client/render/tesr/InscriberTESR.java | 10 +-- .../appeng/container/AEBaseContainer.java | 80 +++++++++---------- .../ContainerCellWorkbench.java | 4 +- .../implementations/ContainerInscriber.java | 20 ++--- .../ContainerInterfaceTerminal.java | 34 ++++---- .../implementations/ContainerMAC.java | 2 +- .../ContainerMEPortableCell.java | 2 +- .../ContainerNetworkStatus.java | 2 +- .../implementations/ContainerNetworkTool.java | 2 +- .../implementations/ContainerPatternTerm.java | 30 +++---- .../implementations/ContainerQuartzKnife.java | 6 +- .../ContainerSecurityStation.java | 6 +- .../implementations/ContainerStorageBus.java | 4 +- .../implementations/ContainerUpgradeable.java | 6 +- .../implementations/ContainerWireless.java | 2 +- .../container/slot/AppEngCraftingSlot.java | 6 +- .../appeng/container/slot/AppEngSlot.java | 2 +- .../container/slot/OptionalSlotFake.java | 2 +- .../slot/OptionalSlotFakeTypeOnly.java | 2 +- .../container/slot/SlotCraftingTerm.java | 18 ++--- .../java/appeng/container/slot/SlotFake.java | 2 +- .../container/slot/SlotFakeTypeOnly.java | 2 +- .../container/slot/SlotInaccessible.java | 8 +- .../container/slot/SlotRestrictedInput.java | 6 +- .../core/api/imc/IMCBlackListSpatial.java | 2 +- .../appeng/core/api/imc/IMCP2PAttunement.java | 2 +- .../core/features/ColoredItemDefinition.java | 2 +- .../registries/cell/CellRegistry.java | 6 +- .../registries/cell/CreativeCellHandler.java | 4 +- .../grinder/GrinderRecipeManager.java | 2 +- .../inscriber/InscriberRegistry.java | 4 +- .../java/appeng/core/stats/Achievements.java | 2 +- src/main/java/appeng/core/sync/GuiBridge.java | 8 +- .../appeng/core/sync/packets/PacketClick.java | 2 +- .../sync/packets/PacketInventoryAction.java | 2 +- .../core/sync/packets/PacketJEIRecipe.java | 16 ++-- .../appeng/crafting/CraftingTreeProcess.java | 8 +- .../java/appeng/debug/TileCubeGenerator.java | 8 +- src/main/java/appeng/debug/TileItemGen.java | 6 +- .../decorative/solid/BlockSkyStone.java | 2 +- .../java/appeng/facade/FacadeContainer.java | 2 +- src/main/java/appeng/facade/FacadePart.java | 4 +- .../java/appeng/helpers/DualityInterface.java | 54 ++++++------- .../appeng/helpers/MultiCraftingTracker.java | 2 +- .../modules/jei/FacadeRecipeWrapper.java | 8 +- .../modules/jei/InscriberRecipeWrapper.java | 4 +- .../integration/modules/jei/JEIPlugin.java | 8 +- .../appeng/items/materials/ItemMaterial.java | 6 +- .../appeng/items/misc/ItemEncodedPattern.java | 4 +- .../items/storage/ItemBasicStorageCell.java | 8 +- .../appeng/items/storage/ItemViewCell.java | 4 +- .../implementations/CraftingCPUCluster.java | 24 +++--- .../me/storage/CellInventoryHandler.java | 4 +- .../me/storage/CreativeCellInventory.java | 2 +- .../me/storage/MEMonitorIInventory.java | 22 ++--- .../java/appeng/parts/CableBusContainer.java | 4 +- .../parts/automation/PartImportBus.java | 10 +-- .../parts/automation/PartUpgradeable.java | 2 +- .../parts/automation/UpgradeInventory.java | 2 +- .../appeng/parts/misc/ItemHandlerAdapter.java | 31 ++++--- .../appeng/parts/misc/PartCableAnchor.java | 2 +- .../java/appeng/parts/p2p/PartP2PTunnel.java | 18 ++--- .../parts/reporting/AbstractPartTerminal.java | 2 +- .../reporting/PartConversionMonitor.java | 6 +- .../parts/reporting/PartCraftingTerminal.java | 2 +- .../parts/reporting/PartPatternTerminal.java | 10 +-- .../recipes/game/DisassembleRecipe.java | 2 +- .../appeng/recipes/game/FacadeRecipe.java | 2 +- .../appeng/recipes/game/ShapedRecipe.java | 6 +- .../appeng/recipes/game/ShapelessRecipe.java | 4 +- .../appeng/recipes/handlers/Inscribe.java | 4 +- .../java/appeng/recipes/handlers/Press.java | 4 +- src/main/java/appeng/server/ServerHelper.java | 2 +- src/main/java/appeng/tile/AEBaseInvTile.java | 2 +- src/main/java/appeng/tile/AEBaseTile.java | 2 +- .../tile/crafting/TileMolecularAssembler.java | 44 +++++----- .../appeng/tile/grindstone/TileGrinder.java | 4 +- .../inventory/AppEngInternalAEInventory.java | 20 ++--- .../inventory/AppEngInternalInventory.java | 20 ++--- .../appeng/tile/misc/TileCellWorkbench.java | 10 +-- .../java/appeng/tile/misc/TileCharger.java | 8 +- .../java/appeng/tile/misc/TileCondenser.java | 20 ++--- .../java/appeng/tile/misc/TileInscriber.java | 52 ++++++------ .../tile/misc/TileVibrationChamber.java | 4 +- .../appeng/tile/qnb/TileQuantumBridge.java | 4 +- .../tile/spatial/TileSpatialIOPort.java | 6 +- .../java/appeng/tile/storage/TileChest.java | 12 +-- .../java/appeng/tile/storage/TileDrive.java | 4 +- .../java/appeng/tile/storage/TileIOPort.java | 6 +- src/main/java/appeng/util/Platform.java | 16 ++-- .../util/helpers/ItemComparisonHelper.java | 14 +++- .../appeng/util/inv/AdaptorIInventory.java | 39 ++++----- .../appeng/util/inv/AdaptorItemHandler.java | 48 +++++------ .../java/appeng/util/inv/AdaptorList.java | 30 +++---- .../appeng/util/inv/AdaptorPlayerHand.java | 62 +++++++------- src/main/java/appeng/util/inv/IMEAdaptor.java | 18 ++--- .../appeng/util/inv/IMEAdaptorIterator.java | 3 +- .../util/inv/IMEInventoryDestination.java | 2 +- .../appeng/util/inv/ItemHandlerIterator.java | 2 +- src/main/java/appeng/util/inv/ItemSlot.java | 6 +- .../util/inv/WrapperChainedInventory.java | 6 +- .../util/inv/WrapperMCISidedInventory.java | 2 +- .../java/appeng/util/item/AEFluidStack.java | 2 +- .../java/appeng/util/item/AEItemStack.java | 12 +-- .../java/appeng/worldgen/MeteoritePlacer.java | 16 ++-- 117 files changed, 594 insertions(+), 570 deletions(-) diff --git a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java index 091ad44fd..b242147b5 100644 --- a/src/main/java/appeng/block/crafting/ItemCraftingStorage.java +++ b/src/main/java/appeng/block/crafting/ItemCraftingStorage.java @@ -39,7 +39,7 @@ public class ItemCraftingStorage extends AEBaseItemBlock @Override public ItemStack getContainerItem( final ItemStack itemStack ) { - return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( null ); + return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( ItemStack.EMPTY ); } @Override diff --git a/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java b/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java index 4109ce340..2e6b4990e 100644 --- a/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java +++ b/src/main/java/appeng/block/qnb/QnbFormedBakedModel.java @@ -18,6 +18,7 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.property.IExtendedBlockState; diff --git a/src/main/java/appeng/client/gui/AEBaseGui.java b/src/main/java/appeng/client/gui/AEBaseGui.java index 7f4ec8236..3c9bcbe77 100644 --- a/src/main/java/appeng/client/gui/AEBaseGui.java +++ b/src/main/java/appeng/client/gui/AEBaseGui.java @@ -92,7 +92,7 @@ public abstract class AEBaseGui extends GuiContainer private GuiScrollbar myScrollBar = null; private boolean disableShiftClick = false; private Stopwatch dbl_clickTimer = Stopwatch.createStarted(); - private ItemStack dbl_whichItem; + private ItemStack dbl_whichItem = ItemStack.EMPTY; private Slot bl_clicked; private boolean subGui; @@ -304,7 +304,7 @@ public abstract class AEBaseGui extends GuiContainer this.getScrollBar().click( this, x - this.guiLeft, y - this.guiTop ); } - if( slot instanceof SlotFake && itemstack != null ) + if( slot instanceof SlotFake && !itemstack.isEmpty() ) { this.drag_click.add( slot ); if( this.drag_click.size() > 1 ) @@ -453,7 +453,7 @@ public abstract class AEBaseGui extends GuiContainer action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; stack = ( (SlotME) slot ).getAEStack(); - if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel()) + if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel() ) { action = InventoryAction.AUTO_CRAFT; } @@ -499,21 +499,21 @@ public abstract class AEBaseGui extends GuiContainer { this.disableShiftClick = true; - if( this.dbl_whichItem == null || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 ) + if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 ) { // some simple double click logic. this.bl_clicked = slot; this.dbl_clickTimer = Stopwatch.createStarted(); if( slot != null ) { - this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null; + this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY; } else { - this.dbl_whichItem = null; + this.dbl_whichItem = ItemStack.EMPTY; } } - else if( this.dbl_whichItem != null ) + else if( !this.dbl_whichItem.isEmpty() ) { // a replica of the weird broken vanilla feature. @@ -540,7 +540,7 @@ public abstract class AEBaseGui extends GuiContainer { final Slot theSlot = this.getSlotUnderMouse(); - if( this.mc.player.inventory.getItemStack() == null && theSlot != null ) + if( this.mc.player.inventory.getItemStack().isEmpty() && theSlot != null ) { for( int j = 0; j < 9; ++j ) { @@ -728,7 +728,7 @@ public abstract class AEBaseGui extends GuiContainer try { final ItemStack is = s.getStack(); - if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is == null ) && ( ( (AppEngSlot) s ).shouldDisplay() ) ) + if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is.isEmpty() ) && ( ( (AppEngSlot) s ).shouldDisplay() ) ) { final AppEngSlot aes = (AppEngSlot) s; if( aes.getIcon() >= 0 ) @@ -776,7 +776,7 @@ public abstract class AEBaseGui extends GuiContainer } } - if( is != null && s instanceof AppEngSlot ) + if( !is.isEmpty() && s instanceof AppEngSlot ) { if( ( (AppEngSlot) s ).getIsValid() == hasCalculatedValidness.NotAvailable ) { diff --git a/src/main/java/appeng/client/gui/AEBaseMEGui.java b/src/main/java/appeng/client/gui/AEBaseMEGui.java index 857578e97..0e6b1df46 100644 --- a/src/main/java/appeng/client/gui/AEBaseMEGui.java +++ b/src/main/java/appeng/client/gui/AEBaseMEGui.java @@ -44,7 +44,7 @@ public abstract class AEBaseMEGui extends AEBaseGui public List handleItemTooltip( final ItemStack stack, final int mouseX, final int mouseY, final List currentToolTip ) { - if( stack != null ) + if( !stack.isEmpty() ) { final Slot s = this.getSlot( mouseX, mouseY ); if( s instanceof SlotME ) @@ -101,7 +101,7 @@ public abstract class AEBaseMEGui extends AEBaseGui protected void renderToolTip( final ItemStack stack, final int x, final int y ) { final Slot s = this.getSlot( x, y ); - if( s instanceof SlotME && stack != null ) + if( s instanceof SlotME && !stack.isEmpty() ) { final int BigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999; diff --git a/src/main/java/appeng/client/gui/Size1Slot.java b/src/main/java/appeng/client/gui/Size1Slot.java index 1aadf38bf..18d346b35 100644 --- a/src/main/java/appeng/client/gui/Size1Slot.java +++ b/src/main/java/appeng/client/gui/Size1Slot.java @@ -33,7 +33,7 @@ class Size1Slot extends Slot public ItemStack getStack() { ItemStack orgStack = delegate.getStack(); - if( orgStack != null ) + if( !orgStack.isEmpty() ) { ItemStack modifiedStack = orgStack.copy(); modifiedStack.setCount( 1 ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java index dcfc35477..63c218cc7 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java @@ -140,7 +140,7 @@ public class GuiCellWorkbench extends GuiUpgradeable for( int x = 0; x < inv.getSizeInventory(); x++ ) { final ItemStack is = inv.getStackInSlot( x ); - if( is != null && is.getItem() instanceof IUpgradeModule ) + if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) { if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java index 299b9912f..3b0324f9c 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java @@ -107,23 +107,23 @@ public class GuiCraftAmount extends AEBaseGui if( target instanceof PartTerminal ) { - myIcon = parts.terminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_ME; } if( target instanceof PartCraftingTerminal ) { - myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL; } if( target instanceof PartPatternTerminal ) { - myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } - if( this.originalGui != null && myIcon != null ) + if( this.originalGui != null && !myIcon.isEmpty() ) { this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) ); } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index 7023c68cc..4ac1edcd4 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -57,7 +57,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU private GuiTabButton originalGuiBtn; private GuiBridge originalGui; - private ItemStack myIcon = null; + private ItemStack myIcon = ItemStack.EMPTY; public GuiCraftingStatus( final InventoryPlayer inventoryPlayer, final ITerminalHost te ) { @@ -70,28 +70,28 @@ public class GuiCraftingStatus extends GuiCraftingCPU if( target instanceof WirelessTerminalGuiObject ) { - myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( null ); + myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_WIRELESS_TERM; } if( target instanceof PartTerminal ) { - myIcon = parts.terminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_ME; } if( target instanceof PartCraftingTerminal ) { - myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL; } if( target instanceof PartPatternTerminal ) { - myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null ); + myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } @@ -131,7 +131,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU // selectCPU.enabled = false; this.buttonList.add( this.selectCPU ); - if( this.myIcon != null ) + if( !this.myIcon.isEmpty() ) { this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), this.itemRender ) ); this.originalGuiBtn.setHideEdge( 13 ); diff --git a/src/main/java/appeng/client/me/ItemRepo.java b/src/main/java/appeng/client/me/ItemRepo.java index 57313b600..bfb68fd4f 100644 --- a/src/main/java/appeng/client/me/ItemRepo.java +++ b/src/main/java/appeng/client/me/ItemRepo.java @@ -84,7 +84,7 @@ public class ItemRepo if( idx >= this.dsp.size() ) { - return null; + return ItemStack.EMPTY; } return this.dsp.get( idx ); } diff --git a/src/main/java/appeng/client/me/SlotDisconnected.java b/src/main/java/appeng/client/me/SlotDisconnected.java index 68186a2fb..4730ecd3a 100644 --- a/src/main/java/appeng/client/me/SlotDisconnected.java +++ b/src/main/java/appeng/client/me/SlotDisconnected.java @@ -63,11 +63,11 @@ public class SlotDisconnected extends AppEngSlot if( Platform.isClient() ) { final ItemStack is = super.getStack(); - if( is != null && is.getItem() instanceof ItemEncodedPattern ) + if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern ) { final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); final ItemStack out = iep.getOutput( is ); - if( out != null ) + if( !out.isEmpty() ) { return out; } diff --git a/src/main/java/appeng/client/me/SlotME.java b/src/main/java/appeng/client/me/SlotME.java index 31826222c..d0fc27768 100644 --- a/src/main/java/appeng/client/me/SlotME.java +++ b/src/main/java/appeng/client/me/SlotME.java @@ -60,7 +60,7 @@ public class SlotME extends Slot { return this.mySlot.getStack(); } - return null; + return ItemStack.EMPTY; } @Override @@ -68,7 +68,7 @@ public class SlotME extends Slot { if( this.mySlot.hasPower() ) { - return this.getStack() != null; + return !this.getStack().isEmpty(); } return false; } @@ -88,7 +88,7 @@ public class SlotME extends Slot @Override public ItemStack decrStackSize( final int par1 ) { - return null; + return ItemStack.EMPTY; } @Override diff --git a/src/main/java/appeng/client/render/StackSizeRenderer.java b/src/main/java/appeng/client/render/StackSizeRenderer.java index 8e5e058a9..d13a149c1 100644 --- a/src/main/java/appeng/client/render/StackSizeRenderer.java +++ b/src/main/java/appeng/client/render/StackSizeRenderer.java @@ -44,7 +44,7 @@ public class StackSizeRenderer public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, ItemStack is, int xPos, int yPos ) { - if( is != null ) + if( !is.isEmpty() ) { final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f; final float inverseScaleFactor = 1.0f / scaleFactor; diff --git a/src/main/java/appeng/client/render/tesr/InscriberTESR.java b/src/main/java/appeng/client/render/tesr/InscriberTESR.java index 80d2e98e0..93aae2e12 100644 --- a/src/main/java/appeng/client/render/tesr/InscriberTESR.java +++ b/src/main/java/appeng/client/render/tesr/InscriberTESR.java @@ -132,15 +132,15 @@ public class InscriberTESR extends TileEntitySpecialRenderer GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); int items = 0; - if( tile.getStackInSlot( 0 ) != null ) + if( !tile.getStackInSlot( 0 ).isEmpty() ) { items++; } - if( tile.getStackInSlot( 1 ) != null ) + if( !tile.getStackInSlot( 1 ).isEmpty() ) { items++; } - if( tile.getStackInSlot( 2 ) != null ) + if( !tile.getStackInSlot( 2 ).isEmpty() ) { items++; } @@ -151,7 +151,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer { ItemStack is = tile.getStackInSlot( 3 ); - if( is == null ) + if( is.isEmpty() ) { final IInscriberRecipe ir = tile.getTask(); if( ir != null ) @@ -177,7 +177,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer private void renderItem( ItemStack sis, final float o, final AEBaseTile tile, final VertexBuffer tess, final double x, final double y, final double z ) { - if( sis != null ) + if( !sis.isEmpty() ) { sis = sis.copy(); diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index 895c732b3..3d5be8130 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -224,8 +224,8 @@ public abstract class AEBaseContainer extends Container // client doesn't need to re-send, makes for lower overhead rapid packets. if( Platform.isClient() ) { - final ItemStack a = stack == null ? null : stack.getItemStack(); - final ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack(); + final ItemStack a = stack == null ? ItemStack.EMPTY : stack.getItemStack(); + final ItemStack b = this.clientRequestedTargetItem == null ? ItemStack.EMPTY : this.clientRequestedTargetItem.getItemStack(); if( Platform.itemComparisons().isSameItem( a, b ) ) { @@ -483,7 +483,7 @@ public abstract class AEBaseContainer extends Container { ItemStack tis = clickSlot.getStack(); - if( tis == null ) + if( tis.isEmpty() ) { return ItemStack.EMPTY; } @@ -533,7 +533,7 @@ public abstract class AEBaseContainer extends Container */ if( selectedSlots.isEmpty() && clickSlot.isPlayerSide() ) { - if( tis != null ) + if( !tis.isEmpty() ) { // target slots in the container... for( final Object inventorySlot : this.inventorySlots ) @@ -547,7 +547,7 @@ public abstract class AEBaseContainer extends Container { break; } - else if( destination == null ) + else if( destination.isEmpty() ) { cs.putStack( tis.copy() ); cs.onSlotChanged(); @@ -559,7 +559,7 @@ public abstract class AEBaseContainer extends Container } } - if( tis != null ) + if( !tis.isEmpty() ) { // find partials.. for( final Slot d : selectedSlots ) @@ -595,7 +595,7 @@ public abstract class AEBaseContainer extends Container if( tis.getCount() <= 0 ) { - clickSlot.putStack( null ); + clickSlot.putStack( ItemStack.EMPTY ); d.onSlotChanged(); // if ( hasMETiles ) updateClient(); @@ -647,7 +647,7 @@ public abstract class AEBaseContainer extends Container if( tis.getCount() <= 0 ) { - clickSlot.putStack( null ); + clickSlot.putStack( ItemStack.EMPTY ); d.onSlotChanged(); // if ( worldEntity != null ) @@ -683,7 +683,7 @@ public abstract class AEBaseContainer extends Container if( tis.getCount() <= 0 ) { - clickSlot.putStack( null ); + clickSlot.putStack( ItemStack.EMPTY ); d.onSlotChanged(); // if ( worldEntity != null ) @@ -703,7 +703,7 @@ public abstract class AEBaseContainer extends Container } } - clickSlot.putStack( tis != null ? tis.copy() : null ); + clickSlot.putStack( !tis.isEmpty() ? tis.copy() : ItemStack.EMPTY ); } this.updateSlot( clickSlot ); @@ -766,9 +766,9 @@ public abstract class AEBaseContainer extends Container { case PICKUP_OR_SET_DOWN: - if( hand == null ) + if( hand.isEmpty() ) { - s.putStack( null ); + s.putStack( ItemStack.EMPTY ); } else { @@ -778,7 +778,7 @@ public abstract class AEBaseContainer extends Container break; case PLACE_SINGLE: - if( hand != null ) + if( !hand.isEmpty() ) { final ItemStack is = hand.copy(); is.setCount( 1 ); @@ -789,9 +789,9 @@ public abstract class AEBaseContainer extends Container case SPLIT_OR_PLACE_SINGLE: ItemStack is = s.getStack(); - if( is != null ) + if( !is.isEmpty() ) { - if( hand == null ) + if( hand.isEmpty() ) { is.setCount( Math.max( 1, is.getCount() - 1 ) ); } @@ -807,7 +807,7 @@ public abstract class AEBaseContainer extends Container s.putStack( is ); } - else if( hand != null ) + else if( !hand.isEmpty() ) { is = hand.copy(); is.setCount( 1 ); @@ -866,7 +866,7 @@ public abstract class AEBaseContainer extends Container myItem.setCount( (int) ais.getStackSize() ); myItem = adp.simulateAdd( myItem ); - if( myItem != null ) + if( !myItem.isEmpty() ) { ais.setStackSize( ais.getStackSize() - myItem.getCount() ); } @@ -887,7 +887,7 @@ public abstract class AEBaseContainer extends Container final int releaseQty = 1; final ItemStack isg = player.inventory.getItemStack(); - if( isg != null && releaseQty > 0 ) + if( !isg.isEmpty() && releaseQty > 0 ) { IAEItemStack ais = AEApi.instance().storage().createItemStack( isg ); ais.setStackSize( 1 ); @@ -899,7 +899,7 @@ public abstract class AEBaseContainer extends Container final InventoryAdaptor ia = new AdaptorPlayerHand( player ); final ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null ); - if( fail == null ) + if( fail.isEmpty() ) { this.getCellInventory().extractItems( extracted, Actionable.MODULATE, this.getActionSource() ); } @@ -921,7 +921,7 @@ public abstract class AEBaseContainer extends Container int liftQty = 1; final ItemStack item = player.inventory.getItemStack(); - if( item != null ) + if( !item.isEmpty() ) { if( item.getCount() >= item.getMaxStackSize() ) { @@ -943,7 +943,7 @@ public abstract class AEBaseContainer extends Container final InventoryAdaptor ia = new AdaptorPlayerHand( player ); final ItemStack fail = ia.addItems( ais.getItemStack() ); - if( fail != null ) + if( !fail.isEmpty() ) { this.getCellInventory().injectItems( ais, Actionable.MODULATE, this.getActionSource() ); } @@ -959,7 +959,7 @@ public abstract class AEBaseContainer extends Container return; } - if( player.inventory.getItemStack() == null ) + if( player.inventory.getItemStack().isEmpty() ) { if( slotItem != null ) { @@ -972,7 +972,7 @@ public abstract class AEBaseContainer extends Container } else { - player.inventory.setItemStack( null ); + player.inventory.setItemStack( ItemStack.EMPTY ); } this.updateHeld( player ); } @@ -987,7 +987,7 @@ public abstract class AEBaseContainer extends Container } else { - player.inventory.setItemStack( null ); + player.inventory.setItemStack( ItemStack.EMPTY ); } this.updateHeld( player ); } @@ -999,7 +999,7 @@ public abstract class AEBaseContainer extends Container return; } - if( player.inventory.getItemStack() == null ) + if( player.inventory.getItemStack().isEmpty() ) { if( slotItem != null ) { @@ -1021,7 +1021,7 @@ public abstract class AEBaseContainer extends Container } else { - player.inventory.setItemStack( null ); + player.inventory.setItemStack( ItemStack.EMPTY ); } this.updateHeld( player ); } @@ -1037,7 +1037,7 @@ public abstract class AEBaseContainer extends Container is.setCount( is.getCount() - 1 ); if( is.getCount() <= 0 ) { - player.inventory.setItemStack( null ); + player.inventory.setItemStack( ItemStack.EMPTY ); } this.updateHeld( player ); } @@ -1074,7 +1074,7 @@ public abstract class AEBaseContainer extends Container myItem.setCount( (int) ais.getStackSize() ); myItem = adp.simulateAdd( myItem ); - if( myItem != null ) + if( !myItem.isEmpty() ) { ais.setStackSize( ais.getStackSize() - myItem.getCount() ); } @@ -1123,7 +1123,7 @@ public abstract class AEBaseContainer extends Container this.getActionSource() ); if( ais == null ) { - return null; + return ItemStack.EMPTY; } return ais.getItemStack(); } @@ -1202,42 +1202,42 @@ public abstract class AEBaseContainer extends Container final ItemStack isB = b.getStack(); // something to do? - if( isA == null && isB == null ) + if( isA.isEmpty() && isB.isEmpty() ) { return; } // can take? - if( isA != null && !a.canTakeStack( this.getInventoryPlayer().player ) ) + if( !isA.isEmpty() && !a.canTakeStack( this.getInventoryPlayer().player ) ) { return; } - if( isB != null && !b.canTakeStack( this.getInventoryPlayer().player ) ) + if( !isB.isEmpty() && !b.canTakeStack( this.getInventoryPlayer().player ) ) { return; } // swap valid? - if( isB != null && !a.isItemValid( isB ) ) + if( !isB.isEmpty() && !a.isItemValid( isB ) ) { return; } - if( isA != null && !b.isItemValid( isA ) ) + if( !isA.isEmpty() && !b.isItemValid( isA ) ) { return; } - ItemStack testA = isB == null ? null : isB.copy(); - ItemStack testB = isA == null ? null : isA.copy(); + ItemStack testA = isB.isEmpty() ? ItemStack.EMPTY : isB.copy(); + ItemStack testB = isA.isEmpty() ? ItemStack.EMPTY : isA.copy(); // can put some back? - if( testA != null && testA.getCount() > a.getSlotStackLimit() ) + if( !testA.isEmpty() && testA.getCount() > a.getSlotStackLimit() ) { - if( testB != null ) + if( !testB.isEmpty() ) { return; } @@ -1249,9 +1249,9 @@ public abstract class AEBaseContainer extends Container testB.setCount( totalA - testA.getCount() ); } - if( testB != null && testB.getCount() > b.getSlotStackLimit() ) + if( !testB.isEmpty() && testB.getCount() > b.getSlotStackLimit() ) { - if( testA != null ) + if ( !testA.isEmpty() ) { return; } diff --git a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java index 98b2cdfcd..380755b90 100644 --- a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java +++ b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java @@ -210,7 +210,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable final IInventory inv = this.getUpgradeable().getInventoryByName( "config" ); for( int x = 0; x < inv.getSizeInventory(); x++ ) { - inv.setInventorySlotContents( x, null ); + inv.setInventorySlotContents( x, ItemStack.EMPTY ); } this.detectAndSendChanges(); } @@ -248,7 +248,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable } else { - inv.setInventorySlotContents( x, null ); + inv.setInventorySlotContents( x, ItemStack.EMPTY ); } } diff --git a/src/main/java/appeng/container/implementations/ContainerInscriber.java b/src/main/java/appeng/container/implementations/ContainerInscriber.java index d14ffca50..8b92bb9d5 100644 --- a/src/main/java/appeng/container/implementations/ContainerInscriber.java +++ b/src/main/java/appeng/container/implementations/ContainerInscriber.java @@ -126,11 +126,11 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() ) { - final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( null ) ) ) && // and... - ( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( null ) ) ); + final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... + ( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ); - final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( null ) ) ) && // and... - ( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( null ) ) ); + final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... + ( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ); if( matchA || matchB ) { @@ -151,9 +151,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres } } - if( ( s == this.top && bot != null ) || ( s == this.bottom && top != null ) ) + if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) ) { - ItemStack otherSlot = null; + ItemStack otherSlot = ItemStack.EMPTY; if( s == this.top ) { otherSlot = this.bottom.getStack(); @@ -174,13 +174,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres boolean isValid = false; for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() ) { - if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( null ), otherSlot ) ) + if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( ItemStack.EMPTY ), otherSlot ) ) { - isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( null ) ); + isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ); } - else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( null ), otherSlot ) ) + else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( ItemStack.EMPTY ), otherSlot ) ) { - isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( null ) ); + isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ); } if( isValid ) diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java index c7a110fa1..c65508b21 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java @@ -204,7 +204,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer if( inv != null ) { final ItemStack is = inv.server.getStackInSlot( slot ); - final boolean hasItemInHand = player.inventory.getItemStack() != null; + final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty(); final InventoryAdaptor playerHand = new AdaptorPlayerHand( player ); @@ -220,7 +220,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer if( hasItemInHand ) { ItemStack inSlot = theSlot.getStackInSlot( 0 ); - if( inSlot == null ) + if( inSlot.isEmpty() ) { player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) ); } @@ -229,12 +229,12 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer inSlot = inSlot.copy(); final ItemStack inHand = player.inventory.getItemStack().copy(); - theSlot.setInventorySlotContents( 0, null ); - player.inventory.setItemStack( null ); + theSlot.setInventorySlotContents( 0, ItemStack.EMPTY ); + player.inventory.setItemStack( ItemStack.EMPTY ); player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) ); - if( player.inventory.getItemStack() == null ) + if( player.inventory.getItemStack().isEmpty() ) { player.inventory.setItemStack( inSlot ); } @@ -256,24 +256,24 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer if( hasItemInHand ) { - ItemStack extra = playerHand.removeItems( 1, null, null ); - if( extra != null ) + ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null ); + if( !extra.isEmpty() ) { extra = interfaceSlot.addItems( extra ); } - if( extra != null ) + if( !extra.isEmpty() ) { playerHand.addItems( extra ); } } - else if( is != null ) + else if( !is.isEmpty() ) { - ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, null, null ); - if( extra != null ) + ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, ItemStack.EMPTY, null ); + if( !extra.isEmpty() ) { extra = playerHand.addItems( extra ); } - if( extra != null ) + if( !extra.isEmpty() ) { interfaceSlot.addItems( extra ); } @@ -300,7 +300,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer if( player.capabilities.isCreativeMode && !hasItemInHand ) { - player.inventory.setItemStack( is == null ? null : is.copy() ); + player.inventory.setItemStack( is.isEmpty() ? ItemStack.EMPTY : is.copy() ); } break; @@ -357,12 +357,12 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer private boolean isDifferent( final ItemStack a, final ItemStack b ) { - if( a == null && b == null ) + if( a.isEmpty() && b.isEmpty() ) { return false; } - if( a == null || b == null ) + if( a.isEmpty() || b.isEmpty() ) { return true; } @@ -388,9 +388,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer final ItemStack is = inv.server.getStackInSlot( x + offset ); // "update" client side. - inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() ); + inv.client.setInventorySlotContents( x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() ); - if( is != null ) + if( !is.isEmpty() ) { is.writeToNBT( itemNBT ); } diff --git a/src/main/java/appeng/container/implementations/ContainerMAC.java b/src/main/java/appeng/container/implementations/ContainerMAC.java index b1d92dfd1..c82894423 100644 --- a/src/main/java/appeng/container/implementations/ContainerMAC.java +++ b/src/main/java/appeng/container/implementations/ContainerMAC.java @@ -57,7 +57,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi final IInventory mac = this.getUpgradeable().getInventoryByName( "mac" ); final ItemStack is = mac.getStackInSlot( 10 ); - if( is == null ) + if( is.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java index 563221038..a473208b9 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java +++ b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java @@ -65,7 +65,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable { if( currentItem != this.civ.getItemStack() ) { - if( currentItem != null ) + if( !currentItem.isEmpty() ) { if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) ) { diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java index 94f5479d9..01fa49a58 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java @@ -118,7 +118,7 @@ public class ContainerNetworkStatus extends AEBaseContainer { final IGridBlock blk = machine.getGridBlock(); final ItemStack is = blk.getMachineRepresentation(); - if( is != null && is.getItem() != null ) + if( !is.isEmpty() && is.getItem() != null ) { final IAEItemStack ais = AEItemStack.create( is ); ais.setStackSize( 1 ); diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java index a339ac601..a81d7a499 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java @@ -70,7 +70,7 @@ public class ContainerNetworkTool extends AEBaseContainer if( currentItem != this.toolInv.getItemStack() ) { - if( currentItem != null ) + if( !currentItem.isEmpty() ) { if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) ) { diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index cd00cb7ee..64d5455b8 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -190,14 +190,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA } // first check the output slots, should either be null, or a pattern - if( output != null && !this.isPattern( output ) ) + if( !output.isEmpty() && !this.isPattern( output ) ) { return; } // if nothing is there we should snag a new pattern. - else if( output == null ) + else if( output.isEmpty() ) { output = this.patternSlotIN.getStack(); - if( output == null || !this.isPattern( output ) ) + if( output.isEmpty() || !this.isPattern( output ) ) { return; // no blanks. } @@ -206,7 +206,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA output.setCount( output.getCount() ); if( output.getCount() == 0 ) { - this.patternSlotIN.putStack( null ); + this.patternSlotIN.putStack( ItemStack.EMPTY ); } // add a new encoded pattern. @@ -250,7 +250,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA for( int x = 0; x < this.craftingSlots.length; x++ ) { input[x] = this.craftingSlots[x].getStack(); - if( input[x] != null ) + if( !input[x].isEmpty() ) { hasValue = true; } @@ -270,7 +270,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { final ItemStack out = this.getAndUpdateOutput(); - if( out != null && out.getCount() > 0 ) + if( !out.isEmpty() && out.getCount() > 0 ) { return new ItemStack[] { out }; } @@ -284,7 +284,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { final ItemStack out = outputSlot.getStack(); - if( out != null && out.getCount() > 0 ) + if( !out.isEmpty() && out.getCount() > 0 ) { list.add( out ); hasValue = true; @@ -302,7 +302,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA private boolean isPattern( final ItemStack output ) { - if( output == null ) + if( output.isEmpty() ) { return false; } @@ -357,7 +357,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA inv = playerInv; } - if( inv.simulateAdd( out.getItemStack() ) != null ) + if( !inv.simulateAdd( out.getItemStack() ).isEmpty() ) { return; } @@ -381,7 +381,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA for( int x = 0; x < 9; x++ ) { - ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() ); + ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].getItemStack() ); } final IRecipe r = Platform.findMatchingRecipe( ic, p.world ); @@ -398,7 +398,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA for( int x = 0; x < ic.getSizeInventory(); x++ ) { - if( ic.getStackInSlot( x ) != null ) + if( !ic.getStackInSlot( x ).isEmpty() ) { final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.world, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) ); real.setInventorySlotContents( x, pulled ); @@ -416,7 +416,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) ); - if( failed != null ) + if( !failed.isEmpty() ) { p.dropItem( failed, false ); } @@ -434,7 +434,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA for( int x = 0; x < real.getSizeInventory(); x++ ) { final ItemStack failed = real.getStackInSlot( x ); - if( failed != null ) + if( !failed.isEmpty() ) { this.getCellInventory().injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.getPatternTerminal() ) ); } @@ -498,12 +498,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { for( final Slot s : this.craftingSlots ) { - s.putStack( null ); + s.putStack( ItemStack.EMPTY ); } for( final Slot s : this.outputSlots ) { - s.putStack( null ); + s.putStack( ItemStack.EMPTY ); } this.detectAndSendChanges(); diff --git a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java index b417cae68..a1b3ebff8 100644 --- a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java +++ b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java @@ -143,7 +143,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn compound.setString( "InscribeName", this.myName ); return namePressStack; - } ).orElse( null ); + } ).orElse( ItemStack.EMPTY ); } } @@ -154,7 +154,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn public ItemStack decrStackSize( final int var1, final int var2 ) { final ItemStack is = this.getStackInSlot( 0 ); - if( is != null ) + if( !is.isEmpty() ) { if( this.makePlate() ) { @@ -272,7 +272,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn @Override public void clear() { - this.inSlot.setInventorySlotContents( 0, null ); + this.inSlot.setInventorySlotContents( 0, ItemStack.EMPTY ); } @Override diff --git a/src/main/java/appeng/container/implementations/ContainerSecurityStation.java b/src/main/java/appeng/container/implementations/ContainerSecurityStation.java index f239ac717..58e4a7abc 100644 --- a/src/main/java/appeng/container/implementations/ContainerSecurityStation.java +++ b/src/main/java/appeng/container/implementations/ContainerSecurityStation.java @@ -75,7 +75,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements final SecurityPermissions permission = SecurityPermissions.valueOf( value ); final ItemStack a = this.configSlot.getStack(); - if( a != null && a.getItem() instanceof IBiometricCard ) + if( !a.isEmpty() && a.getItem() instanceof IBiometricCard ) { final IBiometricCard bc = (IBiometricCard) a.getItem(); if( bc.hasPermission( a, permission ) ) @@ -102,7 +102,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements this.setPermissionMode( 0 ); final ItemStack a = this.configSlot.getStack(); - if( a != null && a.getItem() instanceof IBiometricCard ) + if( !a.isEmpty() && a.getItem() instanceof IBiometricCard ) { final IBiometricCard bc = (IBiometricCard) a.getItem(); @@ -164,7 +164,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements { networkEncodable.setEncryptionKey( term, String.valueOf( this.securityBox.getSecurityKey() ), "" ); - this.wirelessIn.putStack( null ); + this.wirelessIn.putStack( ItemStack.EMPTY ); this.wirelessOut.putStack( term ); // update the two slots in question... diff --git a/src/main/java/appeng/container/implementations/ContainerStorageBus.java b/src/main/java/appeng/container/implementations/ContainerStorageBus.java index db461a209..8ecb353fa 100644 --- a/src/main/java/appeng/container/implementations/ContainerStorageBus.java +++ b/src/main/java/appeng/container/implementations/ContainerStorageBus.java @@ -137,7 +137,7 @@ public class ContainerStorageBus extends ContainerUpgradeable final IInventory inv = this.getUpgradeable().getInventoryByName( "config" ); for( int x = 0; x < inv.getSizeInventory(); x++ ) { - inv.setInventorySlotContents( x, null ); + inv.setInventorySlotContents( x, ItemStack.EMPTY ); } this.detectAndSendChanges(); } @@ -165,7 +165,7 @@ public class ContainerStorageBus extends ContainerUpgradeable } else { - inv.setInventorySlotContents( x, null ); + inv.setInventorySlotContents( x, ItemStack.EMPTY ); } } diff --git a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java index d52e85d57..7e50f9334 100644 --- a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java +++ b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java @@ -97,7 +97,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl for( int x = 0; x < pi.getSizeInventory(); x++ ) { final ItemStack pii = pi.getStackInSlot( x ); - if( pii != null && pii.getItem() instanceof ToolNetworkTool ) + if( !pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool ) { this.lockPlayerInventorySlot( x ); this.tbSlot = x; @@ -204,7 +204,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl if( o instanceof OptionalSlotFake ) { final OptionalSlotFake fs = (OptionalSlotFake) o; - if( !fs.isEnabled() && fs.getDisplayStack() != null ) + if( !fs.isEnabled() && !fs.getDisplayStack().isEmpty() ) { fs.clearStack(); } @@ -233,7 +233,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl if( currentItem != this.tbInventory.getItemStack() ) { - if( currentItem != null ) + if( !currentItem.isEmpty() ) { if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) ) { diff --git a/src/main/java/appeng/container/implementations/ContainerWireless.java b/src/main/java/appeng/container/implementations/ContainerWireless.java index a3b073162..4a25ebfcb 100644 --- a/src/main/java/appeng/container/implementations/ContainerWireless.java +++ b/src/main/java/appeng/container/implementations/ContainerWireless.java @@ -51,7 +51,7 @@ public class ContainerWireless extends AEBaseContainer @Override public void detectAndSendChanges() { - final int boosters = this.boosterSlot.getStack() == null ? 0 : this.boosterSlot.getStack().getCount(); + final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount(); this.setRange( (long) ( 10 * AEConfig.instance().wireless_getMaxRange( boosters ) ) ); this.setDrain( (long) ( 100 * AEConfig.instance().wireless_getPowerDrain( boosters ) ) ); diff --git a/src/main/java/appeng/container/slot/AppEngCraftingSlot.java b/src/main/java/appeng/container/slot/AppEngCraftingSlot.java index d9bc163f7..c7b5308ac 100644 --- a/src/main/java/appeng/container/slot/AppEngCraftingSlot.java +++ b/src/main/java/appeng/container/slot/AppEngCraftingSlot.java @@ -167,14 +167,14 @@ public class AppEngCraftingSlot extends AppEngSlot final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i ); final ItemStack itemstack2 = aitemstack.get( i ); - if( itemstack1 != null ) + if( !itemstack1.isEmpty() ) { this.craftMatrix.decrStackSize( i, 1 ); } - if( itemstack2 != null ) + if( !itemstack2.isEmpty() ) { - if( this.craftMatrix.getStackInSlot( i ) == null ) + if( this.craftMatrix.getStackInSlot( i ).isEmpty() ) { this.craftMatrix.setInventorySlotContents( i, itemstack2 ); } diff --git a/src/main/java/appeng/container/slot/AppEngSlot.java b/src/main/java/appeng/container/slot/AppEngSlot.java index 3848633cf..c2ae6b357 100644 --- a/src/main/java/appeng/container/slot/AppEngSlot.java +++ b/src/main/java/appeng/container/slot/AppEngSlot.java @@ -67,7 +67,7 @@ public class AppEngSlot extends Slot public void clearStack() { - super.putStack( null ); + super.putStack( ItemStack.EMPTY ); } @Override diff --git a/src/main/java/appeng/container/slot/OptionalSlotFake.java b/src/main/java/appeng/container/slot/OptionalSlotFake.java index d2e5d3a63..427d21020 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFake.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFake.java @@ -46,7 +46,7 @@ public class OptionalSlotFake extends SlotFake { if( !this.isEnabled() ) { - if( this.getDisplayStack() != null ) + if( !this.getDisplayStack().isEmpty() ) { this.clearStack(); } diff --git a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java index dcfe7e28c..3be6ad6a2 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java @@ -34,7 +34,7 @@ public class OptionalSlotFakeTypeOnly extends OptionalSlotFake @Override public void putStack( ItemStack is ) { - if( is != null ) + if( !is.isEmpty() ) { is = is.copy(); if( is.getCount() > 1 ) diff --git a/src/main/java/appeng/container/slot/SlotCraftingTerm.java b/src/main/java/appeng/container/slot/SlotCraftingTerm.java index f8efd0460..8e39ccf77 100644 --- a/src/main/java/appeng/container/slot/SlotCraftingTerm.java +++ b/src/main/java/appeng/container/slot/SlotCraftingTerm.java @@ -89,7 +89,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot public void doClick( final InventoryAction action, final EntityPlayer who ) { - if( this.getStack() == null ) + if( this.getStack().isEmpty() ) { return; } @@ -128,18 +128,18 @@ public class SlotCraftingTerm extends AppEngCraftingSlot } final ItemStack rs = Platform.cloneItemStack( this.getStack() ); - if( rs == null ) + if( rs.isEmpty() ) { return; } for( int x = 0; x < maxTimesToCraft; x++ ) { - if( ia.simulateAdd( rs ) == null ) + if( ia.simulateAdd( rs ).isEmpty() ) { final IItemList all = inv.getStorageList(); final ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) ); - if( extra != null ) + if( !extra.isEmpty() ) { final List drops = new ArrayList(); drops.add( extra ); @@ -160,7 +160,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot // update crafting matrix... ItemStack is = this.getStack(); - if( is != null && Platform.itemComparisons().isEqualItem( request, is ) ) + if( !is.isEmpty() && Platform.itemComparisons().isEqualItem( request, is ) ) { final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()]; // Safeguard for empty slots in the inventory for now @@ -186,7 +186,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot for( int x = 0; x < ic.getSizeInventory(); x++ ) { final ItemStack pis = ic.getStackInSlot( x ); - if( pis == null ) + if( pis.isEmpty() ) { continue; } @@ -212,7 +212,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot { for( int x = 0; x < this.getPattern().getSizeInventory(); x++ ) { - if( this.getPattern().getStackInSlot( x ) != null ) + if( !this.getPattern().getStackInSlot( x ).isEmpty() ) { set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.world, r, is, ic, this.getPattern().getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) ); ic.setInventorySlotContents( x, set[x] ); @@ -257,11 +257,11 @@ public class SlotCraftingTerm extends AppEngCraftingSlot // set new items onto the crafting table... for( int x = 0; x < this.craftInv.getSizeInventory(); x++ ) { - if( this.craftInv.getStackInSlot( x ) == null ) + if( this.craftInv.getStackInSlot( x ).isEmpty() ) { this.craftInv.setInventorySlotContents( x, set[x] ); } - else if( set[x] != null ) + else if( !set[x].isEmpty() ) { // eek! put it back! final IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc ); diff --git a/src/main/java/appeng/container/slot/SlotFake.java b/src/main/java/appeng/container/slot/SlotFake.java index 6d4a2c297..a3a9cc0c7 100644 --- a/src/main/java/appeng/container/slot/SlotFake.java +++ b/src/main/java/appeng/container/slot/SlotFake.java @@ -53,7 +53,7 @@ public class SlotFake extends AppEngSlot @Override public void putStack( ItemStack is ) { - if( is != null ) + if( !is.isEmpty() ) { is = is.copy(); } diff --git a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java index 9a3e9bd34..5c739afc1 100644 --- a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java @@ -34,7 +34,7 @@ public class SlotFakeTypeOnly extends SlotFake @Override public void putStack( ItemStack is ) { - if( is != null ) + if( !is.isEmpty() ) { is = is.copy(); if( is.getCount() > 1 ) diff --git a/src/main/java/appeng/container/slot/SlotInaccessible.java b/src/main/java/appeng/container/slot/SlotInaccessible.java index b385a9c5b..7fd2d88d9 100644 --- a/src/main/java/appeng/container/slot/SlotInaccessible.java +++ b/src/main/java/appeng/container/slot/SlotInaccessible.java @@ -27,7 +27,7 @@ import net.minecraft.item.ItemStack; public class SlotInaccessible extends AppEngSlot { - private ItemStack dspStack = null; + private ItemStack dspStack = ItemStack.EMPTY; public SlotInaccessible( final IInventory i, final int slotIdx, final int x, final int y ) { @@ -44,7 +44,7 @@ public class SlotInaccessible extends AppEngSlot public void onSlotChanged() { super.onSlotChanged(); - this.dspStack = null; + this.dspStack = ItemStack.EMPTY; } @Override @@ -56,10 +56,10 @@ public class SlotInaccessible extends AppEngSlot @Override public ItemStack getDisplayStack() { - if( this.dspStack == null ) + if( this.dspStack.isEmpty() ) { final ItemStack dsp = super.getDisplayStack(); - if( dsp != null ) + if( !dsp.isEmpty() ) { this.dspStack = dsp.copy(); } diff --git a/src/main/java/appeng/container/slot/SlotRestrictedInput.java b/src/main/java/appeng/container/slot/SlotRestrictedInput.java index 6d7ef5ca3..8e5058598 100644 --- a/src/main/java/appeng/container/slot/SlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/SlotRestrictedInput.java @@ -101,7 +101,7 @@ public class SlotRestrictedInput extends AppEngSlot return false; } - if( i == null ) + if( i.isEmpty() ) { return false; } @@ -243,11 +243,11 @@ public class SlotRestrictedInput extends AppEngSlot if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) ) { final ItemStack is = super.getStack(); - if( is != null && is.getItem() instanceof ItemEncodedPattern ) + if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern ) { final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); final ItemStack out = iep.getOutput( is ); - if( out != null ) + if( !out.isEmpty() ) { return out; } diff --git a/src/main/java/appeng/core/api/imc/IMCBlackListSpatial.java b/src/main/java/appeng/core/api/imc/IMCBlackListSpatial.java index 0e610363d..6a495b257 100644 --- a/src/main/java/appeng/core/api/imc/IMCBlackListSpatial.java +++ b/src/main/java/appeng/core/api/imc/IMCBlackListSpatial.java @@ -36,7 +36,7 @@ public class IMCBlackListSpatial implements IIMCProcessor { final ItemStack is = m.getItemStackValue(); - if( is != null ) + if( !is.isEmpty() ) { final Block blk = Block.getBlockFromItem( is.getItem() ); if( blk != null ) diff --git a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java index 49bfe4a7c..870a71d43 100644 --- a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java +++ b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java @@ -54,7 +54,7 @@ public class IMCP2PAttunement implements IIMCProcessor if( type != null ) { final ItemStack is = m.getItemStackValue(); - if( is != null ) + if( !is.isEmpty() ) { AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type ); } diff --git a/src/main/java/appeng/core/features/ColoredItemDefinition.java b/src/main/java/appeng/core/features/ColoredItemDefinition.java index f102178f0..61d5cf876 100644 --- a/src/main/java/appeng/core/features/ColoredItemDefinition.java +++ b/src/main/java/appeng/core/features/ColoredItemDefinition.java @@ -92,7 +92,7 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition { final ItemStackSrc is = this.colors[color.ordinal()]; - if( comparableItem == null || is == null ) + if( comparableItem.isEmpty() || is == null ) { return false; } diff --git a/src/main/java/appeng/core/features/registries/cell/CellRegistry.java b/src/main/java/appeng/core/features/registries/cell/CellRegistry.java index 400692a6b..3c887d9aa 100644 --- a/src/main/java/appeng/core/features/registries/cell/CellRegistry.java +++ b/src/main/java/appeng/core/features/registries/cell/CellRegistry.java @@ -53,7 +53,7 @@ public class CellRegistry implements ICellRegistry @Override public boolean isCellHandled( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return false; } @@ -70,7 +70,7 @@ public class CellRegistry implements ICellRegistry @Override public ICellHandler getHandler( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return null; } @@ -87,7 +87,7 @@ public class CellRegistry implements ICellRegistry @Override public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final StorageChannel chan ) { - if( is == null ) + if( is.isEmpty() ) { return null; } diff --git a/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java b/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java index c33a41199..3a426aed2 100644 --- a/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java +++ b/src/main/java/appeng/core/features/registries/cell/CreativeCellHandler.java @@ -42,13 +42,13 @@ public class CreativeCellHandler implements ICellHandler @Override public boolean isCell( final ItemStack is ) { - return is != null && is.getItem() instanceof ItemCreativeStorageCell; + return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell; } @Override public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final StorageChannel channel ) { - if( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell ) + if( channel == StorageChannel.ITEMS && !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell ) { return CreativeCellInventory.getCell( is ); } diff --git a/src/main/java/appeng/core/features/registries/grinder/GrinderRecipeManager.java b/src/main/java/appeng/core/features/registries/grinder/GrinderRecipeManager.java index c288dd208..70d4a88ff 100644 --- a/src/main/java/appeng/core/features/registries/grinder/GrinderRecipeManager.java +++ b/src/main/java/appeng/core/features/registries/grinder/GrinderRecipeManager.java @@ -229,7 +229,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene private ItemStack copy( final ItemStack is ) { - if( is != null ) + if( !is.isEmpty() ) { return is.copy(); } diff --git a/src/main/java/appeng/core/features/registries/inscriber/InscriberRegistry.java b/src/main/java/appeng/core/features/registries/inscriber/InscriberRegistry.java index dade498f7..594b788c6 100644 --- a/src/main/java/appeng/core/features/registries/inscriber/InscriberRegistry.java +++ b/src/main/java/appeng/core/features/registries/inscriber/InscriberRegistry.java @@ -182,11 +182,11 @@ public final class InscriberRegistry implements IInscriberRegistry { throw new IllegalStateException( "Input must have a size." ); } - if( this.output == null ) + if( this.output.isEmpty() ) { throw new IllegalStateException( "Output must be defined." ); } - if( this.topOptional == null && this.bottomOptional == null ) + if( this.topOptional.isEmpty() && this.bottomOptional.isEmpty() ) { throw new IllegalStateException( "One optional must be defined." ); } diff --git a/src/main/java/appeng/core/stats/Achievements.java b/src/main/java/appeng/core/stats/Achievements.java index 66a39aa16..b0e35b956 100644 --- a/src/main/java/appeng/core/stats/Achievements.java +++ b/src/main/java/appeng/core/stats/Achievements.java @@ -124,7 +124,7 @@ public enum Achievements Achievements( final int x, final int y, final IItemDefinition which, final AchievementType type ) { - this.stack = which.maybeStack( 1 ).orElse( null ); + this.stack = which.maybeStack( 1 ).orElse( ItemStack.EMPTY ); this.type = type; this.x = x; this.y = y; diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index e168822c1..a672224ca 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -255,7 +255,7 @@ public enum GuiBridge implements IGuiHandler final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1; if( ID.type.isItem() ) { - ItemStack it = null; + ItemStack it = ItemStack.EMPTY; if( stem ) { it = player.inventory.getCurrentItem(); @@ -295,7 +295,7 @@ public enum GuiBridge implements IGuiHandler private Object getGuiObject( final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z ) { - if( it != null ) + if( !it.isEmpty() ) { if( it.getItem() instanceof IGuiItem ) { @@ -437,7 +437,7 @@ public enum GuiBridge implements IGuiHandler final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1; if( ID.type.isItem() ) { - ItemStack it = null; + ItemStack it = ItemStack.EMPTY; if( stem ) { it = player.inventory.getCurrentItem(); @@ -510,7 +510,7 @@ public enum GuiBridge implements IGuiHandler if( this.type.isItem() ) { final ItemStack it = player.inventory.getCurrentItem(); - if( it != null && it.getItem() instanceof IGuiItem ) + if( !it.isEmpty() && it.getItem() instanceof IGuiItem ) { final Object myItem = ( (IGuiItem) it.getItem() ).getGuiObject( it, w, pos ); if( this.CorrectTileOrPart( myItem ) ) diff --git a/src/main/java/appeng/core/sync/packets/PacketClick.java b/src/main/java/appeng/core/sync/packets/PacketClick.java index 084a65722..2b6ebe614 100644 --- a/src/main/java/appeng/core/sync/packets/PacketClick.java +++ b/src/main/java/appeng/core/sync/packets/PacketClick.java @@ -106,7 +106,7 @@ public class PacketClick extends AppEngPacket final IComparableDefinition maybeMemoryCard = items.memoryCard(); final IComparableDefinition maybeColorApplicator = items.colorApplicator(); - if( is != null ) + if( !is.isEmpty() ) { if( is.getItem() instanceof ToolNetworkTool ) { diff --git a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java index 8bf65813f..44214a8b1 100644 --- a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java @@ -167,7 +167,7 @@ public class PacketInventoryAction extends AppEngPacket { if( this.slotItem == null ) { - AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( null ); + AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( ItemStack.EMPTY ); } else { diff --git a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java index 78c59975b..c11cf1da5 100644 --- a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java @@ -150,7 +150,7 @@ public class PacketJEIRecipe extends AppEngPacket { final ItemStack is = r.getCraftingResult( testInv ); - if( is != null ) + if( !is.isEmpty() ) { final IMEMonitor storage = inv.getItemInventory(); final IItemList all = storage.getStorageList(); @@ -161,13 +161,13 @@ public class PacketJEIRecipe extends AppEngPacket final ItemStack patternItem = testInv.getStackInSlot( x ); ItemStack currentItem = craftMatrix.getStackInSlot( x ); - if( currentItem != null ) + if( !currentItem.isEmpty() ) { testInv.setInventorySlotContents( x, currentItem ); - final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : null; + final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : ItemStack.EMPTY; testInv.setInventorySlotContents( x, patternItem ); - if( newItemStack == null || !Platform.itemComparisons().isSameItem( newItemStack, is ) ) + if( newItemStack.isEmpty() || !Platform.itemComparisons().isSameItem( newItemStack, is ) ) { final IAEItemStack in = AEItemStack.create( currentItem ); if( in != null ) @@ -179,7 +179,7 @@ public class PacketJEIRecipe extends AppEngPacket } else { - craftMatrix.setInventorySlotContents( x, null ); + craftMatrix.setInventorySlotContents( x, ItemStack.EMPTY ); } currentItem = craftMatrix.getStackInSlot( x ); @@ -188,14 +188,14 @@ public class PacketJEIRecipe extends AppEngPacket } // True if we need to fetch an item for the recipe - if( patternItem != null && currentItem == null ) + if( !patternItem.isEmpty() && currentItem.isEmpty() ) { // Grab from network by recipe ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getActionSource(), storage, player.world, r, is, testInv, patternItem, x, all, realForFake, filter ); // If that doesn't get it, grab exact items from network (?) // TODO see if this code is necessary - if( whichItem == null ) + if( whichItem.isEmpty() ) { for( int y = 0; y < this.recipe[x].length; y++ ) { @@ -217,7 +217,7 @@ public class PacketJEIRecipe extends AppEngPacket } // If that doesn't work, grab from the player's inventory - if( whichItem == null && playerInventory != null ) + if( whichItem.isEmpty() && playerInventory != null ) { whichItem = this.extractItemFromPlayerInventory( player, realForFake, patternItem ); } diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index dcd64328d..3712cf74d 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -73,7 +73,7 @@ public class CraftingTreeProcess final IAEItemStack[] is = details.getInputs(); for( int x = 0; x < ic.getSizeInventory(); x++ ) { - ic.setInventorySlotContents( x, is[x] == null ? null : is[x].getItemStack() ); + ic.setInventorySlotContents( x, is[x] == null ? ItemStack.EMPTY : is[x].getItemStack() ); } FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic ); @@ -81,7 +81,7 @@ public class CraftingTreeProcess for( int x = 0; x < ic.getSizeInventory(); x++ ) { final ItemStack g = ic.getStackInSlot( x ); - if( g != null && g.getCount() > 1 ) + if( !g.isEmpty() && g.getCount() > 1 ) { this.fullSimulation = true; } @@ -94,7 +94,7 @@ public class CraftingTreeProcess boolean isAnInput = false; for( final IAEItemStack a : details.getCondensedOutputs() ) { - if( g != null && a != null && a.equals( g ) ) + if( !g.isEmpty() && a != null && a.equals( g ) ) { isAnInput = true; } @@ -151,7 +151,7 @@ public class CraftingTreeProcess boolean isAnInput = false; for( final IAEItemStack a : details.getCondensedOutputs() ) { - if( g != null && a != null && a.equals( g ) ) + if( !g.isEmpty() && a != null && a.equals( g ) ) { isAnInput = true; } diff --git a/src/main/java/appeng/debug/TileCubeGenerator.java b/src/main/java/appeng/debug/TileCubeGenerator.java index 15bfe9103..23b6b1816 100644 --- a/src/main/java/appeng/debug/TileCubeGenerator.java +++ b/src/main/java/appeng/debug/TileCubeGenerator.java @@ -37,14 +37,14 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable { private int size = 3; - private ItemStack is = null; + private ItemStack is = ItemStack.EMPTY; private int countdown = 20 * 10; private EntityPlayer who = null; @Override public void update() { - if( this.is != null && Platform.isServer() ) + if( !this.is.isEmpty() && Platform.isServer() ) { this.countdown--; @@ -92,9 +92,9 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable final ItemStack hand = player.inventory.getCurrentItem(); this.who = player; - if( hand == null ) + if( hand.isEmpty() ) { - this.is = null; + this.is = ItemStack.EMPTY; if( player.isSneaking() ) { diff --git a/src/main/java/appeng/debug/TileItemGen.java b/src/main/java/appeng/debug/TileItemGen.java index ec3d72494..d80959e45 100644 --- a/src/main/java/appeng/debug/TileItemGen.java +++ b/src/main/java/appeng/debug/TileItemGen.java @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.Queue; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -78,7 +79,10 @@ public class TileItemGen extends AEBaseTile implements IInventory private ItemStack getRandomItem() { - return POSSIBLE_ITEMS.peek(); + // Safeguard for crash + ItemStack testStack = POSSIBLE_ITEMS.peek(); + if( testStack.isEmpty() ) testStack = new ItemStack(Blocks.COBBLESTONE, 1); + return testStack; } @Override diff --git a/src/main/java/appeng/decorative/solid/BlockSkyStone.java b/src/main/java/appeng/decorative/solid/BlockSkyStone.java index d5697a9a2..62eb9247e 100644 --- a/src/main/java/appeng/decorative/solid/BlockSkyStone.java +++ b/src/main/java/appeng/decorative/solid/BlockSkyStone.java @@ -64,7 +64,7 @@ public class BlockSkyStone extends AEBaseBlock final ItemStack is = event.getEntityPlayer().getItemStackFromSlot( EntityEquipmentSlot.MAINHAND ); int level = -1; - if( is != null && is.getItem() != null ) + if( !is.isEmpty() && is.getItem() != null ) { level = is.getItem().getHarvestLevel( is, "pickaxe", event.getEntityPlayer(), event.getState() ); } diff --git a/src/main/java/appeng/facade/FacadeContainer.java b/src/main/java/appeng/facade/FacadeContainer.java index f11c89f50..b7e30a7c8 100644 --- a/src/main/java/appeng/facade/FacadeContainer.java +++ b/src/main/java/appeng/facade/FacadeContainer.java @@ -165,7 +165,7 @@ public class FacadeContainer implements IFacadeContainer if( t != null ) { final ItemStack is = new ItemStack( t ); - if( is != null ) + if( !is.isEmpty() ) { final Item i = is.getItem(); if( i instanceof IFacadeItem ) diff --git a/src/main/java/appeng/facade/FacadePart.java b/src/main/java/appeng/facade/FacadePart.java index 024b3a052..4915573ac 100644 --- a/src/main/java/appeng/facade/FacadePart.java +++ b/src/main/java/appeng/facade/FacadePart.java @@ -88,7 +88,7 @@ public class FacadePart implements IFacadePart, IBoxProvider public Item getItem() { final ItemStack is = this.getTextureItem(); - if( is == null ) + if( is.isEmpty() ) { return null; } @@ -99,7 +99,7 @@ public class FacadePart implements IFacadePart, IBoxProvider public int getItemDamage() { final ItemStack is = this.getTextureItem(); - if( is == null ) + if( is.isEmpty() ) { return 0; } diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 9713f2485..71db88c1b 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -178,7 +178,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { this.readConfig(); } - else if( inv == this.patterns && ( removed != null || added != null ) ) + else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) ) { this.updateCraftingList(); } @@ -264,7 +264,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn private void addToSendList( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return; } @@ -292,7 +292,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( final ItemStack p : this.config ) { - if( p != null ) + if( !p.isEmpty() ) { this.hasConfig = true; break; @@ -408,13 +408,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn IAEItemStack req = this.config.getAEStackInSlot( slot ); if( req != null && req.getStackSize() <= 0 ) { - this.config.setInventorySlotContents( slot, null ); + this.config.setInventorySlotContents( slot, ItemStack.EMPTY ); req = null; } final ItemStack Stored = this.storage.getStackInSlot( slot ); - if( req == null && Stored != null ) + if( req == null && !Stored.isEmpty() ) { final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored ); this.requireWork[slot] = work.setStackSize( -work.getStackSize() ); @@ -422,7 +422,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } else if( req != null ) { - if( Stored == null ) // need to add stuff! + if( Stored.isEmpty() ) // need to add stuff! { this.requireWork[slot] = req.copy(); return; @@ -474,7 +474,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn private void addToCraftingList( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return; } @@ -561,7 +561,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { for( int slot = 0; slot < this.storage.getSizeInventory(); slot++ ) { - this.onChangeInventory( this.storage, slot, InvOperation.markDirty, null, null ); + this.onChangeInventory( this.storage, slot, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY ); } } @@ -621,23 +621,23 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { final ItemStack result = ad.addItems( whatToSend ); - if( result == null ) + if( result.isEmpty() ) { - whatToSend = null; + whatToSend = ItemStack.EMPTY; } else { whatToSend.setCount( whatToSend.getCount() - (whatToSend.getCount() - result.getCount()) ); } - if( whatToSend == null ) + if( whatToSend.isEmpty() ) { break; } } } - if( whatToSend == null ) + if( whatToSend.isEmpty() ) { i.remove(); } @@ -682,7 +682,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn else if( itemStack.getStackSize() > 0 ) { // make sure strange things didn't happen... - if( adaptor.simulateAdd( itemStack.getItemStack() ) != null ) + if( !adaptor.simulateAdd( itemStack.getItemStack() ).isEmpty() ) { changed = true; throw new GridAccessException(); @@ -693,7 +693,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { changed = true; final ItemStack issue = adaptor.addItems( acquired.getItemStack() ); - if( issue != null ) + if( !issue.isEmpty() ) { throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" ); } @@ -712,7 +712,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn // make sure strange things didn't happen... final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getItemStack(), null ); - if( canExtract == null || canExtract.getCount() != diff ) + if( canExtract.isEmpty() || canExtract.getCount() != diff ) { changed = true; throw new GridAccessException(); @@ -729,8 +729,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { // extract items! changed = true; - final ItemStack removed = adaptor.removeItems( (int) diff, null, null ); - if( removed == null ) + final ItemStack removed = adaptor.removeItems( (int) diff, ItemStack.EMPTY, null ); + if( removed.isEmpty() ) { throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); } @@ -949,7 +949,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { if( this.isBlocking() ) { - if( ad.simulateRemove( 1, null, null ) != null ) + if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() ) { continue; } @@ -960,7 +960,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( int x = 0; x < table.getSizeInventory(); x++ ) { final ItemStack is = table.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { final ItemStack added = ad.addItems( is ); this.addToSendList( added ); @@ -1000,7 +1000,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); if( ad != null ) { - if( ad.simulateRemove( 1, null, null ) == null ) + if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() ) { allAreBusy = false; break; @@ -1029,12 +1029,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( int x = 0; x < table.getSizeInventory(); x++ ) { final ItemStack is = table.getStackInSlot( x ); - if( is == null ) + if( is.isEmpty() ) { continue; } - if( ad.simulateAdd( is.copy() ) != null ) + if( !ad.simulateAdd( is.copy() ).isEmpty() ) { return false; } @@ -1062,7 +1062,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { for( final ItemStack is : this.waitingToSend ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -1071,7 +1071,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( final ItemStack is : this.upgrades ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -1079,7 +1079,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( final ItemStack is : this.storage ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -1087,7 +1087,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn for( final ItemStack is : this.patterns ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -1213,7 +1213,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( mop.getBlockPos().equals( directedTile.getPos() ) ) { final ItemStack g = directedBlock.getPickBlock( directedBlockState, mop, hostWorld, directedTile.getPos(), null ); - if( g != null ) + if( !g.isEmpty() ) { what = g; } diff --git a/src/main/java/appeng/helpers/MultiCraftingTracker.java b/src/main/java/appeng/helpers/MultiCraftingTracker.java index 2b5e013c1..b70d306a2 100644 --- a/src/main/java/appeng/helpers/MultiCraftingTracker.java +++ b/src/main/java/appeng/helpers/MultiCraftingTracker.java @@ -83,7 +83,7 @@ public class MultiCraftingTracker public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final BaseActionSource mySrc ) { - if( ais != null && d.simulateAdd( ais.getItemStack() ) == null ) + if( ais != null && d.simulateAdd( ais.getItemStack() ).isEmpty() ) { final Future craftingJob = this.getJob( x ); diff --git a/src/main/java/appeng/integration/modules/jei/FacadeRecipeWrapper.java b/src/main/java/appeng/integration/modules/jei/FacadeRecipeWrapper.java index 48fe8ae0b..635039992 100644 --- a/src/main/java/appeng/integration/modules/jei/FacadeRecipeWrapper.java +++ b/src/main/java/appeng/integration/modules/jei/FacadeRecipeWrapper.java @@ -65,17 +65,17 @@ class FacadeRecipeWrapper extends BlankRecipeWrapper implements IShapedCraftingR { List input = new ArrayList<>( 9 ); - input.add( null ); + input.add( ItemStack.EMPTY ); input.add( cableAnchor ); - input.add( null ); + input.add( ItemStack.EMPTY ); input.add( cableAnchor ); input.add( textureItem ); input.add( cableAnchor ); - input.add( null ); + input.add( ItemStack.EMPTY ); input.add( cableAnchor ); - input.add( null ); + input.add( ItemStack.EMPTY ); ingredients.setInputs( ItemStack.class, input ); ingredients.setOutput( ItemStack.class, facade ); diff --git a/src/main/java/appeng/integration/modules/jei/InscriberRecipeWrapper.java b/src/main/java/appeng/integration/modules/jei/InscriberRecipeWrapper.java index cdf3fb510..4567ee7d1 100644 --- a/src/main/java/appeng/integration/modules/jei/InscriberRecipeWrapper.java +++ b/src/main/java/appeng/integration/modules/jei/InscriberRecipeWrapper.java @@ -45,9 +45,9 @@ class InscriberRecipeWrapper extends BlankRecipeWrapper public void getIngredients( IIngredients ingredients ) { List> inputSlots = new ArrayList<>( 3 ); - inputSlots.add( Collections.singletonList( recipe.getTopOptional().orElse( null ) ) ); + inputSlots.add( Collections.singletonList( recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ); inputSlots.add( recipe.getInputs() ); - inputSlots.add( Collections.singletonList( recipe.getBottomOptional().orElse( null ) ) ); + inputSlots.add( Collections.singletonList( recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ); ingredients.setInputLists( ItemStack.class, inputSlots ); ingredients.setOutput( ItemStack.class, recipe.getOutput() ); diff --git a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java index 614f20b1f..15cd8fe24 100644 --- a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java @@ -126,7 +126,7 @@ public class JEIPlugin extends BlankModPlugin private void registerGrinderRecipes( IDefinitions definitions, IModRegistry registry ) { - ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( null ); + ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( ItemStack.EMPTY ); if( grindstone == null ) { @@ -142,19 +142,19 @@ public class JEIPlugin extends BlankModPlugin private void registerCondenserRecipes( IDefinitions definitions, IModRegistry registry ) { - ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( null ); + ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( ItemStack.EMPTY ); if( condenser == null ) { return; } - ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( null ); + ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY ); if( matterBall != null ) { registry.addRecipes( ImmutableList.of( CondenserOutput.MATTER_BALLS ) ); } - ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( null ); + ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY ); if( singularity != null ) { registry.addRecipes( ImmutableList.of( CondenserOutput.SINGULARITY ) ); diff --git a/src/main/java/appeng/items/materials/ItemMaterial.java b/src/main/java/appeng/items/materials/ItemMaterial.java index 8cada8fe6..e6d600129 100644 --- a/src/main/java/appeng/items/materials/ItemMaterial.java +++ b/src/main/java/appeng/items/materials/ItemMaterial.java @@ -220,7 +220,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent, { for( final ItemStack is : options ) { - if( is != null && is.getItem() != null ) + if( !is.isEmpty() && is.getItem() != null ) { replacement = is.copy(); break; @@ -301,7 +301,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent, upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" ); } - if( upgrades != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof IUpgradeModule ) + if( upgrades != null && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof IUpgradeModule ) { final IUpgradeModule um = (IUpgradeModule) player.getHeldItemMainhand().getItem(); final Upgrades u = um.getType( player.getHeldItemMainhand() ); @@ -362,7 +362,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent, private String nameOf( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return "null"; } diff --git a/src/main/java/appeng/items/misc/ItemEncodedPattern.java b/src/main/java/appeng/items/misc/ItemEncodedPattern.java index 783febc67..683f204c1 100644 --- a/src/main/java/appeng/items/misc/ItemEncodedPattern.java +++ b/src/main/java/appeng/items/misc/ItemEncodedPattern.java @@ -80,8 +80,8 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt final InventoryPlayer inv = player.inventory; - ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( null ); - if( is != null ) + ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY ); + if( !is.isEmpty() ) { for( int s = 0; s < player.inventory.getSizeInventory(); s++ ) { diff --git a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java index 17f0b2d7d..c9259a979 100644 --- a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java @@ -237,11 +237,11 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe final IItemList list = inv.getAvailableItems( StorageChannel.ITEMS.createList() ); if( list.isEmpty() && ia != null ) { - playerInventory.setInventorySlotContents( playerInventory.currentItem, null ); + playerInventory.setInventorySlotContents( playerInventory.currentItem, ItemStack.EMPTY ); // drop core final ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); - if( extraB != null ) + if( !extraB.isEmpty() ) { player.dropItem( extraB, false ); } @@ -252,7 +252,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe { final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex ); final ItemStack leftStack = ia.addItems( upgradeStack ); - if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule ) + if( !leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule ) { player.dropItem( upgradeStack, false ); } @@ -262,7 +262,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is -> { final ItemStack extraA = ia.addItems( is ); - if( extraA != null ) + if( !extraA.isEmpty() ) { player.dropItem( extraA, false ); } diff --git a/src/main/java/appeng/items/storage/ItemViewCell.java b/src/main/java/appeng/items/storage/ItemViewCell.java index 2abe0e2c7..898664580 100644 --- a/src/main/java/appeng/items/storage/ItemViewCell.java +++ b/src/main/java/appeng/items/storage/ItemViewCell.java @@ -75,7 +75,7 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem for( int x = 0; x < upgrades.getSizeInventory(); x++ ) { final ItemStack is = upgrades.getStackInSlot( x ); - if( is != null && is.getItem() instanceof IUpgradeModule ) + if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) { final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is ); if( u != null ) @@ -97,7 +97,7 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem for( int x = 0; x < config.getSizeInventory(); x++ ) { final ItemStack is = config.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { priorityList.add( AEItemStack.create( is ) ); } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java index a29e50b44..248e3f5ff 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java @@ -504,14 +504,14 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU fuzz = fuzz.copy(); fuzz.setStackSize( g.getStackSize() ); final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.SIMULATE, this.machineSrc ); - final ItemStack is = ais == null ? null : ais.getItemStack(); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack(); - if( is != null && is.getCount() == g.getStackSize() ) + if( !is.isEmpty() && is.getCount() == g.getStackSize() ) { found = true; break; } - else if( is != null ) + else if( !is.isEmpty() ) { g = g.copy(); g.decStackSize( is.getCount() ); @@ -526,9 +526,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU else { final IAEItemStack ais = this.inventory.extractItems( g.copy(), Actionable.SIMULATE, this.machineSrc ); - final ItemStack is = ais == null ? null : ais.getItemStack(); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack(); - if( is == null || is.getCount() < g.getStackSize() ) + if( is.isEmpty() || is.getCount() < g.getStackSize() ) { return false; } @@ -693,9 +693,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU if( details.isValidItemForSlot( x, fuzz.getItemStack(), this.getWorld() ) ) { final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.MODULATE, this.machineSrc ); - final ItemStack is = ais == null ? null : ais.getItemStack(); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack(); - if( is != null ) + if( !is.isEmpty() ) { this.postChange( AEItemStack.create( is ), this.machineSrc ); ic.setInventorySlotContents( x, is ); @@ -708,9 +708,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU else { final IAEItemStack ais = this.inventory.extractItems( input[x].copy(), Actionable.MODULATE, this.machineSrc ); - final ItemStack is = ais == null ? null : ais.getItemStack(); + final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack(); - if( is != null ) + if( !is.isEmpty() ) { this.postChange( input[x], this.machineSrc ); ic.setInventorySlotContents( x, is ); @@ -735,7 +735,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU for( int x = 0; x < ic.getSizeInventory(); x++ ) { final ItemStack is = ic.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc ); } @@ -764,7 +764,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU for( int x = 0; x < ic.getSizeInventory(); x++ ) { final ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) ); - if( output != null ) + if( !output.isEmpty() ) { final IAEItemStack cItem = AEItemStack.create( output ); this.postChange( cItem, this.machineSrc ); @@ -797,7 +797,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU for( int x = 0; x < ic.getSizeInventory(); x++ ) { final ItemStack is = ic.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc ); } diff --git a/src/main/java/appeng/me/storage/CellInventoryHandler.java b/src/main/java/appeng/me/storage/CellInventoryHandler.java index c2c672f3f..f019390ac 100644 --- a/src/main/java/appeng/me/storage/CellInventoryHandler.java +++ b/src/main/java/appeng/me/storage/CellInventoryHandler.java @@ -62,7 +62,7 @@ public class CellInventoryHandler extends MEInventoryHandler imple for( int x = 0; x < upgrades.getSizeInventory(); x++ ) { final ItemStack is = upgrades.getStackInSlot( x ); - if( is != null && is.getItem() instanceof IUpgradeModule ) + if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule ) { final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is ); if( u != null ) @@ -84,7 +84,7 @@ public class CellInventoryHandler extends MEInventoryHandler imple for( int x = 0; x < config.getSizeInventory(); x++ ) { final ItemStack is = config.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { priorityList.add( AEItemStack.create( is ) ); } diff --git a/src/main/java/appeng/me/storage/CreativeCellInventory.java b/src/main/java/appeng/me/storage/CreativeCellInventory.java index 54a0ca97f..a89bf7852 100644 --- a/src/main/java/appeng/me/storage/CreativeCellInventory.java +++ b/src/main/java/appeng/me/storage/CreativeCellInventory.java @@ -43,7 +43,7 @@ public class CreativeCellInventory implements IMEInventoryHandler final CellConfig cc = new CellConfig( o ); for( final ItemStack is : cc ) { - if( is != null ) + if( !is.isEmpty() ) { final IAEItemStack i = AEItemStack.create( is ); i.setStackSize( Integer.MAX_VALUE ); diff --git a/src/main/java/appeng/me/storage/MEMonitorIInventory.java b/src/main/java/appeng/me/storage/MEMonitorIInventory.java index a95697964..e3167fdfa 100644 --- a/src/main/java/appeng/me/storage/MEMonitorIInventory.java +++ b/src/main/java/appeng/me/storage/MEMonitorIInventory.java @@ -75,7 +75,7 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo @Override public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src ) { - ItemStack out = null; + ItemStack out = ItemStack.EMPTY; if( type == Actionable.SIMULATE ) { @@ -91,7 +91,7 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo this.onTick(); } - if( out == null ) + if( out.isEmpty() ) { return null; } @@ -105,7 +105,7 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo @Override public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src ) { - ItemStack out = null; + ItemStack out = ItemStack.EMPTY; if( type == Actionable.SIMULATE ) { @@ -116,7 +116,7 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null ); } - if( out == null ) + if( out.isEmpty() ) { return null; } @@ -154,7 +154,7 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo high = Math.max( high, is.getSlot() ); final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack(); - final ItemStack oldIS = old == null ? null : old.itemStack; + final ItemStack oldIS = old == null ? ItemStack.EMPTY : old.itemStack; if( this.isDifferent( newIS, oldIS ) ) { @@ -177,8 +177,8 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo } else { - final int newSize = ( newIS == null ? 0 : newIS.getCount() ); - final int diff = newSize - ( oldIS == null ? 0 : oldIS.getCount() ); + final int newSize = ( newIS.isEmpty() ? 0 : newIS.getCount() ); + final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getCount() ); final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance().storage().createItemStack( newIS ) : old.aeStack.copy() ); if( stack != null ) @@ -227,12 +227,12 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo private boolean isDifferent( final ItemStack a, final ItemStack b ) { - if( a == b && b == null ) + if( a == b && b.isEmpty() ) { return false; } - if( ( a == null && b != null ) || ( a != null && b == null ) ) + if( ( a.isEmpty() && !b.isEmpty() ) || ( !a.isEmpty() && b.isEmpty() ) ) { return true; } @@ -344,9 +344,9 @@ public class MEMonitorIInventory implements IMEMonitor, ITickingMo public CachedItemStack( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { - this.itemStack = null; + this.itemStack = ItemStack.EMPTY; this.aeStack = null; } else diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index cbbf74b0e..52650479d 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -1052,12 +1052,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart p = this.getPart( side ); final ItemStack iss = new ItemStack( def ); - if( iss == null ) + if( iss.isEmpty() ) { continue; } - final ItemStack current = p == null ? null : p.getItemStack( PartItemStack.WORLD ); + final ItemStack current = p == null ? ItemStack.EMPTY : p.getItemStack( PartItemStack.WORLD ); if( Platform.itemComparisons().isEqualItemType( iss, current ) ) { diff --git a/src/main/java/appeng/parts/automation/PartImportBus.java b/src/main/java/appeng/parts/automation/PartImportBus.java index eb655d979..7b8eab830 100644 --- a/src/main/java/appeng/parts/automation/PartImportBus.java +++ b/src/main/java/appeng/parts/automation/PartImportBus.java @@ -88,7 +88,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin @Override public boolean canInsert( final ItemStack stack ) { - if( stack == null || stack.getItem() == null ) + if( stack.isEmpty() || stack.getItem() == null ) { return false; } @@ -217,14 +217,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) { - newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) ); + newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) ); } else { - newItems = myAdaptor.removeItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), this.configDestination( inv ) ); + newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), this.configDestination( inv ) ); } - if( newItems != null ) + if( !newItems.isEmpty() ) { newItems.setCount( (int) ( Math.min( newItems.getCount(), energy.extractAEPower( newItems.getCount(), Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 ) ); @@ -266,7 +266,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin if( whatToImport == null ) { - itemStackToImport = null; + itemStackToImport = ItemStack.EMPTY; } else { diff --git a/src/main/java/appeng/parts/automation/PartUpgradeable.java b/src/main/java/appeng/parts/automation/PartUpgradeable.java index 5cfe8bf76..cca94b81b 100644 --- a/src/main/java/appeng/parts/automation/PartUpgradeable.java +++ b/src/main/java/appeng/parts/automation/PartUpgradeable.java @@ -141,7 +141,7 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn { for( final ItemStack is : this.upgrades ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } diff --git a/src/main/java/appeng/parts/automation/UpgradeInventory.java b/src/main/java/appeng/parts/automation/UpgradeInventory.java index 0f52bfeb7..dc3b9043a 100644 --- a/src/main/java/appeng/parts/automation/UpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/UpgradeInventory.java @@ -66,7 +66,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement @Override public boolean isItemValidForSlot( final int i, final ItemStack itemstack ) { - if( itemstack == null ) + if( itemstack.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java index 2e6c29cee..9d33ac179 100644 --- a/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java +++ b/src/main/java/appeng/parts/misc/ItemHandlerAdapter.java @@ -75,7 +75,7 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, IBaseMonitor, IBaseMonitor remainingCurrentSlot ) { @@ -137,7 +137,7 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, IBaseMonitor 0 ); + while( !extracted.isEmpty() && remainingCurrentSlot > 0 ); remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot; @@ -159,7 +159,7 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, IBaseMonitor cachedStacks.length ) + return ItemStack.EMPTY; + + if( cachedStacks[pos] == null ) + return ItemStack.EMPTY; + + return cachedStacks[pos]; + } + @Override public TickRateModulation onTick() { @@ -189,7 +200,7 @@ class ItemHandlerAdapter implements IMEInventory, IBaseMonitor, IBaseMonitor, IBaseMonitor a ) diff --git a/src/main/java/appeng/parts/misc/PartCableAnchor.java b/src/main/java/appeng/parts/misc/PartCableAnchor.java index 870c08c75..54cd40d76 100644 --- a/src/main/java/appeng/parts/misc/PartCableAnchor.java +++ b/src/main/java/appeng/parts/misc/PartCableAnchor.java @@ -60,7 +60,7 @@ public class PartCableAnchor implements IPart @PartModels public static final PartModel FACADE_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor_short" ) ); - private ItemStack is = null; + private ItemStack is = ItemStack.EMPTY; private IPartHost host = null; private AEPartLocation mySide = AEPartLocation.UP; diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index 946a8dedc..5dafcf9be 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -166,7 +166,7 @@ public abstract class PartP2PTunnel extends PartBasicSt // AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() ); final TunnelType tt = AEApi.instance().registries().p2pTunnel().getTunnelTypeByItem( is ); - if( is != null && is.getItem() instanceof IMemoryCard ) + if( !is.isEmpty() && is.getItem() instanceof IMemoryCard ) { final IMemoryCard mc = (IMemoryCard) is.getItem(); final NBTTagCompound data = mc.getData( is ); @@ -174,7 +174,7 @@ public abstract class PartP2PTunnel extends PartBasicSt final ItemStack newType = new ItemStack( data ); final long freq = data.getLong( "freq" ); - if( newType != null ) + if( !newType.isEmpty() ) { if( newType.getItem() instanceof IPartItem ) { @@ -219,7 +219,7 @@ public abstract class PartP2PTunnel extends PartBasicSt switch( tt ) { case LIGHT: - newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( null ); + newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; /* @@ -232,23 +232,23 @@ public abstract class PartP2PTunnel extends PartBasicSt */ //case FLUID: - // newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null ); + // newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( ItemStack.EMPTY ); // break; //case IC2_POWER: - // newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( null ); + // newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( ItemStack.EMPTY ); // break; case ITEM: - newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( null ); + newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; case ME: - newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( null ); + newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; case REDSTONE: - newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( null ); + newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; /* @@ -303,7 +303,7 @@ public abstract class PartP2PTunnel extends PartBasicSt public boolean onPartShiftActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos ) { final ItemStack is = player.inventory.getCurrentItem(); - if( is != null && is.getItem() instanceof IMemoryCard ) + if( !is.isEmpty() && is.getItem() instanceof IMemoryCard ) { final IMemoryCard mc = (IMemoryCard) is.getItem(); final NBTTagCompound data = new NBTTagCompound(); diff --git a/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java index 22f7aded8..6900f6ec3 100644 --- a/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java +++ b/src/main/java/appeng/parts/reporting/AbstractPartTerminal.java @@ -81,7 +81,7 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement for( final ItemStack is : this.viewCell ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } diff --git a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java index fc91d110d..a04f7dc5a 100644 --- a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java @@ -120,14 +120,14 @@ public class PartConversionMonitor extends AbstractPartMonitor final IAEItemStack insertItem = input.copy(); insertItem.setStackSize( targetStack.getCount() ); final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) ); - player.inventory.setInventorySlotContents( x, failedToInsert == null ? null : failedToInsert.getItemStack() ); + player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() ); } } } else { final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) ); - player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() ); + player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() ); } } catch( final GridAccessException e ) @@ -163,7 +163,7 @@ public class PartConversionMonitor extends AbstractPartMonitor ItemStack newItems = retrieved.getItemStack(); final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, EnumFacing.UP ); newItems = adaptor.addItems( newItems ); - if( newItems != null ) + if( !newItems.isEmpty() ) { final TileEntity te = this.getTile(); final List list = Collections.singletonList( newItems ); diff --git a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java index ee3a6d6ac..ab328accd 100644 --- a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java @@ -63,7 +63,7 @@ public class PartCraftingTerminal extends AbstractPartTerminal for( final ItemStack is : this.craftingGrid ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } diff --git a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java index fb78dd130..94f3b1cae 100644 --- a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java @@ -70,7 +70,7 @@ public class PartPatternTerminal extends AbstractPartTerminal { for( final ItemStack is : this.pattern ) { - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -125,7 +125,7 @@ public class PartPatternTerminal extends AbstractPartTerminal if( inv == this.pattern && slot == 1 ) { final ItemStack is = this.pattern.getStackInSlot( 1 ); - if( is != null && is.getItem() instanceof ICraftingPatternItem ) + if( !is.isEmpty() && is.getItem() instanceof ICraftingPatternItem ) { final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() ); @@ -137,13 +137,13 @@ public class PartPatternTerminal extends AbstractPartTerminal for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ ) { final IAEItemStack item = details.getInputs()[x]; - this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() ); + this.crafting.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() ); } for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ ) { final IAEItemStack item = details.getOutputs()[x]; - this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() ); + this.output.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() ); } } } @@ -163,7 +163,7 @@ public class PartPatternTerminal extends AbstractPartTerminal for( int x = 0; x < this.crafting.getSizeInventory(); x++ ) { final ItemStack is = this.crafting.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { is.setCount( 1 ); } diff --git a/src/main/java/appeng/recipes/game/DisassembleRecipe.java b/src/main/java/appeng/recipes/game/DisassembleRecipe.java index ce20136ee..73009e89a 100644 --- a/src/main/java/appeng/recipes/game/DisassembleRecipe.java +++ b/src/main/java/appeng/recipes/game/DisassembleRecipe.java @@ -90,7 +90,7 @@ public final class DisassembleRecipe implements IRecipe for( int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++ ) { final ItemStack stackInSlot = inventory.getStackInSlot( slotIndex ); - if( stackInSlot != null ) + if( !stackInSlot.isEmpty() ) { // needs a single input in the recipe itemCount++; diff --git a/src/main/java/appeng/recipes/game/FacadeRecipe.java b/src/main/java/appeng/recipes/game/FacadeRecipe.java index 0674fd3c2..f1f66ec8d 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -57,7 +57,7 @@ public final class FacadeRecipe implements IRecipe @Nullable private ItemStack getOutput( final IInventory inv, final boolean createFacade ) { - if( inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null ) + if( inv.getStackInSlot( 0 ).isEmpty() && inv.getStackInSlot( 2 ).isEmpty() && inv.getStackInSlot( 6 ).isEmpty() && inv.getStackInSlot( 8 ).isEmpty() ) { if( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) ) { diff --git a/src/main/java/appeng/recipes/game/ShapedRecipe.java b/src/main/java/appeng/recipes/game/ShapedRecipe.java index 8093dc8b3..8fc52a416 100644 --- a/src/main/java/appeng/recipes/game/ShapedRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapedRecipe.java @@ -42,7 +42,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable private static final int MAX_CRAFT_GRID_WIDTH = 3; private static final int MAX_CRAFT_GRID_HEIGHT = 3; - private ItemStack output = null; + private ItemStack output = ItemStack.EMPTY; private Object[] input = null; private int width = 0; private int height = 0; @@ -256,7 +256,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable return false; } } - else if( target == null && slot != null ) + else if( target == null && !slot.isEmpty() ) { return false; } @@ -268,7 +268,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable private boolean checkItemEquals( final ItemStack target, final ItemStack input ) { - if( input == null && target != null || input != null && target == null ) + if( input.isEmpty() && !target.isEmpty() || !input.isEmpty() && target.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/recipes/game/ShapelessRecipe.java b/src/main/java/appeng/recipes/game/ShapelessRecipe.java index 7dd97826d..0de49fccc 100644 --- a/src/main/java/appeng/recipes/game/ShapelessRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapelessRecipe.java @@ -38,7 +38,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable { private final ArrayList input = new ArrayList(); - private ItemStack output = null; + private ItemStack output = ItemStack.EMPTY; private boolean disable = false; public ShapelessRecipe( final ItemStack result, final Object... recipe ) @@ -83,7 +83,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable { final ItemStack slot = var1.getStackInSlot( x ); - if( slot != null ) + if( !slot.isEmpty() ) { boolean inRecipe = false; diff --git a/src/main/java/appeng/recipes/handlers/Inscribe.java b/src/main/java/appeng/recipes/handlers/Inscribe.java index 1fd83a7c0..fac4fafe2 100644 --- a/src/main/java/appeng/recipes/handlers/Inscribe.java +++ b/src/main/java/appeng/recipes/handlers/Inscribe.java @@ -59,8 +59,8 @@ public final class Inscribe extends InscriberProcess final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List inputs = new ArrayList( realInput.length ); Collections.addAll( inputs, realInput ); - final ItemStack top = ( this.getTopOptional() == null ) ? null : this.getTopOptional().getItemStack(); - final ItemStack bot = ( this.getBotOptional() == null ) ? null : this.getBotOptional().getItemStack(); + final ItemStack top = ( this.getTopOptional() == null ) ? ItemStack.EMPTY : this.getTopOptional().getItemStack(); + final ItemStack bot = ( this.getBotOptional() == null ) ? ItemStack.EMPTY : this.getBotOptional().getItemStack(); final ItemStack output = this.getOutput().getItemStack(); final InscriberProcessType type = InscriberProcessType.INSCRIBE; diff --git a/src/main/java/appeng/recipes/handlers/Press.java b/src/main/java/appeng/recipes/handlers/Press.java index c66ad9778..7a7679388 100644 --- a/src/main/java/appeng/recipes/handlers/Press.java +++ b/src/main/java/appeng/recipes/handlers/Press.java @@ -59,8 +59,8 @@ public final class Press extends InscriberProcess final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List inputs = new ArrayList( realInput.length ); Collections.addAll( inputs, realInput ); - final ItemStack top = ( this.getTopOptional() == null ) ? null : this.getTopOptional().getItemStack(); - final ItemStack bot = ( this.getBotOptional() == null ) ? null : this.getBotOptional().getItemStack(); + final ItemStack top = ( this.getTopOptional() == null ) ? ItemStack.EMPTY : this.getTopOptional().getItemStack(); + final ItemStack bot = ( this.getBotOptional() == null ) ? ItemStack.EMPTY : this.getBotOptional().getItemStack(); final ItemStack output = this.getOutput().getItemStack(); final InscriberProcessType type = InscriberProcessType.PRESS; diff --git a/src/main/java/appeng/server/ServerHelper.java b/src/main/java/appeng/server/ServerHelper.java index 1e232639f..d10d89ac1 100644 --- a/src/main/java/appeng/server/ServerHelper.java +++ b/src/main/java/appeng/server/ServerHelper.java @@ -176,7 +176,7 @@ public class ServerHelper extends CommonHelper { final ItemStack is = player.inventory.getStackInSlot( x ); - if( is != null && is.getItem() instanceof ToolNetworkTool ) + if( !is.isEmpty() && is.getItem() instanceof ToolNetworkTool ) { final NBTTagCompound c = is.getTagCompound(); if( c != null && c.getBoolean( "hideFacades" ) ) diff --git a/src/main/java/appeng/tile/AEBaseInvTile.java b/src/main/java/appeng/tile/AEBaseInvTile.java index 823be4093..817dfc7d7 100644 --- a/src/main/java/appeng/tile/AEBaseInvTile.java +++ b/src/main/java/appeng/tile/AEBaseInvTile.java @@ -81,7 +81,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor { final NBTTagCompound item = new NBTTagCompound(); final ItemStack is = this.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { is.writeToNBT( item ); } diff --git a/src/main/java/appeng/tile/AEBaseTile.java b/src/main/java/appeng/tile/AEBaseTile.java index e6d2e56ca..d0497018f 100644 --- a/src/main/java/appeng/tile/AEBaseTile.java +++ b/src/main/java/appeng/tile/AEBaseTile.java @@ -541,7 +541,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, for( int l = 0; l < inv.getSizeInventory(); l++ ) { final ItemStack is = inv.getStackInSlot( l ); - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } diff --git a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java index 3c4f68f54..d16f25b61 100644 --- a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java +++ b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java @@ -87,7 +87,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private final UpgradeInventory upgrades; private boolean isPowered = false; private AEPartLocation pushDirection = AEPartLocation.INTERNAL; - private ItemStack myPattern = null; + private ItemStack myPattern = ItemStack.EMPTY; private ICraftingPatternDetails myPlan = null; private double progress = 0; private boolean isAwake = false; @@ -114,12 +114,12 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade @Override public boolean pushPattern( final ICraftingPatternDetails patternDetails, final InventoryCrafting table, final EnumFacing where ) { - if( this.myPattern == null ) + if( this.myPattern.isEmpty() ) { boolean isEmpty = true; for( int x = 0; x < this.inv.getSizeInventory(); x++ ) { - isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty; + isEmpty = this.inv.getStackInSlot( x ).isEmpty() && isEmpty; } if( isEmpty && patternDetails.isCraftable() ) @@ -167,7 +167,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private boolean canPush() { - return this.inv.getStackInSlot( 9 ) != null; + return !this.inv.getStackInSlot( 9 ).isEmpty(); } private boolean hasMats() @@ -182,13 +182,13 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); } - return this.myPlan.getOutput( this.craftingInv, this.getWorld() ) != null; + return !this.myPlan.getOutput( this.craftingInv, this.getWorld() ).isEmpty(); } @Override public boolean acceptsPlans() { - return this.inv.getStackInSlot( 10 ) == null; + return this.inv.getStackInSlot( 10 ).isEmpty(); } @Override @@ -217,7 +217,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade if( this.forcePlan && this.myPlan != null ) { final ItemStack pattern = this.myPlan.getPattern(); - if( pattern != null ) + if( !pattern.isEmpty() ) { final NBTTagCompound compound = new NBTTagCompound(); pattern.writeToNBT( compound ); @@ -238,7 +238,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) ); - if( myPat != null && myPat.getItem() instanceof ItemEncodedPattern ) + if( !myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern ) { final World w = this.getWorld(); final ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); @@ -269,7 +269,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade final ItemStack is = this.inv.getStackInSlot( 10 ); - if( is != null && is.getItem() instanceof ItemEncodedPattern ) + if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern ) { if( !Platform.itemComparisons().isEqualItem( is, this.myPattern ) ) { @@ -290,7 +290,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.progress = 0; this.forcePlan = false; this.myPlan = null; - this.myPattern = null; + this.myPattern = ItemStack.EMPTY; this.pushDirection = AEPartLocation.INTERNAL; } @@ -367,7 +367,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private boolean hasPattern() { - return this.myPlan != null && this.inv.getStackInSlot( 10 ) != null; + return this.myPlan != null && !this.inv.getStackInSlot( 10 ).isEmpty(); } @Override @@ -404,7 +404,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade for( int h = 0; h < this.upgrades.getSizeInventory(); h++ ) { final ItemStack is = this.upgrades.getStackInSlot( h ); - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -422,12 +422,12 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade @Override public TickRateModulation tickingRequest( final IGridNode node, int ticksSinceLastCall ) { - if( this.inv.getStackInSlot( 9 ) != null ) + if( !this.inv.getStackInSlot( 9 ).isEmpty() ) { this.pushOut( this.inv.getStackInSlot( 9 ) ); // did it eject? - if( this.inv.getStackInSlot( 9 ) == null ) + if( this.inv.getStackInSlot( 9 ).isEmpty() ) { this.markDirty(); } @@ -487,7 +487,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.progress = 0; final ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorld() ); - if( output != null ) + if( !output.isEmpty() ) { FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorld() ), output, this.craftingInv ); @@ -498,7 +498,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) ); } - if( this.inv.getStackInSlot( 10 ) == null ) + if( this.inv.getStackInSlot( 10 ).isEmpty() ) { this.forcePlan = false; this.myPlan = null; @@ -529,17 +529,17 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private void ejectHeldItems() { - if( this.inv.getStackInSlot( 9 ) == null ) + if( this.inv.getStackInSlot( 9 ).isEmpty() ) { for( int x = 0; x < 9; x++ ) { final ItemStack is = this.inv.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { if( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.world ) ) { this.inv.setInventorySlotContents( 9, is ); - this.inv.setInventorySlotContents( x, null ); + this.inv.setInventorySlotContents( x, ItemStack.EMPTY ); this.markDirty(); return; } @@ -574,7 +574,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade output = this.pushTo( output, this.pushDirection.getFacing() ); } - if( output == null && this.forcePlan ) + if( output.isEmpty() && this.forcePlan ) { this.forcePlan = false; this.recalculatePlan(); @@ -585,7 +585,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private ItemStack pushTo( ItemStack output, final EnumFacing d ) { - if( output == null ) + if( output.isEmpty() ) { return output; } @@ -606,7 +606,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade final int size = output.getCount(); output = adaptor.addItems( output ); - final int newSize = output == null ? 0 : output.getCount(); + final int newSize = output.isEmpty() ? 0 : output.getCount(); if( size != newSize ) { diff --git a/src/main/java/appeng/tile/grindstone/TileGrinder.java b/src/main/java/appeng/tile/grindstone/TileGrinder.java index 71ba1d4a3..7d711c4a0 100644 --- a/src/main/java/appeng/tile/grindstone/TileGrinder.java +++ b/src/main/java/appeng/tile/grindstone/TileGrinder.java @@ -177,7 +177,7 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable } } ); - this.setInventorySlotContents( 6, null ); + this.setInventorySlotContents( 6, ItemStack.EMPTY ); } } @@ -189,7 +189,7 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable } final ItemStack notAdded = sia.addItems( output ); - if( notAdded != null ) + if( !notAdded.isEmpty() ) { final List out = new ArrayList(); out.add( notAdded ); diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java index 7d9ae36b4..cf8ce6cc3 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java @@ -56,7 +56,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable= split.getCount() ) { @@ -168,7 +168,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable newItemStack.getCount() ) { removed = removed.copy(); removed.grow( -newItemStack.getCount() ); - added = null; + added = ItemStack.EMPTY; } else if( oldStack.getCount() < newItemStack.getCount() ) { added = added.copy(); added.grow( -oldStack.getCount() ); - removed = null; + removed = ItemStack.EMPTY; } else { - removed = added = null; + removed = added = ItemStack.EMPTY; } } @@ -241,7 +241,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable @Override public ItemStack getStackInSlot( final int var1 ) { - return this.inv[var1]; + return this.inv[var1] == null ? ItemStack.EMPTY : this.inv[var1]; } @Override @@ -78,12 +78,12 @@ public class AppEngInternalInventory implements IInventory, Iterable if( this.inv[slot] != null ) { final ItemStack split = this.getStackInSlot( slot ); - ItemStack ns = null; + ItemStack ns = ItemStack.EMPTY; if( qty >= split.getCount() ) { ns = this.inv[slot]; - this.inv[slot] = null; + this.inv[slot] = ItemStack.EMPTY; } else { @@ -92,7 +92,7 @@ public class AppEngInternalInventory implements IInventory, Iterable if( this.getTileEntity() != null && this.eventsEnabled() ) { - this.getTileEntity().onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null ); + this.getTileEntity().onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, ItemStack.EMPTY ); } this.markDirty(); @@ -124,7 +124,7 @@ public class AppEngInternalInventory implements IInventory, Iterable ItemStack removed = oldStack; ItemStack added = newItemStack; - if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) ) + if( !oldStack.isEmpty() && !newItemStack.isEmpty() && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) ) { if( oldStack.getCount() > newItemStack.getCount() ) { @@ -136,11 +136,11 @@ public class AppEngInternalInventory implements IInventory, Iterable { added = added.copy(); added.grow( -oldStack.getCount() ); - removed = null; + removed = ItemStack.EMPTY; } else { - removed = added = null; + removed = added = ItemStack.EMPTY; } } @@ -173,7 +173,7 @@ public class AppEngInternalInventory implements IInventory, Iterable { if( this.getTileEntity() != null && this.eventsEnabled() ) { - this.getTileEntity().onChangeInventory( this, -1, InvOperation.markDirty, null, null ); + this.getTileEntity().onChangeInventory( this, -1, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY ); } } @@ -199,7 +199,7 @@ public class AppEngInternalInventory implements IInventory, Iterable { if( this.getTileEntity() != null && this.eventsEnabled() ) { - this.getTileEntity().onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null ); + this.getTileEntity().onChangeInventory( this, slotIndex, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY ); } } @@ -306,7 +306,7 @@ public class AppEngInternalInventory implements IInventory, Iterable { for( int x = 0; x < this.size; x++ ) { - this.setInventorySlotContents( x, null ); + this.setInventorySlotContents( x, ItemStack.EMPTY ); } } diff --git a/src/main/java/appeng/tile/misc/TileCellWorkbench.java b/src/main/java/appeng/tile/misc/TileCellWorkbench.java index 2f08e8215..4cd9f04e9 100644 --- a/src/main/java/appeng/tile/misc/TileCellWorkbench.java +++ b/src/main/java/appeng/tile/misc/TileCellWorkbench.java @@ -72,7 +72,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I } final ItemStack is = this.cell.getStackInSlot( 0 ); - if( is == null ) + if( is.isEmpty() ) { return null; } @@ -90,7 +90,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I public ICellWorkbenchItem getCell() { - if( this.cell.getStackInSlot( 0 ) == null ) + if( this.cell.getStackInSlot( 0 ).isEmpty() ) { return null; } @@ -157,7 +157,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I boolean cellHasConfig = false; for( int x = 0; x < configInventory.getSizeInventory(); x++ ) { - if( configInventory.getStackInSlot( x ) != null ) + if( !configInventory.getStackInSlot( x ).isEmpty() ) { cellHasConfig = true; break; @@ -185,7 +185,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I { for( int x = 0; x < this.config.getSizeInventory(); x++ ) { - this.config.setInventorySlotContents( x, null ); + this.config.setInventorySlotContents( x, ItemStack.EMPTY ); } this.markDirty(); @@ -219,7 +219,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I } final ItemStack is = this.cell.getStackInSlot( 0 ); - if( is == null ) + if( is.isEmpty() ) { return null; } diff --git a/src/main/java/appeng/tile/misc/TileCharger.java b/src/main/java/appeng/tile/misc/TileCharger.java index bfd9c777d..d52490ad0 100644 --- a/src/main/java/appeng/tile/misc/TileCharger.java +++ b/src/main/java/appeng/tile/misc/TileCharger.java @@ -93,7 +93,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid } catch( final Throwable t ) { - this.inv.setInventorySlotContents( 0, null ); + this.inv.setInventorySlotContents( 0, ItemStack.EMPTY ); } return false; // TESR doesn't need updates! } @@ -217,7 +217,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid } final ItemStack myItem = this.getStackInSlot( 0 ); - if( myItem == null ) + if( myItem.isEmpty() ) { ItemStack held = player.inventory.getCurrentItem(); @@ -231,7 +231,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid { final List drops = new ArrayList(); drops.add( myItem ); - this.setInventorySlotContents( 0, null ); + this.setInventorySlotContents( 0, ItemStack.EMPTY ); Platform.spawnDrops( this.world, this.pos.offset( this.getForward() ), drops ); } } @@ -267,7 +267,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid return true; } - if( myItem == null ) + if( myItem.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/tile/misc/TileCondenser.java b/src/main/java/appeng/tile/misc/TileCondenser.java index f80a215b3..db13ed238 100644 --- a/src/main/java/appeng/tile/misc/TileCondenser.java +++ b/src/main/java/appeng/tile/misc/TileCondenser.java @@ -97,7 +97,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, public double getStorage() { final ItemStack is = this.inv.getStackInSlot( 2 ); - if( is != null ) + if( !is.isEmpty() ) { if( is.getItem() instanceof IStorageComponent ) { @@ -118,7 +118,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, final double requiredPower = this.getRequiredPower(); final ItemStack output = this.getOutput(); - while( requiredPower <= this.getStoredPower() && output != null && requiredPower > 0 ) + while( requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0 ) { if( this.canAddOutput( output ) ) { @@ -135,7 +135,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, private boolean canAddOutput( final ItemStack output ) { final ItemStack outputStack = this.getStackInSlot( 1 ); - return outputStack == null || ( Platform.itemComparisons().isEqualItem( outputStack, + return outputStack.isEmpty() || ( Platform.itemComparisons().isEqualItem( outputStack, output ) && outputStack.getCount() < outputStack.getMaxStackSize() ); } @@ -147,7 +147,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, private void addOutput( final ItemStack output ) { final ItemStack outputStack = this.getStackInSlot( 1 ); - if( outputStack == null ) + if( outputStack.isEmpty() ) { this.setInventorySlotContents( 1, output.copy() ); } @@ -165,10 +165,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) ) { case MATTER_BALLS: - return materials.matterBall().maybeStack( 1 ).orElse( null ); + return materials.matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY ); case SINGULARITY: - return materials.singularity().maybeStack( 1 ).orElse( null ); + return materials.singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY ); case TRASH: default: @@ -192,7 +192,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, { if( i == 0 ) { - if( itemstack != null ) + if( !itemstack.isEmpty() ) { this.addPower( itemstack.getCount() ); } @@ -215,10 +215,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, if( slot == 0 ) { final ItemStack is = inv.getStackInSlot( 0 ); - if( is != null ) + if( !is.isEmpty() ) { this.addPower( is.getCount() ); - inv.setInventorySlotContents( 0, null ); + inv.setInventorySlotContents( 0, ItemStack.EMPTY ); } } } @@ -324,7 +324,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost, { return stack; } - if( !simulate && stack != null ) + if( !simulate && !stack.isEmpty() ) { addPower( stack.getCount() ); } diff --git a/src/main/java/appeng/tile/misc/TileInscriber.java b/src/main/java/appeng/tile/misc/TileInscriber.java index c5c6af0a5..fdda5db18 100644 --- a/src/main/java/appeng/tile/misc/TileInscriber.java +++ b/src/main/java/appeng/tile/misc/TileInscriber.java @@ -168,7 +168,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } else { - this.inv.setInventorySlotContents( num, null ); + this.inv.setInventorySlotContents( num, ItemStack.EMPTY ); } } @@ -215,7 +215,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, for( int h = 0; h < this.upgrades.getSizeInventory(); h++ ) { final ItemStack is = this.upgrades.getStackInSlot( h ); - if( is != null ) + if( !is.isEmpty() ) { drops.add( is ); } @@ -344,17 +344,17 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, final ItemStack plateB = this.getStackInSlot( 1 ); ItemStack renamedItem = this.getStackInSlot( 2 ); - if( plateA != null && plateA.getCount() > 1 ) + if( !plateA.isEmpty() && plateA.getCount() > 1 ) { return null; } - if( plateB != null && plateB.getCount() > 1 ) + if( !plateB.isEmpty() && plateB.getCount() > 1 ) { return null; } - if( renamedItem != null && renamedItem.getCount() > 1 ) + if( !renamedItem.isEmpty() && renamedItem.getCount() > 1 ) { return null; } @@ -363,19 +363,19 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, final boolean isNameA = namePress.isSameAs( plateA ); final boolean isNameB = namePress.isSameAs( plateB ); - if( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) ) + if( ( isNameA || isNameB ) && ( isNameA || plateA.isEmpty() ) && ( isNameB || plateB.isEmpty() ) ) { - if( renamedItem != null ) + if( !renamedItem.isEmpty() ) { String name = ""; - if( plateA != null ) + if( !plateA.isEmpty() ) { final NBTTagCompound tag = Platform.openNbtData( plateA ); name += tag.getString( "InscribeName" ); } - if( plateB != null ) + if( !plateB.isEmpty() ) { final NBTTagCompound tag = Platform.openNbtData( plateB ); if( name.length() > 0 ) @@ -417,15 +417,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() ) { - final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, - recipe.getTopOptional().orElse( null ) ) ) && // and... - ( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB, - recipe.getBottomOptional().orElse( null ) ) ); + final boolean matchA = ( plateA.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, + recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... + ( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB, + recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ); - final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, - recipe.getTopOptional().orElse( null ) ) ) && // and... - ( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA, - recipe.getBottomOptional().orElse( null ) ) ); + final boolean matchB = ( plateB.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, + recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and... + ( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA, + recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ); if( matchA || matchB ) { @@ -455,15 +455,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, final ItemStack outputCopy = out.getOutput().copy(); final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, SLOT_OUT, 1, true ), EnumFacing.UP ); - if( ad.addItems( outputCopy ) == null ) + if( ad.addItems( outputCopy ).isEmpty() ) { this.setProcessingTime( 0 ); if( out.getProcessType() == InscriberProcessType.PRESS ) { - this.setInventorySlotContents( SLOT_TOP, null ); - this.setInventorySlotContents( SLOT_BOTTOM, null ); + this.setInventorySlotContents( SLOT_TOP, ItemStack.EMPTY ); + this.setInventorySlotContents( SLOT_BOTTOM, ItemStack.EMPTY ); } - this.setInventorySlotContents( SLOT_MIDDLE, null ); + this.setInventorySlotContents( SLOT_MIDDLE, ItemStack.EMPTY ); } } @@ -522,7 +522,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, { final ItemStack outputCopy = out.getOutput().copy(); final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, SLOT_OUT, 1, true ), EnumFacing.UP ); - if( ad.simulateAdd( outputCopy ) == null ) + if( ad.simulateAdd( outputCopy ).isEmpty() ) { this.setSmash( true ); this.finalStep = 0; @@ -678,13 +678,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, @Override public ItemStack insertItem( int slot, ItemStack stack, boolean simulate ) { - if( slot != 0 || stack == null ) + if( slot != 0 || stack.isEmpty() ) { return stack; } // If there's already an item stack in the slot, we don't allow insertion and don't do any other checks - if( inv.getStackInSlot( insertSlot ) != null ) + if( !inv.getStackInSlot( insertSlot ).isEmpty() ) { return stack; } @@ -715,11 +715,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, if( simulate ) { - return adapter.simulateRemove( amount, null, null ); + return adapter.simulateRemove( amount, ItemStack.EMPTY, null ); } else { - return adapter.removeItems( amount, null, null ); + return adapter.removeItems( amount, ItemStack.EMPTY, null ); } } diff --git a/src/main/java/appeng/tile/misc/TileVibrationChamber.java b/src/main/java/appeng/tile/misc/TileVibrationChamber.java index 55fafebd0..a5f097419 100644 --- a/src/main/java/appeng/tile/misc/TileVibrationChamber.java +++ b/src/main/java/appeng/tile/misc/TileVibrationChamber.java @@ -157,7 +157,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka private boolean canEatFuel() { final ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX ); - if( is != null ) + if( !is.isEmpty() ) { final int newBurnTime = TileEntityFurnace.getItemBurnTime( is ); if( newBurnTime > 0 && is.getCount() > 0 ) @@ -244,7 +244,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka private void eatFuel() { final ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX ); - if( is != null ) + if( !is.isEmpty() ) { final int newBurnTime = TileEntityFurnace.getItemBurnTime( is ); if( newBurnTime > 0 && is.getCount() > 0 ) diff --git a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java index 2a13e5e48..b830459cc 100644 --- a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java +++ b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java @@ -94,7 +94,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { int out = this.constructed; - if( this.getStackInSlot( 0 ) != null && this.constructed != -1 ) + if( !this.getStackInSlot( 0 ).isEmpty() && this.constructed != -1 ) { out |= this.hasSingularity; } @@ -272,7 +272,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock public long getQEFrequency() { final ItemStack is = this.internalInventory.getStackInSlot( 0 ); - if( is != null ) + if( !is.isEmpty() ) { final NBTTagCompound c = is.getTagCompound(); if( c != null ) diff --git a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java index 5f8b1e462..b40266fb4 100644 --- a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java +++ b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java @@ -114,7 +114,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl private boolean isSpatialCell( final ItemStack cell ) { - if( cell != null && cell.getItem() instanceof ISpatialStorageCell ) + if( !cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell ) { final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem(); return sc != null && sc.isSpatialStorage( cell ); @@ -126,7 +126,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl public Void call( final World world ) throws Exception { final ItemStack cell = this.getStackInSlot( 0 ); - if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null ) + if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ).isEmpty() ) { final IGrid gi = this.getProxy().getGrid(); final IEnergyGrid energy = this.getProxy().getEnergy(); @@ -147,7 +147,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl if( tr.success ) { energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG ); - this.setInventorySlotContents( 0, null ); + this.setInventorySlotContents( 0, ItemStack.EMPTY ); this.setInventorySlotContents( 1, cell ); } } diff --git a/src/main/java/appeng/tile/storage/TileChest.java b/src/main/java/appeng/tile/storage/TileChest.java index f06c8ecce..2cbb0e16e 100644 --- a/src/main/java/appeng/tile/storage/TileChest.java +++ b/src/main/java/appeng/tile/storage/TileChest.java @@ -199,7 +199,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal this.fluidCell = null; final ItemStack is = this.inv.getStackInSlot( 1 ); - if( is != null ) + if( !is.isEmpty() ) { this.isCached = true; this.cellHandler = AEApi.instance().registries().cell().getHandler( is ); @@ -393,7 +393,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal } } - if( this.inv.getStackInSlot( 0 ) != null ) + if( !this.inv.getStackInSlot( 0 ).isEmpty() ) { this.tryToStoreContents(); } @@ -430,7 +430,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal final ItemStack is = this.inv.getStackInSlot( 1 ); - if( is == null ) + if( is.isEmpty() ) { data.writeInt( 0 ); } @@ -454,7 +454,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal if( item == 0 ) { - this.storageType = null; + this.storageType = ItemStack.EMPTY; } else { @@ -616,7 +616,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal { try { - if( this.getStackInSlot( 0 ) != null ) + if( !this.getStackInSlot( 0 ).isEmpty() ) { final IMEInventory cell = this.getHandler( StorageChannel.ITEMS ); @@ -624,7 +624,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal if( returns == null ) { - this.inv.setInventorySlotContents( 0, null ); + this.inv.setInventorySlotContents( 0, ItemStack.EMPTY ); } else { diff --git a/src/main/java/appeng/tile/storage/TileDrive.java b/src/main/java/appeng/tile/storage/TileDrive.java index e7e73b430..f0fe55565 100644 --- a/src/main/java/appeng/tile/storage/TileDrive.java +++ b/src/main/java/appeng/tile/storage/TileDrive.java @@ -241,7 +241,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior @MENetworkEventSubscribe public void channelRender( final MENetworkChannelsChanged c ) { - this.recalculateDisplay(); + this.recalculateDisplay(); } @Override @@ -312,7 +312,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior this.invBySlot[x] = null; this.handlersBySlot[x] = null; - if( is != null ) + if( !is.isEmpty() ) { this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is ); diff --git a/src/main/java/appeng/tile/storage/TileIOPort.java b/src/main/java/appeng/tile/storage/TileIOPort.java index 63273e0d4..9d45bf3ca 100644 --- a/src/main/java/appeng/tile/storage/TileIOPort.java +++ b/src/main/java/appeng/tile/storage/TileIOPort.java @@ -343,7 +343,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC for( int x = 0; x < 6; x++ ) { final ItemStack is = this.cells.getStackInSlot( x ); - if( is != null ) + if( !is.isEmpty() ) { if( ItemsToMove > 0 ) { @@ -513,9 +513,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC final WrapperInventoryRange wir = new WrapperInventoryRange( this, this.output, true ); final ItemStack result = InventoryAdaptor.getAdaptor( wir, EnumFacing.UP ).addItems( this.getStackInSlot( x ) ); - if( result == null ) + if( result.isEmpty() ) { - this.setInventorySlotContents( x, null ); + this.setInventorySlotContents( x, ItemStack.EMPTY ); return true; } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 275ea81e9..d69485ad0 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -538,7 +538,7 @@ public class Platform { for( final ItemStack i : drops ) { - if( i != null ) + if( !i.isEmpty() ) { if( i.getCount() > 0 ) { @@ -790,7 +790,7 @@ public class Platform public static boolean isWrench( final EntityPlayer player, final ItemStack eq, final BlockPos pos ) { - if( eq != null ) + if( !eq.isEmpty() ) { try { @@ -819,7 +819,7 @@ public class Platform public static boolean isChargeable( final ItemStack i ) { - if( i == null ) + if( i.isEmpty() ) { return false; } @@ -1345,7 +1345,7 @@ public class Platform final IItemList itemChanges = AEApi.instance().storage().createItemList(); final IItemList fluidChanges = AEApi.instance().storage().createFluidList(); - if( removed != null ) + if( !removed.isEmpty() ) { final IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( removed, null, StorageChannel.ITEMS ); @@ -1368,7 +1368,7 @@ public class Platform } } - if( added != null ) + if( !added.isEmpty() ) { final IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( added, null, StorageChannel.ITEMS ); @@ -1641,7 +1641,7 @@ public class Platform if( ae_ext != null ) { final ItemStack extracted = ae_ext.getItemStack(); - if( extracted != null ) + if( !extracted.isEmpty() ) { energySrc.extractAEPower( 1, realForFake, PowerMultiplier.CONFIG ); return extracted; @@ -1709,7 +1709,7 @@ public class Platform } ItemStack ci = i.getContainerItem( stackInSlot.copy() ); - if( ci != null && ci.isItemStackDamageable() && ci.getItemDamage() == ci.getMaxDamage() ) + if( !ci.isEmpty() && ci.isItemStackDamageable() && ci.getItemDamage() == ci.getMaxDamage() ) { ci = ItemStack.EMPTY; } @@ -1727,7 +1727,7 @@ public class Platform public static boolean canRepair( final AEFeature type, final ItemStack a, final ItemStack b ) { - if( b == null || a == null ) + if( b.isEmpty() || a.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/util/helpers/ItemComparisonHelper.java b/src/main/java/appeng/util/helpers/ItemComparisonHelper.java index c20df9023..9c326d0e0 100644 --- a/src/main/java/appeng/util/helpers/ItemComparisonHelper.java +++ b/src/main/java/appeng/util/helpers/ItemComparisonHelper.java @@ -63,7 +63,7 @@ public class ItemComparisonHelper */ public boolean isEqualItemType( final ItemStack that, final ItemStack other ) { - if( that != null && other != null && that.getItem() == other.getItem() ) + if( !that.isEmpty() && !other.isEmpty() && that.getItem() == other.getItem() ) { if( that.isItemStackDamageable() ) { @@ -80,9 +80,12 @@ public class ItemComparisonHelper * The benefit is to compare two null item stacks, without any additional null checks. * * Ignores NBT. + * + * Deprecated because ItemStack should never be null...? * * @return true, if both are equal. */ + @Deprecated public boolean isEqualItem( @Nullable final ItemStack left, @Nullable final ItemStack right ) { return left != null && right != null && left.isItemEqual( right ); @@ -93,9 +96,12 @@ public class ItemComparisonHelper * * Use this when a precise check is required and the same item is required. * Not just something with different NBT tags. - * + * + * Deprecated because ItemStack should never be null...? + * * @return true, if both are identical. */ + @Deprecated public boolean isSameItem( @Nullable final ItemStack is, @Nullable final ItemStack filter ) { return isEqualItem( is, filter ) && hasSameNbtTag( is, filter ); @@ -111,12 +117,12 @@ public class ItemComparisonHelper */ public boolean isFuzzyEqualItem( final ItemStack a, final ItemStack b, final FuzzyMode mode ) { - if( a == null && b == null ) + if( a.isEmpty() && b.isEmpty() ) { return true; } - if( a == null || b == null ) + if( a.isEmpty() || b.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/util/inv/AdaptorIInventory.java b/src/main/java/appeng/util/inv/AdaptorIInventory.java index 1cbda48a1..7282f81b8 100644 --- a/src/main/java/appeng/util/inv/AdaptorIInventory.java +++ b/src/main/java/appeng/util/inv/AdaptorIInventory.java @@ -22,6 +22,7 @@ package appeng.util.inv; import java.util.Iterator; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import appeng.api.config.FuzzyMode; @@ -45,12 +46,12 @@ public class AdaptorIInventory extends InventoryAdaptor public ItemStack removeItems( int amount, ItemStack filter, final IInventoryDestination destination ) { final int s = this.i.getSizeInventory(); - ItemStack rv = null; + ItemStack rv = ItemStack.EMPTY; for( int x = 0; x < s && amount > 0; x++ ) { final ItemStack is = this.i.getStackInSlot( x ); - if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( !is.isEmpty() && this.canRemoveStackFromSlot( x, is ) && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) { int boundAmounts = amount; if( boundAmounts > is.getCount() ) @@ -64,7 +65,7 @@ public class AdaptorIInventory extends InventoryAdaptor if( boundAmounts > 0 ) { - if( rv == null ) + if( rv.isEmpty() ) { rv = is.copy(); filter = rv; @@ -79,7 +80,7 @@ public class AdaptorIInventory extends InventoryAdaptor if( is.getCount() == boundAmounts ) { - this.i.setInventorySlotContents( x, null ); + this.i.setInventorySlotContents( x, ItemStack.EMPTY ); this.i.markDirty(); } else @@ -103,12 +104,12 @@ public class AdaptorIInventory extends InventoryAdaptor public ItemStack simulateRemove( int amount, final ItemStack filter, final IInventoryDestination destination ) { final int s = this.i.getSizeInventory(); - ItemStack rv = null; + ItemStack rv = ItemStack.EMPTY; for( int x = 0; x < s && amount > 0; x++ ) { final ItemStack is = this.i.getStackInSlot( x ); - if( is != null && this.canRemoveStackFromSlot( x, is ) && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( !is.isEmpty() && this.canRemoveStackFromSlot( x, is ) && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) { int boundAmount = amount; if( boundAmount > is.getCount() ) @@ -122,7 +123,7 @@ public class AdaptorIInventory extends InventoryAdaptor if( boundAmount > 0 ) { - if( rv == null ) + if( rv.isEmpty() ) { rv = is.copy(); rv.setCount( boundAmount ); @@ -147,8 +148,8 @@ public class AdaptorIInventory extends InventoryAdaptor for( int x = 0; x < s; x++ ) { final ItemStack is = this.i.getStackInSlot( x ); - if( is != null && this.canRemoveStackFromSlot( x, - is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( !is.isEmpty() && this.canRemoveStackFromSlot( x, + is ) && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { int newAmount = amount; if( newAmount > is.getCount() ) @@ -160,7 +161,7 @@ public class AdaptorIInventory extends InventoryAdaptor newAmount = 0; } - ItemStack rv = null; + ItemStack rv = ItemStack.EMPTY; if( newAmount > 0 ) { rv = is.copy(); @@ -168,7 +169,7 @@ public class AdaptorIInventory extends InventoryAdaptor if( is.getCount() == rv.getCount() ) { - this.i.setInventorySlotContents( x, null ); + this.i.setInventorySlotContents( x, ItemStack.EMPTY ); this.i.markDirty(); } else @@ -180,14 +181,14 @@ public class AdaptorIInventory extends InventoryAdaptor } } - if( rv != null ) + if( !rv.isEmpty() ) { // i.markDirty(); return rv; } } } - return null; + return ItemStack.EMPTY; } @Override @@ -198,8 +199,8 @@ public class AdaptorIInventory extends InventoryAdaptor { final ItemStack is = this.i.getStackInSlot( x ); - if( is != null && this.canRemoveStackFromSlot( x, - is ) && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( !is.isEmpty() && this.canRemoveStackFromSlot( x, + is ) && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { int boundAmount = amount; if( boundAmount > is.getCount() ) @@ -219,7 +220,7 @@ public class AdaptorIInventory extends InventoryAdaptor } } } - return null; + return ItemStack.EMPTY; } @Override @@ -240,7 +241,7 @@ public class AdaptorIInventory extends InventoryAdaptor final int s = this.i.getSizeInventory(); for( int x = 0; x < s; x++ ) { - if( this.i.getStackInSlot( x ) != null ) + if( !this.i.getStackInSlot( x ).isEmpty() ) { return true; } @@ -262,7 +263,7 @@ public class AdaptorIInventory extends InventoryAdaptor */ private ItemStack addItems( final ItemStack itemsToAdd, final boolean modulate ) { - if( itemsToAdd == null || itemsToAdd.getCount() == 0 ) + if( itemsToAdd.isEmpty() || itemsToAdd.getCount() == 0 ) { return ItemStack.EMPTY; } @@ -280,7 +281,7 @@ public class AdaptorIInventory extends InventoryAdaptor if( this.i.isItemValidForSlot( slot, next ) ) { final ItemStack is = this.i.getStackInSlot( slot ); - if( is == null ) + if( is.isEmpty() ) { left.grow( -next.getCount() ); diff --git a/src/main/java/appeng/util/inv/AdaptorItemHandler.java b/src/main/java/appeng/util/inv/AdaptorItemHandler.java index b2d8d38e9..6025d7400 100644 --- a/src/main/java/appeng/util/inv/AdaptorItemHandler.java +++ b/src/main/java/appeng/util/inv/AdaptorItemHandler.java @@ -42,12 +42,12 @@ public class AdaptorItemHandler extends InventoryAdaptor public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination ) { int slots = itemHandler.getSlots(); - ItemStack rv = null; + ItemStack rv = ItemStack.EMPTY; for( int slot = 0; slot < slots && amount > 0; slot++ ) { final ItemStack is = itemHandler.getStackInSlot( slot ); - if( is == null || ( filter != null && !Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isSameItem( is, filter ) ) ) { continue; } @@ -55,7 +55,7 @@ public class AdaptorItemHandler extends InventoryAdaptor if( destination != null ) { ItemStack extracted = itemHandler.extractItem( slot, amount, true ); - if( extracted == null ) + if( extracted.isEmpty() ) { continue; } @@ -69,12 +69,12 @@ public class AdaptorItemHandler extends InventoryAdaptor // Attempt extracting it ItemStack extracted = itemHandler.extractItem( slot, amount, false ); - if( extracted == null ) + if( extracted.isEmpty() ) { continue; } - if( rv == null ) + if( rv.isEmpty() ) { // Use the first stack as a template for the result rv = extracted; @@ -96,16 +96,16 @@ public class AdaptorItemHandler extends InventoryAdaptor public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination ) { int slots = itemHandler.getSlots(); - ItemStack rv = null; + ItemStack rv = ItemStack.EMPTY; for( int slot = 0; slot < slots && amount > 0; slot++ ) { final ItemStack is = itemHandler.getStackInSlot( slot ); - if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) { ItemStack extracted = itemHandler.extractItem( slot, amount, true ); - if( extracted == null ) + if( extracted.isEmpty() ) { continue; } @@ -118,7 +118,7 @@ public class AdaptorItemHandler extends InventoryAdaptor } } - if( rv == null ) + if( rv.isEmpty() ) { // Use the first stack as a template for the result rv = extracted.copy(); @@ -145,12 +145,12 @@ public class AdaptorItemHandler extends InventoryAdaptor public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) { int slots = itemHandler.getSlots(); - ItemStack extracted = null; + ItemStack extracted = ItemStack.EMPTY; - for( int slot = 0; slot < slots && extracted == null; slot++ ) + for( int slot = 0; slot < slots && extracted.isEmpty(); slot++ ) { final ItemStack is = itemHandler.getStackInSlot( slot ); - if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { continue; } @@ -158,7 +158,7 @@ public class AdaptorItemHandler extends InventoryAdaptor if( destination != null ) { ItemStack simulated = itemHandler.extractItem( slot, amount, true ); - if( simulated == null ) + if( simulated.isEmpty() ) { continue; } @@ -180,12 +180,12 @@ public class AdaptorItemHandler extends InventoryAdaptor public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) { int slots = itemHandler.getSlots(); - ItemStack extracted = null; + ItemStack extracted = ItemStack.EMPTY; - for( int slot = 0; slot < slots && extracted == null; slot++ ) + for( int slot = 0; slot < slots && extracted.isEmpty(); slot++ ) { final ItemStack is = itemHandler.getStackInSlot( slot ); - if( is == null || ( filter != null && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( is.isEmpty() || ( !filter.isEmpty() && !Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { continue; } @@ -193,11 +193,11 @@ public class AdaptorItemHandler extends InventoryAdaptor // Attempt extracting it extracted = itemHandler.extractItem( slot, amount, true ); - if( extracted != null && destination != null ) + if( !extracted.isEmpty() && destination != null ) { if( !destination.canInsert( extracted ) ) { - extracted = null; // Keep on looking... + extracted = ItemStack.EMPTY; // Keep on looking... } } } @@ -219,9 +219,9 @@ public class AdaptorItemHandler extends InventoryAdaptor private ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate ) { - if( itemsToAdd == null || itemsToAdd.getCount() == 0 ) + if( itemsToAdd.isEmpty() || itemsToAdd.getCount() == 0 ) { - return null; + return ItemStack.EMPTY; } ItemStack left = itemsToAdd.copy(); @@ -230,13 +230,13 @@ public class AdaptorItemHandler extends InventoryAdaptor { ItemStack is = itemHandler.getStackInSlot( slot ); - if( is == null || Platform.itemComparisons().isSameItem( is, left ) ) + if( is.isEmpty() || Platform.itemComparisons().isSameItem( is, left ) ) { left = itemHandler.insertItem( slot, left, simulate ); - if( left == null || left.getCount() <= 0 ) + if( left.isEmpty() || left.getCount() <= 0 ) { - return null; + return ItemStack.EMPTY; } } } @@ -250,7 +250,7 @@ public class AdaptorItemHandler extends InventoryAdaptor int slots = itemHandler.getSlots(); for( int slot = 0; slot < slots; slot++ ) { - if( itemHandler.getStackInSlot( slot ) != null ) + if( !itemHandler.getStackInSlot( slot ).isEmpty() ) { return true; } diff --git a/src/main/java/appeng/util/inv/AdaptorList.java b/src/main/java/appeng/util/inv/AdaptorList.java index ca329ab38..eb2589409 100644 --- a/src/main/java/appeng/util/inv/AdaptorList.java +++ b/src/main/java/appeng/util/inv/AdaptorList.java @@ -47,7 +47,7 @@ public class AdaptorList extends InventoryAdaptor for( int x = 0; x < s; x++ ) { final ItemStack is = this.i.get( x ); - if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) { if( amount > is.getCount() ) { @@ -74,7 +74,7 @@ public class AdaptorList extends InventoryAdaptor } } } - return null; + return ItemStack.EMPTY; } @Override @@ -82,7 +82,7 @@ public class AdaptorList extends InventoryAdaptor { for( final ItemStack is : this.i ) { - if( is != null && ( filter == null || Platform.itemComparisons().isSameItem( is, filter ) ) ) + if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isSameItem( is, filter ) ) ) { if( amount > is.getCount() ) { @@ -101,7 +101,7 @@ public class AdaptorList extends InventoryAdaptor } } } - return null; + return ItemStack.EMPTY; } @Override @@ -111,7 +111,7 @@ public class AdaptorList extends InventoryAdaptor for( int x = 0; x < s; x++ ) { final ItemStack is = this.i.get( x ); - if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { if( amount > is.getCount() ) { @@ -138,7 +138,7 @@ public class AdaptorList extends InventoryAdaptor } } } - return null; + return ItemStack.EMPTY; } @Override @@ -146,7 +146,7 @@ public class AdaptorList extends InventoryAdaptor { for( final ItemStack is : this.i ) { - if( is != null && ( filter == null || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) + if( !is.isEmpty() && ( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( is, filter, fuzzyMode ) ) ) { if( amount > is.getCount() ) { @@ -165,19 +165,19 @@ public class AdaptorList extends InventoryAdaptor } } } - return null; + return ItemStack.EMPTY; } @Override public ItemStack addItems( final ItemStack toBeAdded ) { - if( toBeAdded == null ) + if( toBeAdded.isEmpty() ) { - return null; + return ItemStack.EMPTY; } if( toBeAdded.getCount() == 0 ) { - return null; + return ItemStack.EMPTY; } final ItemStack left = toBeAdded.copy(); @@ -187,18 +187,18 @@ public class AdaptorList extends InventoryAdaptor if( Platform.itemComparisons().isEqualItem( is, left ) ) { is.grow( left.getCount() ); - return null; + return ItemStack.EMPTY; } } this.i.add( left ); - return null; + return ItemStack.EMPTY; } @Override public ItemStack simulateAdd( final ItemStack toBeSimulated ) { - return null; + return ItemStack.EMPTY; } @Override @@ -206,7 +206,7 @@ public class AdaptorList extends InventoryAdaptor { for( final ItemStack is : this.i ) { - if( is != null ) + if( !is.isEmpty() ) { return true; } diff --git a/src/main/java/appeng/util/inv/AdaptorPlayerHand.java b/src/main/java/appeng/util/inv/AdaptorPlayerHand.java index 8811626be..ac13186ff 100644 --- a/src/main/java/appeng/util/inv/AdaptorPlayerHand.java +++ b/src/main/java/appeng/util/inv/AdaptorPlayerHand.java @@ -47,24 +47,24 @@ public class AdaptorPlayerHand extends InventoryAdaptor public ItemStack removeItems( final int amount, final ItemStack filter, final IInventoryDestination destination ) { final ItemStack hand = this.player.inventory.getItemStack(); - if( hand == null ) + if( hand.isEmpty() ) { - return null; + return ItemStack.EMPTY; } - if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) ) + if( filter.isEmpty() || Platform.itemComparisons().isSameItem( filter, hand ) ) { final ItemStack result = hand.copy(); result.setCount( hand.getCount() > amount ? amount : hand.getCount() ); hand.grow( -amount ); if( hand.getCount() <= 0 ) { - this.player.inventory.setItemStack( null ); + this.player.inventory.setItemStack( ItemStack.EMPTY ); } return result; } - return null; + return ItemStack.EMPTY; } @Override @@ -72,9 +72,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor { final ItemStack hand = this.player.inventory.getItemStack(); - if( hand == null ) + if( hand.isEmpty() ) { - return null; + return ItemStack.EMPTY; } if( filter == null || Platform.itemComparisons().isSameItem( filter, hand ) ) @@ -84,31 +84,31 @@ public class AdaptorPlayerHand extends InventoryAdaptor return result; } - return null; + return ItemStack.EMPTY; } @Override public ItemStack removeSimilarItems( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) { final ItemStack hand = this.player.inventory.getItemStack(); - if( hand == null ) + if( hand.isEmpty() ) { - return null; + return ItemStack.EMPTY; } - if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) ) + if( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) ) { final ItemStack result = hand.copy(); result.setCount( hand.getCount() > amount ? amount : hand.getCount() ); hand.grow( -amount ); if( hand.getCount() <= 0 ) { - this.player.inventory.setItemStack( null ); + this.player.inventory.setItemStack( ItemStack.EMPTY ); } return result; } - return null; + return ItemStack.EMPTY; } @Override @@ -116,32 +116,32 @@ public class AdaptorPlayerHand extends InventoryAdaptor { final ItemStack hand = this.player.inventory.getItemStack(); - if( hand == null ) + if( hand.isEmpty() ) { - return null; + return ItemStack.EMPTY; } - if( filter == null || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) ) + if( filter.isEmpty() || Platform.itemComparisons().isFuzzyEqualItem( filter, hand, fuzzyMode ) ) { final ItemStack result = hand.copy(); result.setCount( hand.getCount() > amount ? amount : hand.getCount() ); return result; } - return null; + return ItemStack.EMPTY; } @Override public ItemStack addItems( final ItemStack toBeAdded ) { - if( toBeAdded == null ) + if( toBeAdded.isEmpty() ) { - return null; + return ItemStack.EMPTY; } if( toBeAdded.getCount() == 0 ) { - return null; + return ItemStack.EMPTY; } if( this.player == null ) { @@ -154,14 +154,14 @@ public class AdaptorPlayerHand extends InventoryAdaptor final ItemStack hand = this.player.inventory.getItemStack(); - if( hand != null && !Platform.itemComparisons().isSameItem( toBeAdded, hand ) ) + if( !hand.isEmpty() && !Platform.itemComparisons().isSameItem( toBeAdded, hand ) ) { return toBeAdded; } int original = 0; - ItemStack newHand = null; - if( hand == null ) + ItemStack newHand = ItemStack.EMPTY; + if( hand.isEmpty() ) { newHand = toBeAdded.copy(); } @@ -182,26 +182,26 @@ public class AdaptorPlayerHand extends InventoryAdaptor } this.player.inventory.setItemStack( newHand ); - return null; + return ItemStack.EMPTY; } @Override public ItemStack simulateAdd( final ItemStack toBeSimulated ) { final ItemStack hand = this.player.inventory.getItemStack(); - if( toBeSimulated == null ) + if( toBeSimulated.isEmpty() ) { - return null; + return ItemStack.EMPTY; } - if( hand != null && !Platform.itemComparisons().isEqualItem( toBeSimulated, hand ) ) + if( !hand.isEmpty() && !Platform.itemComparisons().isEqualItem( toBeSimulated, hand ) ) { return toBeSimulated; } int original = 0; - ItemStack newHand = null; - if( hand == null ) + ItemStack newHand = ItemStack.EMPTY; + if( hand.isEmpty() ) { newHand = toBeSimulated.copy(); } @@ -220,13 +220,13 @@ public class AdaptorPlayerHand extends InventoryAdaptor return B; } - return null; + return ItemStack.EMPTY; } @Override public boolean containsItems() { - return this.player.inventory.getItemStack() != null; + return !this.player.inventory.getItemStack().isEmpty(); } @Override diff --git a/src/main/java/appeng/util/inv/IMEAdaptor.java b/src/main/java/appeng/util/inv/IMEAdaptor.java index 1a99aa3d0..87423970c 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptor.java +++ b/src/main/java/appeng/util/inv/IMEAdaptor.java @@ -70,7 +70,7 @@ public class IMEAdaptor extends InventoryAdaptor { IAEItemStack req = null; - if( filter == null ) + if( filter.isEmpty() ) { final IItemList list = this.getList(); if( !list.isEmpty() ) @@ -96,7 +96,7 @@ public class IMEAdaptor extends InventoryAdaptor return out.getItemStack(); } - return null; + return ItemStack.EMPTY; } @Override @@ -108,7 +108,7 @@ public class IMEAdaptor extends InventoryAdaptor @Override public ItemStack removeSimilarItems( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) { - if( filter == null ) + if( filter.isEmpty() ) { return this.doRemoveItems( amount, null, destination, Actionable.MODULATE ); } @@ -120,7 +120,7 @@ public class IMEAdaptor extends InventoryAdaptor final IAEItemStack reqFilter = AEItemStack.create( filter ); if( reqFilter == null ) { - return null; + return ItemStack.EMPTY; } IAEItemStack out = null; @@ -138,15 +138,15 @@ public class IMEAdaptor extends InventoryAdaptor } } - return null; + return ItemStack.EMPTY; } @Override public ItemStack simulateSimilarRemove( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination ) { - if( filter == null ) + if( filter.isEmpty() ) { - return this.doRemoveItems( amount, null, destination, Actionable.SIMULATE ); + return this.doRemoveItems( amount, ItemStack.EMPTY, destination, Actionable.SIMULATE ); } return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.SIMULATE, fuzzyMode ); } @@ -163,7 +163,7 @@ public class IMEAdaptor extends InventoryAdaptor return out.getItemStack(); } } - return null; + return ItemStack.EMPTY; } @Override @@ -178,7 +178,7 @@ public class IMEAdaptor extends InventoryAdaptor return out.getItemStack(); } } - return null; + return ItemStack.EMPTY; } @Override diff --git a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java index cf064a323..50e74e5fd 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java +++ b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java @@ -23,6 +23,7 @@ import java.util.Iterator; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; +import net.minecraft.item.ItemStack; public final class IMEAdaptorIterator implements Iterator @@ -68,7 +69,7 @@ public final class IMEAdaptorIterator implements Iterator return this.slot; } - this.slot.setItemStack( null ); + this.slot.setItemStack( ItemStack.EMPTY ); return this.slot; } diff --git a/src/main/java/appeng/util/inv/IMEInventoryDestination.java b/src/main/java/appeng/util/inv/IMEInventoryDestination.java index 49c7a5447..da8556351 100644 --- a/src/main/java/appeng/util/inv/IMEInventoryDestination.java +++ b/src/main/java/appeng/util/inv/IMEInventoryDestination.java @@ -41,7 +41,7 @@ public class IMEInventoryDestination implements IInventoryDestination public boolean canInsert( final ItemStack stack ) { - if( stack == null ) + if( stack.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/util/inv/ItemHandlerIterator.java b/src/main/java/appeng/util/inv/ItemHandlerIterator.java index 714aab3ad..77110d5dc 100644 --- a/src/main/java/appeng/util/inv/ItemHandlerIterator.java +++ b/src/main/java/appeng/util/inv/ItemHandlerIterator.java @@ -52,7 +52,7 @@ class ItemHandlerIterator implements Iterator { throw new NoSuchElementException(); } - itemSlot.setExtractable( itemHandler.extractItem( slot, 1, true ) != null ); + itemSlot.setExtractable( !itemHandler.extractItem( slot, 1, true ).isEmpty() ); itemSlot.setItemStack( itemHandler.getStackInSlot( slot ) ); itemSlot.setSlot( slot ); slot++; diff --git a/src/main/java/appeng/util/inv/ItemSlot.java b/src/main/java/appeng/util/inv/ItemSlot.java index 048839680..c4780771c 100644 --- a/src/main/java/appeng/util/inv/ItemSlot.java +++ b/src/main/java/appeng/util/inv/ItemSlot.java @@ -36,7 +36,7 @@ public class ItemSlot public ItemStack getItemStack() { - return this.itemStack == null ? ( this.aeItemStack == null ? null : ( this.itemStack = this.aeItemStack.getItemStack() ) ) : this.itemStack; + return this.itemStack.isEmpty() ? ( this.aeItemStack == null ? ItemStack.EMPTY : ( this.itemStack = this.aeItemStack.getItemStack() ) ) : this.itemStack; } public void setItemStack( final ItemStack is ) @@ -47,13 +47,13 @@ public class ItemSlot public IAEItemStack getAEItemStack() { - return this.aeItemStack == null ? ( this.itemStack == null ? null : ( this.aeItemStack = AEItemStack.create( this.itemStack ) ) ) : this.aeItemStack; + return this.aeItemStack == null ? ( this.itemStack.isEmpty() ? null : ( this.aeItemStack = AEItemStack.create( this.itemStack ) ) ) : this.aeItemStack; } void setAEItemStack( final IAEItemStack is ) { this.aeItemStack = is; - this.itemStack = null; + this.itemStack = ItemStack.EMPTY; } public boolean isExtractable() diff --git a/src/main/java/appeng/util/inv/WrapperChainedInventory.java b/src/main/java/appeng/util/inv/WrapperChainedInventory.java index 56d65d022..28fd543ec 100644 --- a/src/main/java/appeng/util/inv/WrapperChainedInventory.java +++ b/src/main/java/appeng/util/inv/WrapperChainedInventory.java @@ -132,7 +132,7 @@ public class WrapperChainedInventory implements IInventory { return io.i.getStackInSlot( idx - io.offset ); } - return null; + return ItemStack.EMPTY; } @Override @@ -143,7 +143,7 @@ public class WrapperChainedInventory implements IInventory { return io.i.decrStackSize( idx - io.offset, var2 ); } - return null; + return ItemStack.EMPTY; } @Override @@ -154,7 +154,7 @@ public class WrapperChainedInventory implements IInventory { return io.i.removeStackFromSlot( idx - io.offset ); } - return null; + return ItemStack.EMPTY; } @Override diff --git a/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java b/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java index fa2180058..e635fbf91 100644 --- a/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java +++ b/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java @@ -67,7 +67,7 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I @Override public boolean canRemoveItemFromSlot( final int i, final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/util/item/AEFluidStack.java b/src/main/java/appeng/util/item/AEFluidStack.java index 31beebc2d..c7c94c34b 100644 --- a/src/main/java/appeng/util/item/AEFluidStack.java +++ b/src/main/java/appeng/util/item/AEFluidStack.java @@ -84,7 +84,7 @@ public final class AEFluidStack extends AEStack implements IAEFlu public static IAEFluidStack loadFluidStackFromNBT( final NBTTagCompound i ) { final ItemStack itemstack = new ItemStack( i ); - if( itemstack == null ) + if( itemstack.isEmpty() ) { return null; } diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index 153582526..e0839adf3 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -62,7 +62,7 @@ public final class AEItemStack extends AEStack implements IAEItemS private AEItemStack( final ItemStack is ) { - if( is == null ) + if( is.isEmpty() ) { throw new InvalidParameterException( "null is not a valid ItemStack for AEItemStack." ); } @@ -125,7 +125,7 @@ public final class AEItemStack extends AEStack implements IAEItemS } final ItemStack itemstack = new ItemStack( i ); - if( itemstack == null ) + if( itemstack.isEmpty() ) { return null; } @@ -141,7 +141,7 @@ public final class AEItemStack extends AEStack implements IAEItemS @Nullable public static AEItemStack create( final ItemStack stack ) { - if( stack == null ) + if( stack.isEmpty() ) { return null; } @@ -166,7 +166,7 @@ public final class AEItemStack extends AEStack implements IAEItemS short itemNumericId = data.readShort(); d.setString( "id", String.valueOf( itemNumericId ) ); d.setShort( "Damage", data.readShort() ); - d.setByte( "Count", (byte) 1 ); + d.setByte( "Count", (byte) 1 ); // 1 Because vanilla'll freak out otherwise if( hasTagCompound ) { @@ -189,7 +189,7 @@ public final class AEItemStack extends AEStack implements IAEItemS showCraftingLabel = stackSize == 0; } - if( itemstack == null ) + if( itemstack.isEmpty() ) { return null; } @@ -488,7 +488,7 @@ public final class AEItemStack extends AEStack implements IAEItemS @Override public boolean isSameType( final ItemStack otherStack ) { - if( otherStack == null ) + if( otherStack.isEmpty() ) { return false; } diff --git a/src/main/java/appeng/worldgen/MeteoritePlacer.java b/src/main/java/appeng/worldgen/MeteoritePlacer.java index fc9143b65..086fdf06b 100644 --- a/src/main/java/appeng/worldgen/MeteoritePlacer.java +++ b/src/main/java/appeng/worldgen/MeteoritePlacer.java @@ -252,29 +252,29 @@ public final class MeteoritePlacer r = (int) ( Math.random() * 1000 ); } - ItemStack toAdd = null; + ItemStack toAdd = ItemStack.EMPTY; final IMaterials materials = AEApi.instance().definitions().materials(); switch( r % 4 ) { case 0: - toAdd = materials.calcProcessorPress().maybeStack( 1 ).orElse( null ); + toAdd = materials.calcProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; case 1: - toAdd = materials.engProcessorPress().maybeStack( 1 ).orElse( null ); + toAdd = materials.engProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; case 2: - toAdd = materials.logicProcessorPress().maybeStack( 1 ).orElse( null ); + toAdd = materials.logicProcessorPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; case 3: - toAdd = materials.siliconPress().maybeStack( 1 ).orElse( null ); + toAdd = materials.siliconPress().maybeStack( 1 ).orElse( ItemStack.EMPTY ); break; default: } - if( toAdd != null ) + if( !toAdd.isEmpty() ) { - if( ap.simulateRemove( 1, toAdd, null ) == null ) + if( ap.simulateRemove( 1, toAdd, null ).isEmpty() ) { ap.addItems( toAdd ); } @@ -310,7 +310,7 @@ public final class MeteoritePlacer possibles.add( new ItemStack( net.minecraft.init.Items.GOLD_NUGGET ) ); ItemStack nugget = Platform.pickRandom( possibles ); - if( nugget != null ) + if( !nugget.isEmpty() ) { nugget = nugget.copy(); nugget.setCount( (int) ( Math.random() * 12 ) + 1 );