Skip to content

Commit

Permalink
Standardized the naming of ItemStacks, both as variable and in method…
Browse files Browse the repository at this point in the history
… descriptions, in the API.
  • Loading branch information
Phylogeny committed Dec 24, 2016
1 parent 9a5d94b commit b4d18b5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 59 deletions.
Expand Up @@ -16,23 +16,23 @@ public class EventBlockBitModification extends Event
private final BlockPos pos;
private final EntityPlayer player;
private final EnumHand hand;
private final ItemStack itemUsed;
private final ItemStack stackUsed;
private final boolean placement;

public EventBlockBitModification(
final World w,
final BlockPos pos,
final EntityPlayer player,
final EnumHand hand,
final ItemStack itemUsed,
final ItemStack stackUsed,
final boolean placement )
{

this.w = w;
this.pos = pos;
this.player = player;
this.hand = hand;
this.itemUsed = itemUsed;
this.stackUsed = stackUsed;
this.placement = placement;
}

Expand All @@ -58,7 +58,7 @@ public EnumHand getHand()

public ItemStack getItemUsed()
{
return itemUsed;
return stackUsed;
}

public boolean isPlacing()
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/mod/chiselsandbits/api/IBitAccess.java
Expand Up @@ -85,7 +85,7 @@ void commitChanges(
void commitChanges();

/**
* Returns an item for the {@link IBitAccess}
* Returns an ItemStack for the {@link IBitAccess}
*
* Usable for any {@link IBitAccess}
*
Expand All @@ -94,19 +94,19 @@ void commitChanges(
* @param type
* what type of item to give.
* @param crossWorld
* determines if the NBT for the item is specific to this world
* determines if the NBT for the ItemStack is specific to this world
* 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, which is empty if there are no bits.
* @return an ItemStack for bits, which is empty if there are no bits.
*/
ItemStack getBitsAsItem(
EnumFacing side,
ItemType type,
boolean crossWorld );

/**
* Returns an item for the {@link IBitAccess}, this method all ways returns
* Returns an ItemStack for the {@link IBitAccess}, this method all ways returns
* non-cross world NBT, please move to the above method and specify false to
* prepare for future removal.
*
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, which is empty if there are no bits.
* @return an ItemStack for bits, which is empty if there are no bits.
*/
@Deprecated
ItemStack getBitsAsItem(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mod/chiselsandbits/api/IBitBrush.java
Expand Up @@ -28,7 +28,7 @@ public interface IBitBrush
* 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
* this ItemStack WILL BE NULL, if you put this ItemStack in an inventory, drop
* it on the ground, or anything else.. CHECK THIS!!!!!
*
* @param count
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/mod/chiselsandbits/api/IChiselAndBitsAPI.java
Expand Up @@ -19,13 +19,13 @@ public interface IChiselAndBitsAPI
{

/**
* Determine the Item Type and return it.
* Determine the Item Type of the item in an ItemStack and return it.
*
* @param item
* @param stack
* @return ItemType of the item, or null if it is not any of them.
*/
ItemType getItemType(
ItemStack item );
ItemStack stack );

/**
* Check if a block can support {@link IBitAccess}
Expand Down Expand Up @@ -65,24 +65,24 @@ IBitAccess getBitAccess(
BlockPos pos ) throws CannotBeChiseled;

/**
* Create a bit access from an item, passing an empty ItemStack creates an empty bit access,
* Create a bit access from an ItemStack, passing an empty ItemStack creates an empty bit access,
* passing an invalid item returns null.
*
* @return a {@link IBitAccess} for an item.
* @return a {@link IBitAccess} for an ItemStack.
*/
IBitAccess createBitItem(
ItemStack BitItemStack );
ItemStack stack );

/**
* Create a brush from an item, once created you can use it many times.
* Create a brush from an ItemStack, once created you can use it many times.
*
* @param bitItem
* @return A brush for the specified item, if passed an empty ItemStack an
* @return A brush for the specified ItemStack, if passed an empty ItemStack an
* air brush is created.
* @throws InvalidBitItem
*/
IBitBrush createBrush(
ItemStack bitItem ) throws InvalidBitItem;
ItemStack stack ) throws InvalidBitItem;

