mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +00:00
Initial annotations/nullability changes (#3392)
This commit is contained in:
1 parent
1fa0c0c548
commit
9cf74914e7
37 files changed
+172
-104
No files matched your search
@@ -50,9 +50,9 @@ public class ItemHandlerHelper
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static boolean canItemStacksStack(ItemStack a, ItemStack b)
|
||||
public static boolean canItemStacksStack(@Nonnull ItemStack a, @Nonnull ItemStack b)
|
||||
{
|
||||
if (a == null || !a.isItemEqual(b))
|
||||
if (a.func_190926_b() || !a.isItemEqual(b))
|
||||
return false;
|
||||
|
||||
final NBTTagCompound aTag = a.getTagCompound();
|
||||
@@ -64,9 +64,9 @@ public class ItemHandlerHelper
|
||||
* A relaxed version of canItemStacksStack that stacks itemstacks with different metadata if they don't have subtypes.
|
||||
* This usually only applies when players pick up items.
|
||||
*/
|
||||
public static boolean canItemStacksStackRelaxed(ItemStack a, ItemStack b)
|
||||
public static boolean canItemStacksStackRelaxed(@Nonnull ItemStack a, @Nonnull ItemStack b)
|
||||
{
|
||||
if (a == null || b == null || a.getItem() != b.getItem())
|
||||
if (a.func_190926_b() || b.func_190926_b() || a.getItem() != b.getItem())
|
||||
return false;
|
||||
|
||||
if (!a.isStackable())
|
||||
@@ -84,7 +84,7 @@ public class ItemHandlerHelper
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack copyStackWithSize(ItemStack itemStack, int size)
|
||||
public static ItemStack copyStackWithSize(@Nonnull ItemStack itemStack, int size)
|
||||
{
|
||||
if (size == 0)
|
||||
return ItemStack.field_190927_a;
|
||||
@@ -148,7 +148,7 @@ public class ItemHandlerHelper
|
||||
}
|
||||
|
||||
/** giveItemToPlayer without preferred slot */
|
||||
public static void giveItemToPlayer(EntityPlayer player, ItemStack stack) {
|
||||
public static void giveItemToPlayer(EntityPlayer player, @Nonnull ItemStack stack) {
|
||||
giveItemToPlayer(player, stack, -1);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class ItemHandlerHelper
|
||||
* @param player The player to give the item to
|
||||
* @param stack The itemstack to insert
|
||||
*/
|
||||
public static void giveItemToPlayer(EntityPlayer player, ItemStack stack, int preferredSlot)
|
||||
public static void giveItemToPlayer(EntityPlayer player, @Nonnull ItemStack stack, int preferredSlot)
|
||||
{
|
||||
IItemHandler inventory = new PlayerMainInvWrapper(player.inventory);
|
||||
World world = player.worldObj;
|
||||
@@ -172,20 +172,20 @@ public class ItemHandlerHelper
|
||||
remainder = inventory.insertItem(preferredSlot, stack, false);
|
||||
}
|
||||
// then into the inventory in general
|
||||
if(remainder != null)
|
||||
if(!remainder.func_190926_b())
|
||||
{
|
||||
remainder = insertItemStacked(inventory, remainder, false);
|
||||
}
|
||||
|
||||
// play sound if something got picked up
|
||||
if (remainder == null || remainder.func_190916_E() != stack.func_190916_E())
|
||||
if (remainder.func_190926_b() || remainder.func_190916_E() != stack.func_190916_E())
|
||||
{
|
||||
world.playSound(player, player.posX, player.posY, player.posZ,
|
||||
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
}
|
||||
|
||||
// drop remaining itemstack into the world
|
||||
if (remainder != null && !world.isRemote)
|
||||
if (!remainder.func_190926_b() && !world.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(world, player.posX, player.posY + 0.5, player.posZ, stack);
|
||||
entityitem.setPickupDelay(40);
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
|
||||
}
|
||||
}
|
||||
|
||||
protected int getStackLimit(int slot, ItemStack stack)
|
||||
protected int getStackLimit(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
return stack.getMaxStackSize();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class VanillaHopperItemHandler extends InvWrapper
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if (stack == null)
|
||||
if (stack.func_190926_b())
|
||||
return null;
|
||||
// if (simulate || !hopper.mayTransfer())
|
||||
// return super.insertItem(slot, stack, simulate);
|
||||
|
||||
@@ -47,15 +47,15 @@ public class VanillaInventoryCodeHooks
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (extractItem != null)
|
||||
if (!extractItem.func_190926_b())
|
||||
{
|
||||
for (int j = 0; j < dest.getSizeInventory(); j++)
|
||||
{
|
||||
ItemStack destStack = dest.getStackInSlot(j);
|
||||
if (destStack == null || destStack.func_190916_E() < destStack.getMaxStackSize() && destStack.func_190916_E() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack))
|
||||
if (destStack.func_190926_b() || destStack.func_190916_E() < destStack.getMaxStackSize() && destStack.func_190916_E() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack))
|
||||
{
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack == null)
|
||||
if (destStack.func_190926_b())
|
||||
dest.setInventorySlotContents(j, extractItem);
|
||||
else
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public class VanillaInventoryCodeHooks
|
||||
for (int i = 0; i < hopper.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stackInSlot = hopper.getStackInSlot(i);
|
||||
if (stackInSlot != null)
|
||||
if (stackInSlot.func_190926_b())
|
||||
{
|
||||
ItemStack insert = stackInSlot.copy();
|
||||
insert.func_190920_e(1);
|
||||
|
||||
@@ -72,8 +72,8 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
if (stack == null)
|
||||
return null;
|
||||
if (stack.func_190926_b())
|
||||
return ItemStack.field_190927_a;
|
||||
|
||||
if (!getInv().isItemValidForSlot(slot, stack))
|
||||
return stack;
|
||||
@@ -98,7 +98,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
getInv().markDirty();
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.field_190927_a;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -145,7 +145,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
getInv().setInventorySlotContents(slot, stack);
|
||||
getInv().markDirty();
|
||||
}
|
||||
return null;
|
||||
return ItemStack.field_190927_a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,12 +156,12 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate)
|
||||
{
|
||||
if (amount == 0)
|
||||
return null;
|
||||
return ItemStack.field_190927_a;
|
||||
|
||||
ItemStack stackInSlot = getInv().getStackInSlot(slot);
|
||||
|
||||
if (stackInSlot == null)
|
||||
return null;
|
||||
if (stackInSlot.func_190926_b())
|
||||
return ItemStack.field_190927_a;
|
||||
|
||||
if (simulate)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ public class InvWrapper implements IItemHandlerModifiable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack)
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
getInv().setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RangedWrapper implements IItemHandlerModifiable {
|
||||
return compose.getStackInSlot(slot + minSlot);
|
||||
}
|
||||
|
||||
return null;
|
||||
return ItemStack.field_190927_a;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +86,7 @@ public class RangedWrapper implements IItemHandlerModifiable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, ItemStack stack)
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
if (checkSlot(slot))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user