Fixed tools getting deleted when being used in off-hand.
This commit is contained in:
@@ -108,17 +108,17 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer p, final @Nullable EnumHand hand )
|
||||
{
|
||||
if( this.getAECurrentPower( p.getHeldItemMainhand() ) > 1600 )
|
||||
if( this.getAECurrentPower( p.getHeldItem(hand) ) > 1600 )
|
||||
{
|
||||
int shots = 1;
|
||||
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory( p.getHeldItemMainhand() );
|
||||
final CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory( p.getHeldItem(hand) );
|
||||
if( cu != null )
|
||||
{
|
||||
shots += cu.getInstalledUpgrades( Upgrades.SPEED );
|
||||
}
|
||||
|
||||
final IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( p.getHeldItemMainhand(), null, StorageChannel.ITEMS );
|
||||
final IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( p.getHeldItem(hand), null, StorageChannel.ITEMS );
|
||||
if( inv != null )
|
||||
{
|
||||
final IItemList itemList = inv.getAvailableItems( AEApi.instance().storage().createItemList() );
|
||||
@@ -128,25 +128,25 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
|
||||
shots = Math.min( shots, (int) aeAmmo.getStackSize() );
|
||||
for( int sh = 0; sh < shots; sh++ )
|
||||
{
|
||||
this.extractAEPower( p.getHeldItemMainhand(), 1600 );
|
||||
this.extractAEPower( p.getHeldItem(hand), 1600 );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
aeAmmo.setStackSize( 1 );
|
||||
final ItemStack ammo = ( (IAEItemStack) aeAmmo ).getItemStack();
|
||||
if( ammo == null )
|
||||
{
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
ammo.setCount( 1 );
|
||||
aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) );
|
||||
if( aeAmmo == null )
|
||||
{
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
final LookDirection dir = Platform.getPlayerRay( p, p.getEyeHeight() );
|
||||
@@ -168,7 +168,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
|
||||
{
|
||||
this.shootPaintBalls( type, w, p, Vec3d, Vec3d1, direction, d0, d1, d2 );
|
||||
}
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItem(hand) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -182,11 +182,11 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
|
||||
{
|
||||
p.sendMessage( PlayerMessages.AmmoDepleted.get() );
|
||||
}
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, p.getHeldItem(hand) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ActionResult<ItemStack>( EnumActionResult.FAIL, p.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.FAIL, p.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
private void shootPaintBalls( final ItemStack type, final World w, final EntityPlayer p, final Vec3d Vec3d, final Vec3d Vec3d1, final Vec3d direction, final double d0, final double d1, final double d2 )
|
||||
|
||||
Reference in New Issue
Block a user