pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -41,297 +40,248 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack {
|
||||
private static final String NBT_STACKSIZE = "cnt";
|
||||
private static final String NBT_REQUESTABLE = "req";
|
||||
private static final String NBT_CRAFTABLE = "craft";
|
||||
private static final String NBT_ITEMSTACK = "is";
|
||||
|
||||
public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack
|
||||
{
|
||||
private static final String NBT_STACKSIZE = "cnt";
|
||||
private static final String NBT_REQUESTABLE = "req";
|
||||
private static final String NBT_CRAFTABLE = "craft";
|
||||
private static final String NBT_ITEMSTACK = "is";
|
||||
private final AESharedItemStack sharedStack;
|
||||
|
||||
private final AESharedItemStack sharedStack;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private ITextComponent displayName;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private List<ITextComponent> tooltip;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ITextComponent displayName;
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private List<ITextComponent> tooltip;
|
||||
private AEItemStack(final AEItemStack is) {
|
||||
this.setStackSize(is.getStackSize());
|
||||
this.setCraftable(is.isCraftable());
|
||||
this.setCountRequestable(is.getCountRequestable());
|
||||
this.sharedStack = is.sharedStack;
|
||||
}
|
||||
|
||||
private AEItemStack( final AEItemStack is )
|
||||
{
|
||||
this.setStackSize( is.getStackSize() );
|
||||
this.setCraftable( is.isCraftable() );
|
||||
this.setCountRequestable( is.getCountRequestable() );
|
||||
this.sharedStack = is.sharedStack;
|
||||
}
|
||||
private AEItemStack(final AESharedItemStack is, long size) {
|
||||
this.sharedStack = is;
|
||||
this.setStackSize(size);
|
||||
this.setCraftable(false);
|
||||
this.setCountRequestable(0);
|
||||
}
|
||||
|
||||
private AEItemStack( final AESharedItemStack is, long size )
|
||||
{
|
||||
this.sharedStack = is;
|
||||
this.setStackSize( size );
|
||||
this.setCraftable( false );
|
||||
this.setCountRequestable( 0 );
|
||||
}
|
||||
@Nullable
|
||||
public static AEItemStack fromItemStack(@Nonnull final ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AEItemStack fromItemStack( @Nonnull final ItemStack stack )
|
||||
{
|
||||
if( stack.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount());
|
||||
}
|
||||
|
||||
return new AEItemStack( AEItemStackRegistry.getRegisteredStack( stack ), stack.getCount() );
|
||||
}
|
||||
public static IAEItemStack fromNBT(final CompoundNBT i) {
|
||||
if (i == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IAEItemStack fromNBT( final CompoundNBT i )
|
||||
{
|
||||
if( i == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final ItemStack itemstack = ItemStack.read(i.getCompound(NBT_ITEMSTACK));
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack itemstack = ItemStack.read( i.getCompound( NBT_ITEMSTACK ) );
|
||||
if( itemstack.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final AEItemStack item = AEItemStack.fromItemStack(itemstack);
|
||||
item.setStackSize(i.getLong(NBT_STACKSIZE));
|
||||
item.setCountRequestable(i.getLong(NBT_REQUESTABLE));
|
||||
item.setCraftable(i.getBoolean(NBT_CRAFTABLE));
|
||||
return item;
|
||||
}
|
||||
|
||||
final AEItemStack item = AEItemStack.fromItemStack( itemstack );
|
||||
item.setStackSize( i.getLong( NBT_STACKSIZE ) );
|
||||
item.setCountRequestable( i.getLong( NBT_REQUESTABLE ) );
|
||||
item.setCraftable( i.getBoolean( NBT_CRAFTABLE ) );
|
||||
return item;
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(final CompoundNBT i) {
|
||||
final CompoundNBT itemStack = new CompoundNBT();
|
||||
this.getDefinition().write(itemStack);
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final CompoundNBT i )
|
||||
{
|
||||
final CompoundNBT itemStack = new CompoundNBT();
|
||||
this.getDefinition().write( itemStack );
|
||||
i.put(NBT_ITEMSTACK, itemStack);
|
||||
i.putLong(NBT_STACKSIZE, this.getStackSize());
|
||||
i.putLong(NBT_REQUESTABLE, this.getCountRequestable());
|
||||
i.putBoolean(NBT_CRAFTABLE, this.isCraftable());
|
||||
}
|
||||
|
||||
i.put( NBT_ITEMSTACK, itemStack );
|
||||
i.putLong( NBT_STACKSIZE, this.getStackSize() );
|
||||
i.putLong( NBT_REQUESTABLE, this.getCountRequestable() );
|
||||
i.putBoolean( NBT_CRAFTABLE, this.isCraftable() );
|
||||
}
|
||||
public static AEItemStack fromPacket(final PacketBuffer buffer) {
|
||||
final boolean isCraftable = buffer.readBoolean();
|
||||
final long stackSize = buffer.readVarLong();
|
||||
final long countRequestable = buffer.readVarLong();
|
||||
final ItemStack itemstack = buffer.readItemStack();
|
||||
|
||||
public static AEItemStack fromPacket( final PacketBuffer buffer )
|
||||
{
|
||||
final boolean isCraftable = buffer.readBoolean();
|
||||
final long stackSize = buffer.readVarLong();
|
||||
final long countRequestable = buffer.readVarLong();
|
||||
final ItemStack itemstack = buffer.readItemStack();
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if( itemstack.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final AEItemStack item = new AEItemStack(AEItemStackRegistry.getRegisteredStack(itemstack), stackSize);
|
||||
item.setCountRequestable(countRequestable);
|
||||
item.setCraftable(isCraftable);
|
||||
return item;
|
||||
}
|
||||
|
||||
final AEItemStack item = new AEItemStack( AEItemStackRegistry.getRegisteredStack( itemstack ), stackSize );
|
||||
item.setCountRequestable( countRequestable );
|
||||
item.setCraftable( isCraftable );
|
||||
return item;
|
||||
}
|
||||
@Override
|
||||
public void writeToPacket(final PacketBuffer buffer) {
|
||||
buffer.writeBoolean(this.isCraftable());
|
||||
buffer.writeVarLong(this.getStackSize());
|
||||
buffer.writeVarLong(this.getCountRequestable());
|
||||
buffer.writeItemStack(getDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket( final PacketBuffer buffer )
|
||||
{
|
||||
buffer.writeBoolean( this.isCraftable() );
|
||||
buffer.writeVarLong( this.getStackSize() );
|
||||
buffer.writeVarLong( this.getCountRequestable() );
|
||||
buffer.writeItemStack( getDefinition() );
|
||||
}
|
||||
@Override
|
||||
public void add(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.incStackSize(option.getStackSize());
|
||||
this.setCountRequestable(this.getCountRequestable() + option.getCountRequestable());
|
||||
this.setCraftable(this.isCraftable() || option.isCraftable());
|
||||
}
|
||||
|
||||
this.incStackSize( option.getStackSize() );
|
||||
this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() );
|
||||
this.setCraftable( this.isCraftable() || option.isCraftable() );
|
||||
}
|
||||
@Override
|
||||
public boolean fuzzyComparison(final IAEItemStack other, final FuzzyMode mode) {
|
||||
final ItemStack itemStack = this.getDefinition();
|
||||
final ItemStack otherStack = other.getDefinition();
|
||||
|
||||
@Override
|
||||
public boolean fuzzyComparison( final IAEItemStack other, final FuzzyMode mode )
|
||||
{
|
||||
final ItemStack itemStack = this.getDefinition();
|
||||
final ItemStack otherStack = other.getDefinition();
|
||||
return this.fuzzyItemStackComparison(itemStack, otherStack, mode);
|
||||
}
|
||||
|
||||
return this.fuzzyItemStackComparison( itemStack, otherStack, mode );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack copy() {
|
||||
return new AEItemStack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack copy()
|
||||
{
|
||||
return new AEItemStack( this );
|
||||
}
|
||||
@Override
|
||||
public boolean isItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isFluid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluid()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEItemStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
@Override
|
||||
public ItemStack createItemStack() {
|
||||
return ItemHandlerHelper.copyStackWithSize(this.getDefinition(),
|
||||
(int) Math.min(Integer.MAX_VALUE, this.getStackSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createItemStack()
|
||||
{
|
||||
return ItemHandlerHelper.copyStackWithSize( this.getDefinition(), (int) Math.min( Integer.MAX_VALUE, this.getStackSize() ) );
|
||||
}
|
||||
@Override
|
||||
public Item getItem() {
|
||||
return this.getDefinition().getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return this.getDefinition().getItem();
|
||||
}
|
||||
@Override
|
||||
public int getItemDamage() {
|
||||
return this.sharedStack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemDamage()
|
||||
{
|
||||
return this.sharedStack.getItemDamage();
|
||||
}
|
||||
@Override
|
||||
public boolean isSameType(final IAEItemStack otherStack) {
|
||||
if (otherStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType( final IAEItemStack otherStack )
|
||||
{
|
||||
if( otherStack == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(this.sharedStack, ((AEItemStack) otherStack).sharedStack);
|
||||
}
|
||||
|
||||
return Objects.equals( this.sharedStack, ( (AEItemStack) otherStack ).sharedStack );
|
||||
}
|
||||
@Override
|
||||
public boolean isSameType(final ItemStack otherStack) {
|
||||
if (otherStack.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int oldSize = otherStack.getCount();
|
||||
|
||||
@Override
|
||||
public boolean isSameType( final ItemStack otherStack )
|
||||
{
|
||||
if( otherStack.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int oldSize = otherStack.getCount();
|
||||
otherStack.setCount(1);
|
||||
boolean ret = ItemStack.areItemStacksEqual(this.getDefinition(), otherStack);
|
||||
otherStack.setCount(oldSize);
|
||||
|
||||
otherStack.setCount( 1 );
|
||||
boolean ret = ItemStack.areItemStacksEqual( this.getDefinition(), otherStack );
|
||||
otherStack.setCount( oldSize );
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.sharedStack.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.sharedStack.hashCode();
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object ia) {
|
||||
if (ia instanceof AEItemStack) {
|
||||
return this.isSameType((AEItemStack) ia);
|
||||
} else if (ia instanceof ItemStack) {
|
||||
return this.isSameType((ItemStack) ia);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object ia )
|
||||
{
|
||||
if( ia instanceof AEItemStack )
|
||||
{
|
||||
return this.isSameType( (AEItemStack) ia );
|
||||
}
|
||||
else if( ia instanceof ItemStack )
|
||||
{
|
||||
return this.isSameType( (ItemStack) ia );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName();
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public List<ITextComponent> getToolTip() {
|
||||
if (this.tooltip == null) {
|
||||
this.tooltip = Platform.getTooltip(this.asItemStackRepresentation());
|
||||
}
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public List<ITextComponent> getToolTip()
|
||||
{
|
||||
if( this.tooltip == null )
|
||||
{
|
||||
this.tooltip = Platform.getTooltip( this.asItemStackRepresentation() );
|
||||
}
|
||||
return this.tooltip;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public ITextComponent getDisplayName() {
|
||||
if (this.displayName == null) {
|
||||
this.displayName = Platform.getItemDisplayName(this.asItemStackRepresentation());
|
||||
}
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( this.displayName == null )
|
||||
{
|
||||
this.displayName = Platform.getItemDisplayName( this.asItemStackRepresentation() );
|
||||
}
|
||||
return this.displayName;
|
||||
}
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public String getModID() {
|
||||
return this.getDefinition().getItem().getRegistryName().getNamespace();
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public String getModID()
|
||||
{
|
||||
return this.getDefinition().getItem().getRegistryName().getNamespace();
|
||||
}
|
||||
@Override
|
||||
public boolean hasTagCompound() {
|
||||
return this.getDefinition().hasTag();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTagCompound()
|
||||
{
|
||||
return this.getDefinition().hasTag();
|
||||
}
|
||||
@Override
|
||||
public ItemStack asItemStackRepresentation() {
|
||||
return this.getDefinition().copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack asItemStackRepresentation()
|
||||
{
|
||||
return this.getDefinition().copy();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDefinition() {
|
||||
return this.sharedStack.getDefinition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDefinition()
|
||||
{
|
||||
return this.sharedStack.getDefinition();
|
||||
}
|
||||
AESharedItemStack getSharedStack() {
|
||||
return this.sharedStack;
|
||||
}
|
||||
|
||||
AESharedItemStack getSharedStack()
|
||||
{
|
||||
return this.sharedStack;
|
||||
}
|
||||
private boolean fuzzyItemStackComparison(ItemStack a, ItemStack b, FuzzyMode mode) {
|
||||
if (a.getItem() == b.getItem()) {
|
||||
if (a.getItem().isDamageable()) {
|
||||
if (mode == FuzzyMode.IGNORE_ALL) {
|
||||
return true;
|
||||
} else if (mode == FuzzyMode.PERCENT_99) {
|
||||
return (a.getDamage() > 1) == (b.getDamage() > 1);
|
||||
} else {
|
||||
final float percentDamageOfA = (float) a.getDamage() / a.getMaxDamage();
|
||||
final float percentDamageOfB = (float) b.getDamage() / b.getMaxDamage();
|
||||
|
||||
private boolean fuzzyItemStackComparison( ItemStack a, ItemStack b, FuzzyMode mode )
|
||||
{
|
||||
if( a.getItem() == b.getItem() )
|
||||
{
|
||||
if( a.getItem().isDamageable() )
|
||||
{
|
||||
if( mode == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( mode == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
return ( a.getDamage() > 1 ) == ( b.getDamage() > 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final float percentDamageOfA = (float) a.getDamage() / a.getMaxDamage();
|
||||
final float percentDamageOfB = (float) b.getDamage() / b.getMaxDamage();
|
||||
return (percentDamageOfA > mode.breakPoint) == (percentDamageOfB > mode.breakPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( percentDamageOfA > mode.breakPoint ) == ( percentDamageOfB > mode.breakPoint );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
@@ -33,54 +32,43 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
public final class AEItemStackRegistry {
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> SERVER_REGISTRY = new WeakHashMap<>();
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> CLIENT_REGISTRY = new WeakHashMap<>();
|
||||
|
||||
public final class AEItemStackRegistry
|
||||
{
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> SERVER_REGISTRY = new WeakHashMap<>();
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> CLIENT_REGISTRY = new WeakHashMap<>();
|
||||
private AEItemStackRegistry() {
|
||||
}
|
||||
|
||||
private AEItemStackRegistry()
|
||||
{
|
||||
}
|
||||
private static WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> registry() {
|
||||
if (Platform.isClient()) {
|
||||
return CLIENT_REGISTRY;
|
||||
} else {
|
||||
return SERVER_REGISTRY;
|
||||
}
|
||||
}
|
||||
|
||||
private static WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> registry()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return CLIENT_REGISTRY;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SERVER_REGISTRY;
|
||||
}
|
||||
}
|
||||
static synchronized AESharedItemStack getRegisteredStack(final @Nonnull ItemStack itemStack) {
|
||||
if (itemStack.isEmpty()) {
|
||||
throw new IllegalArgumentException("stack cannot be empty");
|
||||
}
|
||||
|
||||
static synchronized AESharedItemStack getRegisteredStack( final @Nonnull ItemStack itemStack )
|
||||
{
|
||||
if( itemStack.isEmpty() )
|
||||
{
|
||||
throw new IllegalArgumentException( "stack cannot be empty" );
|
||||
}
|
||||
int oldStackSize = itemStack.getCount();
|
||||
itemStack.setCount(1);
|
||||
|
||||
int oldStackSize = itemStack.getCount();
|
||||
itemStack.setCount( 1 );
|
||||
AESharedItemStack search = new AESharedItemStack(itemStack);
|
||||
WeakReference<AESharedItemStack> weak = registry().get(search);
|
||||
AESharedItemStack ret = null;
|
||||
|
||||
AESharedItemStack search = new AESharedItemStack( itemStack );
|
||||
WeakReference<AESharedItemStack> weak = registry().get( search );
|
||||
AESharedItemStack ret = null;
|
||||
if (weak != null) {
|
||||
ret = weak.get();
|
||||
}
|
||||
|
||||
if( weak != null )
|
||||
{
|
||||
ret = weak.get();
|
||||
}
|
||||
if (ret == null) {
|
||||
ret = new AESharedItemStack(itemStack.copy());
|
||||
registry().put(ret, new WeakReference<>(ret));
|
||||
}
|
||||
itemStack.setCount(oldStackSize);
|
||||
|
||||
if( ret == null )
|
||||
{
|
||||
ret = new AESharedItemStack( itemStack.copy() );
|
||||
registry().put( ret, new WeakReference<>( ret ) );
|
||||
}
|
||||
itemStack.setCount( oldStackSize );
|
||||
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -29,196 +28,159 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
|
||||
final class AESharedItemStack implements Comparable<AESharedItemStack> {
|
||||
private final ItemStack itemStack;
|
||||
private final int itemId;
|
||||
private final int itemDamage;
|
||||
private final int hashCode;
|
||||
|
||||
final class AESharedItemStack implements Comparable<AESharedItemStack>
|
||||
{
|
||||
private final ItemStack itemStack;
|
||||
private final int itemId;
|
||||
private final int itemDamage;
|
||||
private final int hashCode;
|
||||
public AESharedItemStack(final ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
this.itemId = Item.getIdFromItem(itemStack.getItem());
|
||||
this.itemDamage = itemStack.getDamage();
|
||||
this.hashCode = this.makeHashCode();
|
||||
}
|
||||
|
||||
public AESharedItemStack( final ItemStack itemStack )
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.itemId = Item.getIdFromItem( itemStack.getItem() );
|
||||
this.itemDamage = itemStack.getDamage();
|
||||
this.hashCode = this.makeHashCode();
|
||||
}
|
||||
Bounds getBounds(final FuzzyMode fuzzy) {
|
||||
return new Bounds(this.itemStack, fuzzy);
|
||||
}
|
||||
|
||||
Bounds getBounds( final FuzzyMode fuzzy )
|
||||
{
|
||||
return new Bounds( this.itemStack, fuzzy );
|
||||
}
|
||||
ItemStack getDefinition() {
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
ItemStack getDefinition()
|
||||
{
|
||||
return this.itemStack;
|
||||
}
|
||||
int getItemDamage() {
|
||||
return this.itemDamage;
|
||||
}
|
||||
|
||||
int getItemDamage()
|
||||
{
|
||||
return this.itemDamage;
|
||||
}
|
||||
int getItemID() {
|
||||
return this.itemId;
|
||||
}
|
||||
|
||||
int getItemID()
|
||||
{
|
||||
return this.itemId;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.hashCode;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj instanceof AESharedItemStack) {
|
||||
final AESharedItemStack other = (AESharedItemStack) obj;
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object obj )
|
||||
{
|
||||
if( obj instanceof AESharedItemStack )
|
||||
{
|
||||
final AESharedItemStack other = (AESharedItemStack) obj;
|
||||
Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
Preconditions.checkArgument(other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
|
||||
Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
Preconditions.checkArgument( other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
if (this.itemStack == other.itemStack) {
|
||||
return true;
|
||||
}
|
||||
return ItemStack.areItemStacksEqual(this.itemStack, other.itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( this.itemStack == other.itemStack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ItemStack.areItemStacksEqual( this.itemStack, other.itemStack );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int compareTo(final AESharedItemStack b) {
|
||||
Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
Preconditions.checkArgument(b.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
|
||||
@Override
|
||||
public int compareTo( final AESharedItemStack b )
|
||||
{
|
||||
Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
Preconditions.checkArgument( b.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
if (this.itemStack == b.getDefinition()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( this.itemStack == b.getDefinition() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final int id = this.itemId - b.itemId;
|
||||
if (id != 0) {
|
||||
return id;
|
||||
}
|
||||
|
||||
final int id = this.itemId - b.itemId;
|
||||
if( id != 0 )
|
||||
{
|
||||
return id;
|
||||
}
|
||||
final int damageValue = this.itemDamage - b.itemDamage;
|
||||
if (damageValue != 0) {
|
||||
return damageValue;
|
||||
}
|
||||
|
||||
final int damageValue = this.itemDamage - b.itemDamage;
|
||||
if( damageValue != 0 )
|
||||
{
|
||||
return damageValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
private int makeHashCode() {
|
||||
return Objects.hash(this.itemId, this.itemDamage, this.itemStack.hasTag() ? this.itemStack.getTag() : 0);
|
||||
}
|
||||
|
||||
private int makeHashCode()
|
||||
{
|
||||
return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTag() ? this.itemStack.getTag() : 0 );
|
||||
}
|
||||
/**
|
||||
* Creates the lower and upper bounds for a specific shared itemstack.
|
||||
*/
|
||||
public static final class Bounds {
|
||||
/**
|
||||
* Bounds enforced by {@link ItemStack#isEmpty()}
|
||||
*/
|
||||
private static final int MIN_DAMAGE_VALUE = 0;
|
||||
private static final int MAX_DAMAGE_VALUE = Short.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Creates the lower and upper bounds for a specific shared itemstack.
|
||||
*/
|
||||
public static final class Bounds
|
||||
{
|
||||
/**
|
||||
* Bounds enforced by {@link ItemStack#isEmpty()}
|
||||
*/
|
||||
private static final int MIN_DAMAGE_VALUE = 0;
|
||||
private static final int MAX_DAMAGE_VALUE = Short.MAX_VALUE;
|
||||
private final AESharedItemStack lower;
|
||||
private final AESharedItemStack upper;
|
||||
|
||||
private final AESharedItemStack lower;
|
||||
private final AESharedItemStack upper;
|
||||
public Bounds(final ItemStack stack, final FuzzyMode fuzzy) {
|
||||
Preconditions.checkState(!stack.isEmpty(), "ItemStack#isEmpty() has to be false");
|
||||
Preconditions.checkState(stack.getCount() == 1, "ItemStack#getCount() has to be 1");
|
||||
|
||||
public Bounds( final ItemStack stack, final FuzzyMode fuzzy )
|
||||
{
|
||||
Preconditions.checkState( !stack.isEmpty(), "ItemStack#isEmpty() has to be false" );
|
||||
Preconditions.checkState( stack.getCount() == 1, "ItemStack#getCount() has to be 1" );
|
||||
final CompoundNBT tag = stack.hasTag() ? stack.getTag() : null;
|
||||
|
||||
final CompoundNBT tag = stack.hasTag() ? stack.getTag() : null;
|
||||
this.lower = this.makeLowerBound(stack, tag, fuzzy);
|
||||
this.upper = this.makeUpperBound(stack, tag, fuzzy);
|
||||
}
|
||||
|
||||
this.lower = this.makeLowerBound( stack, tag, fuzzy );
|
||||
this.upper = this.makeUpperBound( stack, tag, fuzzy );
|
||||
}
|
||||
public AESharedItemStack lower() {
|
||||
return this.lower;
|
||||
}
|
||||
|
||||
public AESharedItemStack lower()
|
||||
{
|
||||
return this.lower;
|
||||
}
|
||||
public AESharedItemStack upper() {
|
||||
return this.upper;
|
||||
}
|
||||
|
||||
public AESharedItemStack upper()
|
||||
{
|
||||
return this.upper;
|
||||
}
|
||||
private AESharedItemStack makeLowerBound(final ItemStack itemStack, final CompoundNBT tag,
|
||||
final FuzzyMode fuzzy) {
|
||||
final ItemStack newDef = itemStack.copy();
|
||||
|
||||
private AESharedItemStack makeLowerBound( final ItemStack itemStack, final CompoundNBT tag, final FuzzyMode fuzzy )
|
||||
{
|
||||
final ItemStack newDef = itemStack.copy();
|
||||
if (newDef.getItem().isDamageable()) {
|
||||
if (fuzzy == FuzzyMode.IGNORE_ALL) {
|
||||
newDef.setDamage(MIN_DAMAGE_VALUE);
|
||||
} else if (fuzzy == FuzzyMode.PERCENT_99) {
|
||||
if (itemStack.getDamage() == MIN_DAMAGE_VALUE) {
|
||||
newDef.setDamage(MIN_DAMAGE_VALUE);
|
||||
} else {
|
||||
newDef.setDamage(MIN_DAMAGE_VALUE + 1);
|
||||
}
|
||||
} else {
|
||||
final int breakpoint = fuzzy.calculateBreakPoint(itemStack.getMaxDamage());
|
||||
final int damage = breakpoint <= itemStack.getDamage() ? breakpoint : 0;
|
||||
newDef.setDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
if( newDef.getItem().isDamageable() )
|
||||
{
|
||||
if( fuzzy == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
newDef.setDamage( MIN_DAMAGE_VALUE );
|
||||
}
|
||||
else if( fuzzy == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
if( itemStack.getDamage() == MIN_DAMAGE_VALUE )
|
||||
{
|
||||
newDef.setDamage( MIN_DAMAGE_VALUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
newDef.setDamage( MIN_DAMAGE_VALUE + 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() );
|
||||
final int damage = breakpoint <= itemStack.getDamage() ? breakpoint : 0;
|
||||
newDef.setDamage( damage );
|
||||
}
|
||||
}
|
||||
return new AESharedItemStack(newDef);
|
||||
}
|
||||
|
||||
return new AESharedItemStack( newDef );
|
||||
}
|
||||
private AESharedItemStack makeUpperBound(final ItemStack itemStack, final CompoundNBT tag,
|
||||
final FuzzyMode fuzzy) {
|
||||
final ItemStack newDef = itemStack.copy();
|
||||
|
||||
private AESharedItemStack makeUpperBound( final ItemStack itemStack, final CompoundNBT tag, final FuzzyMode fuzzy )
|
||||
{
|
||||
final ItemStack newDef = itemStack.copy();
|
||||
if (newDef.getItem().isDamageable()) {
|
||||
if (fuzzy == FuzzyMode.IGNORE_ALL) {
|
||||
newDef.setDamage(itemStack.getMaxDamage() + 1);
|
||||
} else if (fuzzy == FuzzyMode.PERCENT_99) {
|
||||
if (itemStack.getDamage() == MIN_DAMAGE_VALUE) {
|
||||
newDef.setDamage(MIN_DAMAGE_VALUE);
|
||||
} else {
|
||||
newDef.setDamage(itemStack.getMaxDamage() + 1);
|
||||
}
|
||||
} else {
|
||||
final int breakpoint = fuzzy.calculateBreakPoint(itemStack.getMaxDamage());
|
||||
final int damage = itemStack.getDamage() < breakpoint ? breakpoint - 1
|
||||
: itemStack.getMaxDamage() + 1;
|
||||
newDef.setDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
if( newDef.getItem().isDamageable() )
|
||||
{
|
||||
if( fuzzy == FuzzyMode.IGNORE_ALL )
|
||||
{
|
||||
newDef.setDamage( itemStack.getMaxDamage() + 1 );
|
||||
}
|
||||
else if( fuzzy == FuzzyMode.PERCENT_99 )
|
||||
{
|
||||
if( itemStack.getDamage() == MIN_DAMAGE_VALUE )
|
||||
{
|
||||
newDef.setDamage( MIN_DAMAGE_VALUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
newDef.setDamage( itemStack.getMaxDamage() + 1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() );
|
||||
final int damage = itemStack.getDamage() < breakpoint ? breakpoint - 1 : itemStack.getMaxDamage() + 1;
|
||||
newDef.setDamage( damage );
|
||||
}
|
||||
}
|
||||
return new AESharedItemStack(newDef);
|
||||
}
|
||||
|
||||
return new AESharedItemStack( newDef );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,102 +18,86 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public abstract class AEStack<T extends IAEStack<T>> implements IAEStack<T> {
|
||||
|
||||
public abstract class AEStack<T extends IAEStack<T>> implements IAEStack<T>
|
||||
{
|
||||
private boolean isCraftable;
|
||||
private long stackSize;
|
||||
private long countRequestable;
|
||||
|
||||
private boolean isCraftable;
|
||||
private long stackSize;
|
||||
private long countRequestable;
|
||||
@Override
|
||||
public long getStackSize() {
|
||||
return this.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStackSize()
|
||||
{
|
||||
return this.stackSize;
|
||||
}
|
||||
@Override
|
||||
public T setStackSize(final long ss) {
|
||||
this.stackSize = ss;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setStackSize( final long ss )
|
||||
{
|
||||
this.stackSize = ss;
|
||||
return (T) this;
|
||||
}
|
||||
@Override
|
||||
public long getCountRequestable() {
|
||||
return this.countRequestable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCountRequestable()
|
||||
{
|
||||
return this.countRequestable;
|
||||
}
|
||||
@Override
|
||||
public T setCountRequestable(final long countRequestable) {
|
||||
this.countRequestable = countRequestable;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setCountRequestable( final long countRequestable )
|
||||
{
|
||||
this.countRequestable = countRequestable;
|
||||
return (T) this;
|
||||
}
|
||||
@Override
|
||||
public boolean isCraftable() {
|
||||
return this.isCraftable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftable()
|
||||
{
|
||||
return this.isCraftable;
|
||||
}
|
||||
@Override
|
||||
public T setCraftable(final boolean isCraftable) {
|
||||
this.isCraftable = isCraftable;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setCraftable( final boolean isCraftable )
|
||||
{
|
||||
this.isCraftable = isCraftable;
|
||||
return (T) this;
|
||||
}
|
||||
@Override
|
||||
public T reset() {
|
||||
this.stackSize = 0;
|
||||
this.setCountRequestable(0);
|
||||
this.setCraftable(false);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T reset()
|
||||
{
|
||||
this.stackSize = 0;
|
||||
this.setCountRequestable( 0 );
|
||||
this.setCraftable( false );
|
||||
return (T) this;
|
||||
}
|
||||
@Override
|
||||
public T empty() {
|
||||
final T dup = this.copy();
|
||||
dup.reset();
|
||||
return dup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T empty()
|
||||
{
|
||||
final T dup = this.copy();
|
||||
dup.reset();
|
||||
return dup;
|
||||
}
|
||||
@Override
|
||||
public boolean isMeaningful() {
|
||||
return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMeaningful()
|
||||
{
|
||||
return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable;
|
||||
}
|
||||
@Override
|
||||
public void incStackSize(final long i) {
|
||||
this.stackSize += i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incStackSize( final long i )
|
||||
{
|
||||
this.stackSize += i;
|
||||
}
|
||||
@Override
|
||||
public void decStackSize(final long i) {
|
||||
this.stackSize -= i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decStackSize( final long i )
|
||||
{
|
||||
this.stackSize -= i;
|
||||
}
|
||||
@Override
|
||||
public void incCountRequestable(final long i) {
|
||||
this.countRequestable += i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incCountRequestable( final long i )
|
||||
{
|
||||
this.countRequestable += i;
|
||||
}
|
||||
@Override
|
||||
public void decCountRequestable(final long i) {
|
||||
this.countRequestable -= i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decCountRequestable( final long i )
|
||||
{
|
||||
this.countRequestable -= i;
|
||||
}
|
||||
|
||||
protected abstract boolean hasTagCompound();
|
||||
protected abstract boolean hasTagCompound();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -28,173 +27,145 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
abstract class AbstractItemList implements IItemList<IAEItemStack> {
|
||||
|
||||
abstract class AbstractItemList implements IItemList<IAEItemStack>
|
||||
{
|
||||
@Override
|
||||
public void add(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.add(option);
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.add( option );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack findPrecise(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack findPrecise( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.getRecords().get(((AEItemStack) itemStack).getSharedStack());
|
||||
}
|
||||
|
||||
return this.getRecords().get( ( (AEItemStack) itemStack ).getSharedStack() );
|
||||
}
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
|
||||
if (filter == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy )
|
||||
{
|
||||
if( filter == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.getRecords().values();
|
||||
}
|
||||
|
||||
return this.getRecords().values();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
@Override
|
||||
public void addStorage(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorage( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.incStackSize(option.getStackSize());
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.incStackSize( option.getStackSize() );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public void addCrafting(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrafting( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.setCraftable(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.setCraftable( true );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize(0);
|
||||
opt.setCraftable(true);
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize( 0 );
|
||||
opt.setCraftable( true );
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public void addRequestable(final IAEItemStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequestable( final IAEItemStack option )
|
||||
{
|
||||
if( option == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
|
||||
|
||||
final IAEItemStack st = this.getRecords().get( ( (AEItemStack) option ).getSharedStack() );
|
||||
if (st != null) {
|
||||
st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable());
|
||||
return;
|
||||
}
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() );
|
||||
return;
|
||||
}
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize(0);
|
||||
opt.setCraftable(false);
|
||||
opt.setCountRequestable(option.getCountRequestable());
|
||||
|
||||
final IAEItemStack opt = option.copy();
|
||||
opt.setStackSize( 0 );
|
||||
opt.setCraftable( false );
|
||||
opt.setCountRequestable( option.getCountRequestable() );
|
||||
this.putItemRecord(opt);
|
||||
}
|
||||
|
||||
this.putItemRecord( opt );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack getFirstItem() {
|
||||
for (final IAEItemStack stackType : this) {
|
||||
return stackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getFirstItem()
|
||||
{
|
||||
for( final IAEItemStack stackType : this )
|
||||
{
|
||||
return stackType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
int size = 0;
|
||||
for (IAEItemStack entry : getRecords().values()) {
|
||||
if (entry.isMeaningful()) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
int size = 0;
|
||||
for( IAEItemStack entry : getRecords().values() )
|
||||
{
|
||||
if( entry.isMeaningful() )
|
||||
{
|
||||
size++;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator() {
|
||||
return new MeaningfulItemIterator<>(this.getRecords().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator()
|
||||
{
|
||||
return new MeaningfulItemIterator<>( this.getRecords().values() );
|
||||
}
|
||||
@Override
|
||||
public void resetStatus() {
|
||||
for (final IAEItemStack i : this) {
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStatus()
|
||||
{
|
||||
for( final IAEItemStack i : this )
|
||||
{
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
abstract Map<AESharedItemStack, IAEItemStack> getRecords();
|
||||
|
||||
abstract Map<AESharedItemStack, IAEItemStack> getRecords();
|
||||
|
||||
private IAEItemStack putItemRecord( final IAEItemStack itemStack )
|
||||
{
|
||||
return this.getRecords().put( ( (AEItemStack) itemStack ).getSharedStack(), itemStack );
|
||||
}
|
||||
private IAEItemStack putItemRecord(final IAEItemStack itemStack) {
|
||||
return this.getRecords().put(((AEItemStack) itemStack).getSharedStack(), itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -29,34 +28,28 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AESharedItemStack.Bounds;
|
||||
|
||||
class FuzzyItemList extends AbstractItemList {
|
||||
private final NavigableMap<AESharedItemStack, IAEItemStack> records = new TreeMap<>();
|
||||
|
||||
class FuzzyItemList extends AbstractItemList
|
||||
{
|
||||
private final NavigableMap<AESharedItemStack, IAEItemStack> records = new TreeMap<>();
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
|
||||
if (filter == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy )
|
||||
{
|
||||
if( filter == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.findFuzzyDamage(filter, fuzzy);
|
||||
}
|
||||
|
||||
return this.findFuzzyDamage( filter, fuzzy );
|
||||
}
|
||||
@Override
|
||||
Map<AESharedItemStack, IAEItemStack> getRecords() {
|
||||
return this.records;
|
||||
}
|
||||
|
||||
@Override
|
||||
Map<AESharedItemStack, IAEItemStack> getRecords()
|
||||
{
|
||||
return this.records;
|
||||
}
|
||||
private Collection<IAEItemStack> findFuzzyDamage(final IAEItemStack filter, final FuzzyMode fuzzy) {
|
||||
final AEItemStack itemStack = (AEItemStack) filter;
|
||||
final Bounds bounds = itemStack.getSharedStack().getBounds(fuzzy);
|
||||
|
||||
private Collection<IAEItemStack> findFuzzyDamage( final IAEItemStack filter, final FuzzyMode fuzzy )
|
||||
{
|
||||
final AEItemStack itemStack = (AEItemStack) filter;
|
||||
final Bounds bounds = itemStack.getSharedStack().getBounds( fuzzy );
|
||||
|
||||
return this.records.subMap( bounds.lower(), true, bounds.upper(), true ).descendingMap().values();
|
||||
}
|
||||
return this.records.subMap(bounds.lower(), true, bounds.upper(), true).descendingMap().values();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
@@ -32,194 +31,155 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
public final class ItemList implements IItemList<IAEItemStack> {
|
||||
|
||||
public final class ItemList implements IItemList<IAEItemStack>
|
||||
{
|
||||
private final static IItemList<IAEItemStack> NULL_ITEMLIST = new NullItemList();
|
||||
|
||||
private final static IItemList<IAEItemStack> NULL_ITEMLIST = new NullItemList();
|
||||
private final Map<Item, IItemList<IAEItemStack>> records = new IdentityHashMap<>();
|
||||
|
||||
private final Map<Item, IItemList<IAEItemStack>> records = new IdentityHashMap<>();
|
||||
@Override
|
||||
public IAEItemStack findPrecise(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack findPrecise( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.getRecord(itemStack.getItem()).findPrecise(itemStack);
|
||||
}
|
||||
|
||||
return this.getRecord( itemStack.getItem() ).findPrecise( itemStack );
|
||||
}
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
|
||||
if (filter == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy )
|
||||
{
|
||||
if( filter == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.getRecord(filter.getItem()).findFuzzy(filter, fuzzy);
|
||||
}
|
||||
|
||||
return this.getRecord( filter.getItem() ).findFuzzy( filter, fuzzy );
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
@Override
|
||||
public void add(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.getOrCreateRecord(itemStack.getItem()).add(itemStack);
|
||||
}
|
||||
|
||||
this.getOrCreateRecord( itemStack.getItem() ).add( itemStack );
|
||||
}
|
||||
@Override
|
||||
public void addStorage(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorage( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.getOrCreateRecord(itemStack.getItem()).addStorage(itemStack);
|
||||
}
|
||||
|
||||
this.getOrCreateRecord( itemStack.getItem() ).addStorage( itemStack );
|
||||
}
|
||||
@Override
|
||||
public void addCrafting(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrafting( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.getOrCreateRecord(itemStack.getItem()).addCrafting(itemStack);
|
||||
}
|
||||
|
||||
this.getOrCreateRecord( itemStack.getItem() ).addCrafting( itemStack );
|
||||
}
|
||||
@Override
|
||||
public void addRequestable(final IAEItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequestable( final IAEItemStack itemStack )
|
||||
{
|
||||
if( itemStack == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.getOrCreateRecord(itemStack.getItem()).addRequestable(itemStack);
|
||||
}
|
||||
|
||||
this.getOrCreateRecord( itemStack.getItem() ).addRequestable( itemStack );
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack getFirstItem() {
|
||||
for (final IAEItemStack stackType : this) {
|
||||
return stackType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getFirstItem()
|
||||
{
|
||||
for( final IAEItemStack stackType : this )
|
||||
{
|
||||
return stackType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
int size = 0;
|
||||
for (IItemList<IAEItemStack> entry : records.values()) {
|
||||
size += entry.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
int size = 0;
|
||||
for( IItemList<IAEItemStack> entry : records.values() )
|
||||
{
|
||||
size += entry.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator() {
|
||||
return new ChainedIterator(this.records.values().iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator()
|
||||
{
|
||||
return new ChainedIterator( this.records.values().iterator() );
|
||||
}
|
||||
@Override
|
||||
public void resetStatus() {
|
||||
for (final IAEItemStack i : this) {
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStatus()
|
||||
{
|
||||
for( final IAEItemStack i : this )
|
||||
{
|
||||
i.reset();
|
||||
}
|
||||
}
|
||||
private IItemList<IAEItemStack> getRecord(Item item) {
|
||||
return this.records.getOrDefault(item, NULL_ITEMLIST);
|
||||
}
|
||||
|
||||
private IItemList<IAEItemStack> getRecord( Item item )
|
||||
{
|
||||
return this.records.getOrDefault( item, NULL_ITEMLIST );
|
||||
}
|
||||
private IItemList<IAEItemStack> getOrCreateRecord(Item item) {
|
||||
return this.records.computeIfAbsent(item, this::makeRecordMap);
|
||||
}
|
||||
|
||||
private IItemList<IAEItemStack> getOrCreateRecord( Item item )
|
||||
{
|
||||
return this.records.computeIfAbsent( item, this::makeRecordMap );
|
||||
}
|
||||
private IItemList<IAEItemStack> makeRecordMap(Item item) {
|
||||
if (item.isDamageable()) {
|
||||
return new FuzzyItemList();
|
||||
} else {
|
||||
return new StrictItemList();
|
||||
}
|
||||
}
|
||||
|
||||
private IItemList<IAEItemStack> makeRecordMap( Item item )
|
||||
{
|
||||
if( item.isDamageable() )
|
||||
{
|
||||
return new FuzzyItemList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StrictItemList();
|
||||
}
|
||||
}
|
||||
private class ChainedIterator implements Iterator<IAEItemStack> {
|
||||
|
||||
private class ChainedIterator implements Iterator<IAEItemStack>
|
||||
{
|
||||
private final Iterator<IItemList<IAEItemStack>> parent;
|
||||
private Iterator<IAEItemStack> next;
|
||||
|
||||
private final Iterator<IItemList<IAEItemStack>> parent;
|
||||
private Iterator<IAEItemStack> next;
|
||||
public ChainedIterator(Iterator<IItemList<IAEItemStack>> iterator) {
|
||||
this.parent = iterator;
|
||||
if (this.parent.hasNext()) {
|
||||
this.next = this.parent.next().iterator();
|
||||
}
|
||||
}
|
||||
|
||||
public ChainedIterator( Iterator<IItemList<IAEItemStack>> iterator )
|
||||
{
|
||||
this.parent = iterator;
|
||||
if( this.parent.hasNext() )
|
||||
{
|
||||
this.next = this.parent.next().iterator();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
while (this.next != null) {
|
||||
if (this.next.hasNext()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
while( this.next != null )
|
||||
{
|
||||
if( this.next.hasNext() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (this.parent.hasNext()) {
|
||||
this.next = this.parent.next().iterator();
|
||||
} else {
|
||||
this.next = null;
|
||||
}
|
||||
}
|
||||
|
||||
if( this.parent.hasNext() )
|
||||
{
|
||||
this.next = this.parent.next().iterator();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.next = null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack next() {
|
||||
if (this.next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack next()
|
||||
{
|
||||
if( this.next == null )
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return this.next.next();
|
||||
}
|
||||
|
||||
return this.next.next();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -27,61 +26,48 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemContainer;
|
||||
|
||||
public class ItemModList implements IItemContainer<IAEItemStack> {
|
||||
|
||||
public class ItemModList implements IItemContainer<IAEItemStack>
|
||||
{
|
||||
private final IItemContainer<IAEItemStack> backingStore;
|
||||
private final IItemContainer<IAEItemStack> overrides = AEApi.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
private final IItemContainer<IAEItemStack> backingStore;
|
||||
private final IItemContainer<IAEItemStack> overrides = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
public ItemModList(final IItemContainer<IAEItemStack> backend) {
|
||||
this.backingStore = backend;
|
||||
}
|
||||
|
||||
public ItemModList( final IItemContainer<IAEItemStack> backend )
|
||||
{
|
||||
this.backingStore = backend;
|
||||
}
|
||||
@Override
|
||||
public void add(final IAEItemStack option) {
|
||||
IAEItemStack over = this.overrides.findPrecise(option);
|
||||
if (over == null) {
|
||||
over = this.backingStore.findPrecise(option);
|
||||
if (over == null) {
|
||||
this.overrides.add(option);
|
||||
} else {
|
||||
option.add(over);
|
||||
this.overrides.add(option);
|
||||
}
|
||||
} else {
|
||||
this.overrides.add(option);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( final IAEItemStack option )
|
||||
{
|
||||
IAEItemStack over = this.overrides.findPrecise( option );
|
||||
if( over == null )
|
||||
{
|
||||
over = this.backingStore.findPrecise( option );
|
||||
if( over == null )
|
||||
{
|
||||
this.overrides.add( option );
|
||||
}
|
||||
else
|
||||
{
|
||||
option.add( over );
|
||||
this.overrides.add( option );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.overrides.add( option );
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack findPrecise(final IAEItemStack i) {
|
||||
final IAEItemStack over = this.overrides.findPrecise(i);
|
||||
if (over == null) {
|
||||
return this.backingStore.findPrecise(i);
|
||||
}
|
||||
return over;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack findPrecise( final IAEItemStack i )
|
||||
{
|
||||
final IAEItemStack over = this.overrides.findPrecise( i );
|
||||
if( over == null )
|
||||
{
|
||||
return this.backingStore.findPrecise( i );
|
||||
}
|
||||
return over;
|
||||
}
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(final IAEItemStack input, final FuzzyMode fuzzy) {
|
||||
return this.overrides.findFuzzy(input, fuzzy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( final IAEItemStack input, final FuzzyMode fuzzy )
|
||||
{
|
||||
return this.overrides.findFuzzy( input, fuzzy );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.overrides.isEmpty() && this.backingStore.isEmpty();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.overrides.isEmpty() && this.backingStore.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@@ -26,61 +25,50 @@ import java.util.NoSuchElementException;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public class MeaningfulItemIterator<T extends IAEItemStack> implements Iterator<T> {
|
||||
|
||||
public class MeaningfulItemIterator<T extends IAEItemStack> implements Iterator<T>
|
||||
{
|
||||
private final Collection<T> collection;
|
||||
private final Iterator<T> parent;
|
||||
private T next;
|
||||
private final Collection<T> toRemove = new ArrayList<>();
|
||||
|
||||
private final Collection<T> collection;
|
||||
private final Iterator<T> parent;
|
||||
private T next;
|
||||
private final Collection<T> toRemove = new ArrayList<>();
|
||||
public MeaningfulItemIterator(final Collection<T> collection) {
|
||||
this.collection = collection;
|
||||
this.parent = collection.iterator();
|
||||
}
|
||||
|
||||
public MeaningfulItemIterator( final Collection<T> collection )
|
||||
{
|
||||
this.collection = collection;
|
||||
this.parent = collection.iterator();
|
||||
}
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
while (this.parent.hasNext()) {
|
||||
this.next = this.parent.next();
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
while( this.parent.hasNext() )
|
||||
{
|
||||
this.next = this.parent.next();
|
||||
if (this.next.isMeaningful()) {
|
||||
return true;
|
||||
} else {
|
||||
// TODO: Avoid if possible
|
||||
this.toRemove.add(this.next);
|
||||
// this.parent.remove(); // self cleaning :3
|
||||
}
|
||||
}
|
||||
|
||||
if( this.next.isMeaningful() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Avoid if possible
|
||||
this.toRemove.add( this.next );
|
||||
// this.parent.remove(); // self cleaning :3
|
||||
}
|
||||
}
|
||||
// Cleanup afterwards to avoid CMEs
|
||||
this.toRemove.forEach(entry -> this.collection.remove(entry));
|
||||
|
||||
// Cleanup afterwards to avoid CMEs
|
||||
this.toRemove.forEach( entry -> this.collection.remove( entry ) );
|
||||
this.next = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.next = null;
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public T next() {
|
||||
if (this.next == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
if( this.next == null )
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
return this.next;
|
||||
}
|
||||
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
this.parent.remove();
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
this.parent.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -27,69 +26,56 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
public class NullItemList implements IItemList<IAEItemStack> {
|
||||
|
||||
public class NullItemList implements IItemList<IAEItemStack>
|
||||
{
|
||||
@Override
|
||||
public void add(IAEItemStack option) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add( IAEItemStack option )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack findPrecise(IAEItemStack i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack findPrecise( IAEItemStack i )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy(IAEItemStack input, FuzzyMode fuzzy) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAEItemStack> findFuzzy( IAEItemStack input, FuzzyMode fuzzy )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void addStorage(IAEItemStack option) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorage( IAEItemStack option )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void addCrafting(IAEItemStack option) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCrafting( IAEItemStack option )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void addRequestable(IAEItemStack option) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRequestable( IAEItemStack option )
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public IAEItemStack getFirstItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getFirstItem()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator() {
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEItemStack> iterator()
|
||||
{
|
||||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetStatus()
|
||||
{
|
||||
}
|
||||
@Override
|
||||
public void resetStatus() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,22 +18,18 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
class StrictItemList extends AbstractItemList {
|
||||
|
||||
class StrictItemList extends AbstractItemList
|
||||
{
|
||||
private final Map<AESharedItemStack, IAEItemStack> records = new IdentityHashMap<>();
|
||||
|
||||
private final Map<AESharedItemStack, IAEItemStack> records = new IdentityHashMap<>();
|
||||
|
||||
@Override
|
||||
Map<AESharedItemStack, IAEItemStack> getRecords()
|
||||
{
|
||||
return this.records;
|
||||
}
|
||||
@Override
|
||||
Map<AESharedItemStack, IAEItemStack> getRecords() {
|
||||
return this.records;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user