Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea54ccbcf5 | |||
| 7796c6d4b6 | |||
| e2e6f6e83f |
@@ -24,8 +24,10 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -208,7 +210,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
IAEItemStack mostDamaged = null;
|
||||
for( IAEItemStack is : outList )
|
||||
{
|
||||
if (!is.isCraftable())
|
||||
if( !is.isCraftable() )
|
||||
{
|
||||
if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() )
|
||||
{
|
||||
@@ -235,6 +237,22 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
// Fall back using an existing item
|
||||
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
|
||||
}
|
||||
|
||||
if( out == null )
|
||||
{
|
||||
IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
Iterator<IAEItemStack> iterator = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getAvailableItems( items ).iterator();
|
||||
while ( iterator.hasNext() )
|
||||
{
|
||||
final IAEItemStack o = iterator.next();
|
||||
if( o.getDefinition().isItemEqual( request.getDefinition() ) && o.isCraftable() )
|
||||
{
|
||||
out = o;
|
||||
break;
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( out != null )
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
@@ -195,10 +196,13 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
{
|
||||
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
|
||||
private final IFluidHandler fluidHandler;
|
||||
private ArrayList<Integer> skipSlots;
|
||||
|
||||
|
||||
public InventoryCache( IFluidHandler fluidHandler )
|
||||
{
|
||||
this.fluidHandler = fluidHandler;
|
||||
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
|
||||
}
|
||||
|
||||
public List<IAEFluidStack> update()
|
||||
@@ -211,13 +215,22 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
if( slots > this.cachedAeStacks.length )
|
||||
{
|
||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
||||
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
|
||||
}
|
||||
|
||||
for( int slot = 0; slot < slots; slot++ )
|
||||
{
|
||||
if (skipSlots.contains( slot ))
|
||||
continue;
|
||||
// Save the old stuff
|
||||
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
|
||||
final FluidStack newFS = tankProperties[slot].getContents();
|
||||
FluidStack newFS = tankProperties[slot].getContents();
|
||||
if (newFS != null) {
|
||||
if (this.fluidHandler.drain( 1, false ) == null){
|
||||
newFS = null;
|
||||
skipSlots.add( slot );
|
||||
}
|
||||
}
|
||||
|
||||
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -268,10 +270,12 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
{
|
||||
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
||||
private final IItemHandler itemHandler;
|
||||
private ArrayList<Integer> skipSlots;
|
||||
|
||||
public InventoryCache( IItemHandler itemHandler )
|
||||
{
|
||||
this.itemHandler = itemHandler;
|
||||
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||
@@ -289,14 +293,22 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
if( slots > this.cachedAeStacks.length )
|
||||
{
|
||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
||||
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
|
||||
}
|
||||
|
||||
for( int slot = 0; slot < slots; slot++ )
|
||||
{
|
||||
if (skipSlots.contains( slot ))
|
||||
continue;
|
||||
// Save the old stuff
|
||||
final IAEItemStack oldAeIS = this.cachedAeStacks[slot];
|
||||
final ItemStack newIS = this.itemHandler.getStackInSlot( slot );
|
||||
|
||||
ItemStack newIS = this.itemHandler.getStackInSlot( slot );
|
||||
if (!newIS.isEmpty()) {
|
||||
if (this.itemHandler.extractItem( slot,1,true ).isEmpty()){
|
||||
newIS = ItemStack.EMPTY;
|
||||
skipSlots.add( slot );
|
||||
}
|
||||
}
|
||||
this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes );
|
||||
}
|
||||
|
||||
@@ -317,6 +329,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
|
||||
// Reduce the cache size
|
||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
||||
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
|
||||
}
|
||||
|
||||
return changes;
|
||||
|
||||
Reference in New Issue
Block a user