private boolean isStorageCell( final T input ) { if( input instanceof IAEItemStack ) { final IAEItemStack stack = (IAEItemStack) input; final IStorageCell<?> type = getStorageCell( stack.getDefinition() ); return type != null && !type.storableInStorageCell(); } return false; }
@Override public boolean fuzzyComparison( final IAEItemStack other, final FuzzyMode mode ) { if( mode == FuzzyMode.IGNORE_ALL && OreHelper.INSTANCE.sameOre( this, other ) ) { return true; } final ItemStack itemStack = this.getDefinition(); final ItemStack otherStack = other.getDefinition(); return this.fuzzyItemStackComparison( itemStack, otherStack, mode ); }
@Override public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition ) { if( requestedAddition != null ) { final int[] id = OreDictionary.getOreIDs( requestedAddition.getDefinition() ); for( final int x : id ) { if( ORE_TO_COLOR.containsKey( x ) ) { return false; } } if( requestedAddition.getItem() instanceof ItemSnowball ) { return false; } return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 ); } return true; }
@Override public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src ) { ItemStack out = ItemStack.EMPTY; if( type == Actionable.SIMULATE ) { out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getDefinition(), null ); } else { out = this.adaptor.removeItems( (int) request.getStackSize(), request.getDefinition(), null ); } if( out.isEmpty() ) { return null; } // better then doing construction from scratch :3 final IAEItemStack o = request.copy(); o.setStackSize( out.getCount() ); if( type == Actionable.MODULATE ) { this.onTick(); } return o; }
private int calculateMaximumAmountToImport( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor<IAEItemStack> inv, final FuzzyMode fzMode ) { final int toSend = Math.min( this.itemsToSend, 64 ); final ItemStack itemStackToImport; if( whatToImport == null ) { itemStackToImport = ItemStack.EMPTY; } else { itemStackToImport = whatToImport.getDefinition(); } final IAEItemStack itemAmountNotStorable; final ItemStack simResult; if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) { simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this ); itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); } else { simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this ); itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source ); } if( itemAmountNotStorable != null ) { return (int) Math.min( simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend ); } return toSend; }
ais.setStackSize( ais.getDefinition().getMaxStackSize() ); while( true )
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), fzMode, this ); newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getDefinition(), this );
@Override public boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos ) { if( Platform.isClient() ) { return true; } if( !this.getProxy().isActive() ) { return false; } if( !Platform.hasPermissions( this.getLocation(), player ) ) { return false; } if( this.getDisplayed() != null ) { this.extractItem( player, this.getDisplayed().getDefinition().getMaxStackSize() ); } return true; }
@Nonnull public static HashMap<Object, Object> getBasicProperties(@Nonnull IAEItemStack stack) { HashMap<Object, Object> data = Maps.newHashMap(); data.putAll(MetaItemBasic.getBasicMeta(stack.getDefinition())); data.put("count", stack.getStackSize()); data.put("isCraftable", stack.isCraftable()); return data; } }
@Nullable @Override public ItemStack convert(@Nonnull IAEItemStack from) { return from.getStackSize() == 0 ? from.getDefinition() : from.createItemStack(); } }
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getDefinition(), null ); if( canExtract.isEmpty() || canExtract.getCount() != diff )
final ItemStack sh = x.getDefinition(); if( ( Platform.itemComparisons().isEqualItemType( providedTemplate, sh ) || ae_req.sameOre( x ) ) && !ItemStack.areItemsEqual( sh, output ) )
final ItemStack fail = ia.removeItems( 1, extracted.getDefinition(), null ); if( fail.isEmpty() ) if( !Platform.itemComparisons().isSameItem( slotItem.getDefinition(), item ) ) ais.setStackSize( ais.getDefinition().getMaxStackSize() ); ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() ); if( ais != null ) final long maxSize = ais.getDefinition().getMaxStackSize(); ais.setStackSize( maxSize ); ais = this.getCellInventory().extractItems( ais, Actionable.SIMULATE, this.getActionSource() );
public static String getDisplayName(Object o) { if (o instanceof ItemStack) return ((ItemStack) o).getDisplayName(); if (o instanceof IAEItemStack) return ((IAEItemStack) o).getDefinition().getDisplayName(); if (o instanceof IAEFluidStack) return ((IAEFluidStack) o).getFluidStack().getLocalizedName(); if (o instanceof IAEEssentiaStack) return ((IAEEssentiaStack) o).getAspect().getName(); return "NAMENOTFOUND"; }
public static String getModID(Object o) { ResourceLocation rl = null; if (o instanceof ItemStack) rl = ((ItemStack) o).getItem().getRegistryName(); else if (o instanceof IAEItemStack) rl = ((IAEItemStack) o).getDefinition().getItem().getRegistryName(); else if (o instanceof IAEFluidStack) return FluidRegistry.getModId(((IAEFluidStack) o).getFluidStack()); else if (o instanceof IAEEssentiaStack) return "Thaumcraft"; // Probably useless return rl != null ? rl.getResourceDomain() : "MODIDNOTFOUND"; }
private static IAEItemStack findStack(IGrid network, ItemFingerprint fingerprint) { IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); IStorageGrid grid = network.getCache(IStorageGrid.class); for (IAEItemStack aeStack : grid.getInventory(channel).getStorageList()) { if (fingerprint.matches(aeStack.getDefinition())) return aeStack; } return null; } }
@Override public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table) { if (this.returnStack != null && !this.returnStack.isEmpty()) { return false; } ItemStack filled = patternDetails.getCondensedOutputs()[0].getDefinition(); if (!patternFluids.containsKey(patternDetails)) return false; FluidStack fluid = patternFluids.get(patternDetails); IStorageGrid storage = getStorageGrid(); if (storage == null || fluid == null) { return false; } IAEFluidStack fluidStack = AEUtils.createFluidStack(new FluidStack(fluid.getFluid(), FluidHelper.getCapacity(patternDetails.getCondensedInputs()[0].getDefinition()))); IAEFluidStack extracted = storage.getInventory(StorageChannels.FLUID()) .extractItems(fluidStack.copy(), Actionable.SIMULATE, new MachineSource(this)); if (extracted == null || extracted.getStackSize() != fluidStack.getStackSize()) { return false; } storage.getInventory(StorageChannels.FLUID()).extractItems(fluidStack, Actionable.MODULATE, new MachineSource(this)); this.returnStack = filled; this.ticksToFinish = 40; return true; }
@BasicMethod.Inject( value = IGrid.class, modId = AppEng.MOD_ID, doc = "function(item:string|table):table -- Search all items in the network. " + "You can specify the item as a string, with or without the damage value ('minecraft:stone' or 'minecraft:stone@0') " + "or as a table with 'name', 'damage' and 'nbthash' fields. You must specify the 'name', but you can " + "leave the other fields empty." ) public static MethodResult findItems(final IUnbakedContext<IGrid> context, Object[] args) throws LuaException { final ItemFingerprint fingerprint = ItemFingerprint.fromLua(args, 0); return MethodResult.nextTick(() -> { IContext<IGrid> baked = context.bake(); IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); IStorageGrid grid = baked.getTarget().getCache(IStorageGrid.class); int i = 0; Map<Integer, Object> out = Maps.newHashMap(); for (IAEItemStack aeStack : grid.getInventory(channel).getStorageList()) { if (fingerprint.matches(aeStack.getDefinition())) { out.put(++i, baked.makeChildId(aeStack).getObject()); } } return MethodResult.result(out); }); }
toExtract.setStackSize(Math.min(limit, toExtract.getDefinition().getMaxStackSize())); toExtract = storageGrid.getInventory(channel).extractItems(toExtract, Actionable.MODULATE, source);
if (player.inventory.getItemStack().isEmpty() && packet.requestedStack != null) { // PICKUP IAEItemStack stack = (IAEItemStack) packet.requestedStack.copy(); stack.setStackSize(stack.getDefinition().getMaxStackSize()); stack = AEUtil.inventoryExtract(stack, this.monitor, this.part.source); if (player.inventory.getItemStack().isEmpty() && packet.requestedStack != null) { // Grab half IAEItemStack stack = (IAEItemStack) packet.requestedStack.copy(); stack.setStackSize(stack.getDefinition().getMaxStackSize()); // Cap it to max stack size stack = AEUtil.inventoryExtract(stack, this.monitor, this.part.source, Actionable.SIMULATE); // Double check how much we have available if (!held.isEmpty() && (held.getCount() >= held.getMaxStackSize() || !ForgeUtil.areItemStacksEqual(((IAEItemStack) packet.requestedStack).getDefinition(), held))) return; IAEItemStack stack = (IAEItemStack) packet.requestedStack.copy();