Skip to content

Commit

Permalink
Fixed NPE bugs in API by returning empty, rather than null, and updat…
Browse files Browse the repository at this point in the history
…ed the method descriptions accordingly.
  • Loading branch information
Phylogeny committed Dec 24, 2016
1 parent 918ee73 commit 8f6a7db
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mod/chiselsandbits/api/IBitAccess.java
Expand Up @@ -98,7 +98,7 @@ void commitChanges(
* or if it is portable, cross world NBT is larger and slower,
* you should only request cross world NBT if you specifically
* need it.
* @return an Item for bits, null if there are no bits.
* @return an Item for bits, which is empty if there are no bits.
*/
ItemStack getBitsAsItem(
EnumFacing side,
Expand All @@ -116,7 +116,7 @@ ItemStack getBitsAsItem(
* angle the player is looking at, can be null.
* @param type
* what type of item to give.
* @return an Item for bits, null if there are no bits.
* @return an Item for bits, which is empty if there are no bits.
*/
@Deprecated
ItemStack getBitsAsItem(
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/mod/chiselsandbits/api/IBitBrush.java
Expand Up @@ -25,16 +25,15 @@ public interface IBitBrush
IBlockState getState();

/**
* Get the ItemStack for a bit, returns null for air.
* Get the ItemStack for a bit, which is empty for air.
*
* VERY IMPORTANT: C&B lets you disable bits, if this happens the Item in
* this ItemStack WILL BE NULL, if you put this item in an inventory, drop
* it on the ground, or anything else.. CHECK THIS!!!!!
*
* @param count
* @return ItemStack, or null for air.
* @return ItemStack, which is empty for air.
*/
@Nullable
ItemStack getItemStack(
int count );

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mod/chiselsandbits/core/api/BitAccess.java
Expand Up @@ -140,13 +140,13 @@ public ItemStack getBitsAsItem(
{
if ( type == null )
{
return null;
return ModUtil.getEmptyStack();
}

final BlobStats cb = blob.getVoxelStats();
if ( cb.mostCommonState == 0 )
{
return null;
return ModUtil.getEmptyStack();
}

final NBTBlobConverter c = new NBTBlobConverter();
Expand All @@ -164,7 +164,7 @@ public ItemStack getBitsAsItem(

if ( blk == null )
{
return null;
return ModUtil.getEmptyStack();
}

itemstack = new ItemStack( blk, 1 );
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mod/chiselsandbits/core/api/BitBrush.java
Expand Up @@ -20,12 +20,12 @@ public BitBrush(
}

@Override
public @Nullable ItemStack getItemStack(
public ItemStack getItemStack(
final int count )
{
if ( stateID == 0 )
{
return null;
return ModUtil.getEmptyStack();
}

return ItemChiseledBit.createStack( stateID, count, true );
Expand Down

0 comments on commit 8f6a7db

Please sign in to comment.