/**
* Create a brush from a state, once created you can use it many times.
Expand Down Expand Up @@ -135,7 +135,7 @@ ItemStack getBitItem(
*
* CLIENT: destroys the item.
*
* SERVER: adds item to inv/bag/spawns entity.
* SERVER: adds ItemStack to inv/bag/spawns entity.
*
* @param player
* player to give bits to.
Expand All @@ -148,7 +148,7 @@ ItemStack getBitItem(
*/
void giveBitToPlayer(
EntityPlayer player,
ItemStack itemstack,
ItemStack stack,
Vec3d spawnPos );

/**
Expand All @@ -158,7 +158,7 @@ void giveBitToPlayer(
* @return internal object to manipulate bag.
*/
IBitBag getBitbag(
ItemStack itemstack );
ItemStack stack );

/**
* Begins an undo operation, starting two operations without ending the
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/mod/chiselsandbits/core/api/BitAccess.java
Expand Up @@ -155,7 +155,7 @@ public ItemStack getBitsAsItem(
final NBTTagCompound nbttagcompound = new NBTTagCompound();
c.writeChisleData( nbttagcompound, crossWorld );

final ItemStack itemstack;
final ItemStack stack;

if ( type == ItemType.CHISLED_BLOCK )
{
Expand All @@ -167,35 +167,35 @@ public ItemStack getBitsAsItem(
return ModUtil.getEmptyStack();
}

itemstack = new ItemStack( blk, 1 );
itemstack.setTagInfo( ModUtil.NBT_BLOCKENTITYTAG, nbttagcompound );
stack = new ItemStack( blk, 1 );
stack.setTagInfo( ModUtil.NBT_BLOCKENTITYTAG, nbttagcompound );
}
else
{
switch ( type )
{
case MIRROR_DESIGN:
itemstack = new ItemStack( ChiselsAndBits.getItems().itemMirrorprint );
stack = new ItemStack( ChiselsAndBits.getItems().itemMirrorprint );
break;
case NEGATIVE_DESIGN:
itemstack = new ItemStack( ChiselsAndBits.getItems().itemNegativeprint );
stack = new ItemStack( ChiselsAndBits.getItems().itemNegativeprint );
break;
case POSITIVE_DESIGN:
itemstack = new ItemStack( ChiselsAndBits.getItems().itemPositiveprint );
stack = new ItemStack( ChiselsAndBits.getItems().itemPositiveprint );
break;
default:
return ModUtil.getEmptyStack();
}

itemstack.setTagCompound( nbttagcompound );
stack.setTagCompound( nbttagcompound );
}

if ( side != null )
{
ModUtil.setSide( itemstack, side );
ModUtil.setSide( stack, side );
}

return itemstack;
return stack;
}

@Override
Expand Down
56 changes: 28 additions & 28 deletions src/main/java/mod/chiselsandbits/core/api/ChiselAndBitsAPI.java
Expand Up @@ -116,16 +116,16 @@ public IBitAccess getBitAccess(

@Override
public IBitBrush createBrush(
final ItemStack bitItem ) throws InvalidBitItem
final ItemStack stack ) throws InvalidBitItem
{
if ( ModUtil.isEmpty(bitItem) )
if ( ModUtil.isEmpty(stack) )
{
return new BitBrush( 0 );
}

if ( bitItem.getItem() == null || getItemType( bitItem ) == ItemType.CHISLED_BIT )
if ( stack.getItem() == null || getItemType( stack ) == ItemType.CHISLED_BIT )
{
final int stateID = ItemChiseledBit.getStackState( bitItem );
final int stateID = ItemChiseledBit.getStackState( stack );
final IBlockState state = ModUtil.getStateById( stateID );

if ( state != null && BlockBitInfo.supportsBlock( state ) )
Expand Down Expand Up @@ -157,44 +157,44 @@ public IBitLocation getBitPos(

@Override
public ItemType getItemType(
final ItemStack item )
final ItemStack stack )
{
if ( item.getItem() instanceof ItemChiseledBit )
if ( stack.getItem() instanceof ItemChiseledBit )
{
return ItemType.CHISLED_BIT;
}

if ( item.getItem() instanceof ItemBitBag )
if ( stack.getItem() instanceof ItemBitBag )
{
return ItemType.BIT_BAG;
}

if ( item.getItem() instanceof ItemChisel )
if ( stack.getItem() instanceof ItemChisel )
{
return ItemType.CHISEL;
}

if ( item.getItem() instanceof ItemBlockChiseled )
if ( stack.getItem() instanceof ItemBlockChiseled )
{
return ItemType.CHISLED_BLOCK;
}

if ( item.getItem() instanceof ItemMirrorPrint )
if ( stack.getItem() instanceof ItemMirrorPrint )
{
return ItemType.MIRROR_DESIGN;
}

if ( item.getItem() instanceof ItemPositivePrint )
if ( stack.getItem() instanceof ItemPositivePrint )
{
return ItemType.POSITIVE_DESIGN;
}

if ( item.getItem() instanceof ItemNegativePrint )
if ( stack.getItem() instanceof ItemNegativePrint )
{
return ItemType.NEGATIVE_DESIGN;
}

if ( item.getItem() instanceof ItemWrench )
if ( stack.getItem() instanceof ItemWrench )
{
return ItemType.WRENCH;
}
Expand All @@ -204,23 +204,23 @@ public ItemType getItemType(

@Override
public IBitAccess createBitItem(
final ItemStack bitItemStack )
final ItemStack stack )
{
if ( ModUtil.isEmpty(bitItemStack) )
if ( ModUtil.isEmpty(stack) )
{
return new BitAccess( null, null, new VoxelBlob(), VoxelBlob.NULL_BLOB );
}

final ItemType type = getItemType( bitItemStack );
final ItemType type = getItemType( stack );
if ( type != null && type.isBitAccess )
{
final VoxelBlob blob = ModUtil.getBlobFromStack( bitItemStack, null );
final VoxelBlob blob = ModUtil.getBlobFromStack( stack, null );
return new BitAccess( null, null, blob, VoxelBlob.NULL_BLOB );
}

if ( bitItemStack != null && bitItemStack.getItem() instanceof ItemBlock )
if ( stack.getItem() instanceof ItemBlock )
{
final IBlockState state = DeprecationHelper.getStateFromItem( bitItemStack );
final IBlockState state = DeprecationHelper.getStateFromItem( stack );

if ( BlockBitInfo.supportsBlock( state ) )
{
Expand Down Expand Up @@ -265,10 +265,10 @@ public ItemStack getBitItem(
@Override
public void giveBitToPlayer(
final EntityPlayer player,
final ItemStack is,
final ItemStack stack,
Vec3d spawnPos )
{
if ( ModUtil.isEmpty(is) )
if ( ModUtil.isEmpty(stack) )
{
return;
}
Expand All @@ -278,9 +278,9 @@ public void giveBitToPlayer(
spawnPos = new Vec3d( player.posX, player.posY, player.posZ );
}

final EntityItem ei = new EntityItem( player.getEntityWorld(), spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord, is );
final EntityItem ei = new EntityItem( player.getEntityWorld(), spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord, stack );

if ( is.getItem() == ChiselsAndBits.getItems().itemBlockBit )
if ( stack.getItem() == ChiselsAndBits.getItems().itemBlockBit )
{
if ( player.getEntityWorld().isRemote )
{
Expand All @@ -290,20 +290,20 @@ public void giveBitToPlayer(
ModUtil.feedPlayer( player.getEntityWorld(), player, ei );
return;
}
else if ( !player.inventory.addItemStackToInventory( is ) )
else if ( !player.inventory.addItemStackToInventory( stack ) )
{
ei.setEntityItemStack( is );
ei.setEntityItemStack( stack );
player.getEntityWorld().spawnEntityInWorld( ei );
}
}

@Override
public IBitBag getBitbag(
final ItemStack itemstack )
final ItemStack stack )
{
if ( !ModUtil.isEmpty(itemstack) )
if ( !ModUtil.isEmpty(stack) )
{
final Object o = itemstack.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP );
final Object o = stack.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP );
if ( o instanceof IBitBag )
{
return (IBitBag) o;
Expand Down

0 comments on commit b4d18b5

Please sign in to comment.