Compare commits

..

4 Commits

Author SHA1 Message Date
Salomão fa07247bd7 Revert "also shrink the fluid skiplist if the tanks change sizes"
This reverts commit 892c919ee2.
2021-03-04 23:08:08 -03:00
Salomão 95d25ddf47 Revert "Skip un-extractable slots."
This reverts commit e2e6f6e83f.
2021-03-04 23:07:58 -03:00
Salomão 7a45e1faf4 Revert "rebuild skipslotlist if the the inventory grows or shrinks"
This reverts commit 7796c6d4b6.
2021-03-04 23:07:34 -03:00
Salomão 1f88494832 fix not being able to swap patterns on interface terminal 2021-03-03 09:57:02 -03:00
3 changed files with 4 additions and 31 deletions
@@ -478,7 +478,7 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
case PICKUP: // pickup / set-down. case PICKUP: // pickup / set-down.
if (slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty()) if (slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty())
action = InventoryAction.SPLIT_OR_PLACE_SINGLE; action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
if (!slot.getStack().isEmpty() && player.inventory.getItemStack().isEmpty()) if (!slot.getStack().isEmpty() && player.inventory.getItemStack().getCount() <= 1)
action = InventoryAction.PICKUP_OR_SET_DOWN; action = InventoryAction.PICKUP_OR_SET_DOWN;
break; break;
case QUICK_MOVE: case QUICK_MOVE:
@@ -26,7 +26,6 @@ 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;
@@ -196,13 +195,10 @@ 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()
@@ -215,22 +211,13 @@ 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];
FluidStack newFS = tankProperties[slot].getContents(); final 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 );
} }
@@ -251,7 +238,6 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
} }
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>( this.fluidHandler.getTankProperties().length );
} }
return changes; return changes;
} }
@@ -26,9 +26,7 @@ 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;
@@ -270,12 +268,10 @@ 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 )
@@ -293,22 +289,14 @@ 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];
ItemStack newIS = this.itemHandler.getStackInSlot( slot ); final 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 );
} }
@@ -329,7 +317,6 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
// Reduce the cache size // Reduce the cache size
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
} }
return changes; return changes;