Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa07247bd7 | |||
| 95d25ddf47 | |||
| 7a45e1faf4 | |||
| 1f88494832 |
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user