Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2e6f6e83f |
@@ -26,6 +26,7 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
@@ -195,10 +196,13 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
{
|
{
|
||||||
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
|
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
|
||||||
private final IFluidHandler fluidHandler;
|
private final IFluidHandler fluidHandler;
|
||||||
|
private ArrayList<Integer> skipSlots;
|
||||||
|
|
||||||
|
|
||||||
public InventoryCache( IFluidHandler fluidHandler )
|
public InventoryCache( IFluidHandler fluidHandler )
|
||||||
{
|
{
|
||||||
this.fluidHandler = fluidHandler;
|
this.fluidHandler = fluidHandler;
|
||||||
|
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IAEFluidStack> update()
|
public List<IAEFluidStack> update()
|
||||||
@@ -211,13 +215,22 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
if( slots > this.cachedAeStacks.length )
|
if( slots > this.cachedAeStacks.length )
|
||||||
{
|
{
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
||||||
|
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int slot = 0; slot < slots; slot++ )
|
for( int slot = 0; slot < slots; slot++ )
|
||||||
{
|
{
|
||||||
|
if (skipSlots.contains( slot ))
|
||||||
|
continue;
|
||||||
// Save the old stuff
|
// Save the old stuff
|
||||||
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
|
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 );
|
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
@@ -268,10 +270,12 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
{
|
{
|
||||||
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
|
private ArrayList<Integer> skipSlots;
|
||||||
|
|
||||||
public InventoryCache( IItemHandler itemHandler )
|
public InventoryCache( IItemHandler itemHandler )
|
||||||
{
|
{
|
||||||
this.itemHandler = itemHandler;
|
this.itemHandler = itemHandler;
|
||||||
|
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||||
@@ -289,14 +293,22 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
if( slots > this.cachedAeStacks.length )
|
if( slots > this.cachedAeStacks.length )
|
||||||
{
|
{
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
||||||
|
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int slot = 0; slot < slots; slot++ )
|
for( int slot = 0; slot < slots; slot++ )
|
||||||
{
|
{
|
||||||
|
if (skipSlots.contains( slot ))
|
||||||
|
continue;
|
||||||
// Save the old stuff
|
// Save the old stuff
|
||||||
final IAEItemStack oldAeIS = this.cachedAeStacks[slot];
|
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 );
|
this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user