Fixes #1186: Storage Cells drop upgrades upon disassembling

This commit is contained in:
thatsIch
2015-04-03 23:59:40 +02:00
parent 817163dbf6
commit 8087a43df5
16 changed files with 109 additions and 59 deletions
+4 -4
View File
@@ -78,9 +78,9 @@ public abstract class AEBaseItem extends Item implements IAEFeature
@Override
@SuppressWarnings( "unchecked" )
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayAdditionalInformation )
public final void addInformation( ItemStack stack, EntityPlayer player, List lines, boolean displayMoreInfo )
{
this.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
this.addCheckedInformation( stack, player, lines, displayMoreInfo );
}
@Override
@@ -89,8 +89,8 @@ public abstract class AEBaseItem extends Item implements IAEFeature
return false;
}
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addInformation( stack, player, lines, displayAdditionalInformation );
super.addInformation( stack, player, lines, displayMoreInfo );
}
}
@@ -85,9 +85,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
MaterialType mt = this.getTypeByStack( stack );
if( mt == null )
@@ -162,13 +162,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
int progress = this.getProgress( stack ) % SINGLE_OFFSET;
lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" );
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
}
@Override
@@ -98,7 +98,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
ICraftingPatternDetails details = this.getPatternForItem( stack, player.worldObj );
@@ -38,6 +38,7 @@ import appeng.api.config.IncludeExclude;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventoryHandler;
@@ -55,12 +56,12 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
{
final MaterialType component;
final int totalBytes;
final int perType;
final double idleDrain;
private final MaterialType component;
private final int totalBytes;
private final int perType;
private final double idleDrain;
public ItemBasicStorageCell( MaterialType whichCell, int kilobytes )
{
@@ -96,9 +97,9 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
IMEInventoryHandler inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
if( inventory instanceof ICellInventoryHandler )
{
@@ -113,12 +114,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
if( handler.isPreformatted() )
{
String List = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
if( handler.isFuzzy() )
lines.add( GuiText.Partitioned.getLocal() + " - " + List + ' ' + GuiText.Fuzzy.getLocal() );
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal() );
else
lines.add( GuiText.Partitioned.getLocal() + " - " + List + ' ' + GuiText.Precise.getLocal() );
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal() );
}
}
}
@@ -136,6 +137,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
return this.perType;
}
@Override
public int getBytesPerType( ItemStack cellItem )
{
return this.perType;
}
@Override
public int getTotalTypes( ItemStack cellItem )
{
@@ -234,10 +241,24 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
{
playerInventory.setInventorySlotContents( playerInventory.currentItem, null );
// drop core
ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
if( extraB != null )
player.dropPlayerItemWithRandomChoice( extraB, false );
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory( stack );
for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++ )
{
final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex );
final ItemStack leftStack = ia.addItems( upgradeStack );
if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule )
{
player.dropPlayerItemWithRandomChoice( upgradeStack, false );
}
}
// drop empty storage cell case
for( ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
{
final ItemStack extraA = ia.addItems( storageCellStack );
@@ -55,7 +55,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
WorldCoord wc = this.getStoredSize( stack );
if( wc.x > 0 )
@@ -166,7 +166,7 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
if( perms.isEmpty() )
@@ -46,7 +46,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
@@ -388,9 +388,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
@@ -417,6 +417,12 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
return 8;
}
@Override
public int getBytesPerType( ItemStack cellItem )
{
return 8;
}
@Override
public int getTotalTypes( ItemStack cellItem )
{
@@ -95,9 +95,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
@@ -481,6 +481,12 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
return 8;
}
@Override
public int getBytesPerType( ItemStack cellItem )
{
return 8;
}
@Override
public int getTotalTypes( ItemStack cellItem )
{
@@ -80,9 +80,9 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS );
@@ -109,6 +109,12 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
return 8;
}
@Override
public int getBytesPerType( ItemStack cellItem )
{
return 8;
}
@Override
public int getTotalTypes( ItemStack cellItem )
{
@@ -73,9 +73,9 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
super.addCheckedInformation( stack, player, lines, displayMoreInfo );
if( stack.hasTagCompound() )
{
@@ -54,7 +54,7 @@ public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPow
}
@Override
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayMoreInfo )
{
NBTTagCompound tag = stack.getTagCompound();
double internalCurrentPower = 0;