Fix more items and unsafe checks that made items get deleted.
This commit is contained in:
@@ -274,9 +274,9 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
||||
public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
ItemStack heldItem;
|
||||
if( player != null && !player.getHeldItemMainhand().isEmpty() )
|
||||
if( player != null && !player.getHeldItem(hand).isEmpty() )
|
||||
{
|
||||
heldItem = player.getHeldItemMainhand();
|
||||
heldItem = player.getHeldItem(hand);
|
||||
|
||||
if( Platform.isWrench( player, heldItem, pos ) && player.isSneaking() )
|
||||
{
|
||||
@@ -366,7 +366,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
||||
}
|
||||
}
|
||||
|
||||
return this.onActivated( world, pos, player, hand, player.getHeldItemMainhand(), facing, hitX, hitY, hitZ );
|
||||
return this.onActivated( world, pos, player, hand, player.getHeldItem(hand), facing, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ToolReplicatorCard extends AEBaseItem
|
||||
tag.setInteger( "z", z );
|
||||
tag.setInteger( "side", side.ordinal() );
|
||||
tag.setInteger( "dimid", world.provider.getDimension() );
|
||||
player.getHeldItemMainhand().setTagCompound( tag );
|
||||
player.getHeldItem(hand).setTagCompound( tag );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public class ToolReplicatorCard extends AEBaseItem
|
||||
}
|
||||
else
|
||||
{
|
||||
final NBTTagCompound ish = player.getHeldItemMainhand().getTagCompound();
|
||||
final NBTTagCompound ish = player.getHeldItem(hand).getTagCompound();
|
||||
if( ish != null )
|
||||
{
|
||||
final int src_x = ish.getInteger( "x" );
|
||||
|
||||
@@ -302,10 +302,10 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
|
||||
upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" );
|
||||
}
|
||||
|
||||
if( upgrades != null && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof IUpgradeModule )
|
||||
if( upgrades != null && !player.getHeldItem(hand).isEmpty() && player.getHeldItem(hand).getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getHeldItemMainhand().getItem();
|
||||
final Upgrades u = um.getType( player.getHeldItemMainhand() );
|
||||
final IUpgradeModule um = (IUpgradeModule) player.getHeldItem(hand).getItem();
|
||||
final Upgrades u = um.getType( player.getHeldItem(hand) );
|
||||
|
||||
if( u != null )
|
||||
{
|
||||
@@ -317,7 +317,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
player.inventory.setInventorySlotContents( player.inventory.currentItem, ad.addItems( player.getHeldItemMainhand() ) );
|
||||
player.inventory.setInventorySlotContents( player.inventory.currentItem, ad.addItems( player.getHeldItem(hand) ) );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,15 +58,15 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
this.clearPattern( player.getHeldItemMainhand(), player );
|
||||
this.clearPattern( player.getHeldItem(hand), player );
|
||||
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
return this.clearPattern( player.getHeldItemMainhand(), player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
return this.clearPattern( player.getHeldItem(hand), player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
private boolean clearPattern( final ItemStack stack, final EntityPlayer player )
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
return AEApi.instance().partHelper().placeBus( player.getHeldItemMainhand(), pos, side, player, hand, world );
|
||||
return AEApi.instance().partHelper().placeBus( player.getHeldItem(hand), pos, side, player, hand, world );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -155,12 +155,12 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
@Override
|
||||
public EnumActionResult onItemUse( final EntityPlayer player, final World w, final BlockPos pos, final EnumHand hand, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
if( this.getTypeByStack( player.getHeldItemMainhand() ) == PartType.InvalidType )
|
||||
if( this.getTypeByStack( player.getHeldItem(hand) ) == PartType.InvalidType )
|
||||
{
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
return AEApi.instance().partHelper().placeBus( player.getHeldItemMainhand(), pos, side, player, hand, w );
|
||||
return AEApi.instance().partHelper().placeBus( player.getHeldItem(hand), pos, side, player, hand, w );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,8 +216,8 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World world, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
this.disassembleDrive( player.getHeldItemMainhand(), world, player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItemMainhand() );
|
||||
this.disassembleDrive( player.getHeldItem(hand), world, player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
private boolean disassembleDrive( final ItemStack stack, final World world, final EntityPlayer player )
|
||||
@@ -283,7 +283,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
return this.disassembleDrive( player.getHeldItemMainhand(), world, player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
return this.disassembleDrive( player.getHeldItem(hand), world, player ) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -144,9 +144,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
if( player.isSneaking() && !w.isRemote )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItemMainhand().getItem();
|
||||
final IMemoryCard mem = (IMemoryCard) player.getHeldItem(hand).getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
player.getHeldItemMainhand().setTagCompound( null );
|
||||
player.getHeldItem(hand).setTagCompound( null );
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
Platform.openGUI( player, null, AEPartLocation.INTERNAL, GuiBridge.GUI_PORTABLE_CELL );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItemMainhand() );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
|
||||
@@ -58,8 +58,8 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick( final World w, final EntityPlayer player, final EnumHand hand )
|
||||
{
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItemMainhand(), w, player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItemMainhand() );
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui( player.getHeldItem(hand), w, player );
|
||||
return new ActionResult<ItemStack>( EnumActionResult.SUCCESS, player.getHeldItem(hand) );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
|
||||
Reference in New Issue
Block a user