Compare commits

..

1 Commits

Author SHA1 Message Date
Salomão bc2e4c84b9 highlight interfaces from interface terminal. 2021-02-28 15:36:45 -03:00
12 changed files with 53 additions and 141 deletions
-1
View File
@@ -86,7 +86,6 @@ configurations {
dependencies { dependencies {
deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12.2-5.4.2:api" deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12.2-5.4.2:api"
deobfCompile "gregtechce:gregtech:1.12.2:1.12.0.662"
// installable runtime dependencies // installable runtime dependencies
mods "mcp.mobius.waila:Hwyla:${hwyla_version}" mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
@@ -476,10 +476,7 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
switch( clickType ) switch( clickType )
{ {
case PICKUP: // pickup / set-down. case PICKUP: // pickup / set-down.
if (slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty()) action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
if (!slot.getStack().isEmpty() && player.inventory.getItemStack().getCount() <= 1)
action = InventoryAction.PICKUP_OR_SET_DOWN;
break; break;
case QUICK_MOVE: case QUICK_MOVE:
action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
@@ -22,11 +22,15 @@ package appeng.client.gui.implementations;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import akka.event.Logging;
import appeng.client.render.BlockPosHighlighter;
import appeng.util.BlockPosUtils; import appeng.util.BlockPosUtils;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -46,8 +50,10 @@ import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import org.lwjgl.util.Color;
import org.lwjgl.util.ReadableColor;
import static appeng.client.render.BlockPosHighlighter.hilightBlock; import static appeng.client.render.BlockPosHighlighter.hilightBlock;
@@ -72,15 +78,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false; private boolean refreshList = false;
private MEGuiTextField searchFieldOutputs; private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs; private MEGuiTextField searchFieldInputs;
private PartInterfaceTerminal partInterfaceTerminal;
private GuiButton guiButtonHide;
private GuiButton guiButtonNextAssembler;
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te ) public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
{ {
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) ); super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar(); final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar ); this.setScrollBar( scrollbar );
this.xSize = 195; this.xSize = 195;
@@ -103,7 +106,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.searchFieldInputs.setVisible( true ); this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false ); this.searchFieldInputs.setFocused( false );
// this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 105, this.offsetX ), this.guiTop + 4, 65, 12 ); // this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 94, this.offsetX ), this.guiTop + 18, 65, 12 ); this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 94, this.offsetX ), this.guiTop + 18, 65, 12 );
this.searchFieldOutputs.setEnableBackgroundDrawing( false ); this.searchFieldOutputs.setEnableBackgroundDrawing( false );
this.searchFieldOutputs.setMaxStringLength( 25 ); this.searchFieldOutputs.setMaxStringLength( 25 );
@@ -111,15 +114,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.searchFieldOutputs.setVisible( true ); this.searchFieldOutputs.setVisible( true );
this.searchFieldOutputs.setFocused( true ); this.searchFieldOutputs.setFocused( true );
this.searchFieldInputs.setText( partInterfaceTerminal.in );
this.searchFieldOutputs.setText( partInterfaceTerminal.out );
}
@Override
public void onGuiClosed()
{
partInterfaceTerminal.saveSearchStrings( this.searchFieldInputs.getText().toLowerCase(), this.searchFieldOutputs.getText().toLowerCase() );
super.onGuiClosed();
} }
@Override @Override
@@ -132,12 +126,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
final int ex = this.getScrollBar().getCurrentScroll(); final int ex = this.getScrollBar().getCurrentScroll();
this.guiButtonNextAssembler = new GuiButton( -1, guiLeft + 110, guiTop + 4, 12, 12, "M" );
this.buttonList.add( guiButtonNextAssembler );
this.guiButtonHide = new GuiButton( -1, guiLeft + 128, guiTop + 4, 60, 12, "Hide Full" );
this.buttonList.add( guiButtonHide );
final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator(); final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
while( o.hasNext() ) while( o.hasNext() )
{ {
@@ -216,27 +204,6 @@ public class GuiInterfaceTerminal extends AEBaseGui
mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + "Y: " + blockPos.getY() + "Z: " + blockPos.getZ() ), false ); mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + "Y: " + blockPos.getY() + "Z: " + blockPos.getZ() ), false );
mc.player.closeScreen(); mc.player.closeScreen();
} }
if (btn == guiButtonHide)
{
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
this.refreshList();
}
if (btn == guiButtonNextAssembler)
{
// Set Search to "Molecular Assembler" and set "Only Free Interface"
boolean currentOnlyInterfacesWithFreeSlots = this.partInterfaceTerminal.onlyInterfacesWithFreeSlots;
String currentSearchText = this.searchFieldOutputs.getText();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = true;
this.searchFieldOutputs.setText("Molecular Assembler");
this.refreshList();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = currentOnlyInterfacesWithFreeSlots;
this.searchFieldOutputs.setText(currentSearchText);
}
} }
@Override @Override
@@ -357,20 +324,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase(); final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + partInterfaceTerminal.onlyInterfacesWithFreeSlots); final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs );
final boolean rebuild = cachedSearch.isEmpty(); final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() ) for( final ClientDCInternalInv entry : this.byId.values() )
{ {
// ignore inventory if not doing a full rebuild and cache already marks it as miss. // ignore inventory if not doing a full rebuild or cache already marks it as miss.
if( !rebuild && !cachedSearch.contains( entry ) ) if( !rebuild && !cachedSearch.contains( entry ) )
{ {
continue; continue;
} }
// Shortcut to skip any filter if search term is ""/empty // Shortcut to skip any filter if search term is ""/empty
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty());
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty() && !partInterfaceTerminal.onlyInterfacesWithFreeSlots);
// Search if the current inventory holds a pattern containing the search term. // Search if the current inventory holds a pattern containing the search term.
if( !found ) if( !found )
@@ -388,32 +354,13 @@ public class GuiInterfaceTerminal extends AEBaseGui
break; break;
} }
} }
}
// If only Interfaces with empty slots should be shown, check that here
boolean interfaceHasFreeSlots = false;
if (partInterfaceTerminal.onlyInterfacesWithFreeSlots) {
for( final ItemStack itemStack : entry.getInventory() )
{
if(itemStack.isEmpty()){
interfaceHasFreeSlots = true;
break;
}
}
} }
// if found, filter skipped or machine name matching the search term, add it // if found, filter skipped or machine name matching the search term, add it
if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs ))) if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs )))
{ {
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) this.byName.put( entry.getName(), entry );
{ cachedSearch.add( entry );
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
else if ( interfaceHasFreeSlots ){
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
} }
else else
{ {
@@ -419,7 +419,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
this.client = new AppEngInternalInventory( null, this.server.getSlots() ); this.client = new AppEngInternalInventory( null, this.server.getSlots() );
this.unlocalizedName = unlocalizedName; this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue(); this.sortBy = dual.getSortValue();
this.pos = dual.getLocation().getPos(); this.pos = dual.getTile().getPos();
} }
} }
@@ -291,7 +291,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && input[x].getCount() * multiple > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() * multiple > 64 )
{ {
canMultiplyInputs = false; canMultiplyInputs = false;
} }
@@ -299,7 +299,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots ) for( final OptionalSlotFake outputSlot : this.outputSlots )
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() * multiple > 64 )
{ {
canMultiplyOutputs = false; canMultiplyOutputs = false;
} }
@@ -369,7 +369,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && input[x].getCount() + increase > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() + increase > 64 )
{ {
canIncreaseInputs = false; canIncreaseInputs = false;
} }
@@ -377,7 +377,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots ) for( final OptionalSlotFake outputSlot : this.outputSlots )
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() + increase > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() + increase > 64 )
{ {
canIncreaseOutputs = false; canIncreaseOutputs = false;
} }
@@ -450,11 +450,11 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth ) if( !input[x].isEmpty() && 64 - input[x].getCount() > maxInputStackGrowth )
{ {
maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount(); maxInputStackGrowth = 64 - input[x].getCount();
} }
if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > 64 )
{ {
canGrowInputs = false; canGrowInputs = false;
} }
@@ -463,9 +463,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
{ {
maxOutputStackGrowth = out.getMaxStackSize() - out.getCount(); maxOutputStackGrowth = 64 - out.getCount();
} }
if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > 64 )
{ {
canGrowOutputs = false; canGrowOutputs = false;
} }
@@ -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 appeng.api.config.Settings; import net.minecraft.item.ItemStack;
import appeng.api.config.StorageFilter;
import appeng.parts.misc.PartStorageBus;
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;
@@ -64,18 +62,12 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
private final IFluidHandler fluidHandler; private final IFluidHandler fluidHandler;
private final IGridProxyable proxyable; private final IGridProxyable proxyable;
private final FluidHandlerAdapter.InventoryCache cache; private final FluidHandlerAdapter.InventoryCache cache;
private StorageFilter mode;
FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy ) FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy )
{ {
this.fluidHandler = fluidHandler; this.fluidHandler = fluidHandler;
this.proxyable = proxy; this.proxyable = proxy;
if( this.proxyable instanceof PartStorageBus ) this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler );
{
PartStorageBus partStorageBus = (PartStorageBus) this.proxyable;
this.mode = ( (StorageFilter) partStorageBus.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler, this.mode);
} }
@Override @Override
@@ -204,12 +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 final StorageFilter mode; private ArrayList<Integer> skipSlots;
public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
public InventoryCache( IFluidHandler fluidHandler )
{ {
this.mode = mode;
this.fluidHandler = fluidHandler; this.fluidHandler = fluidHandler;
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
} }
public List<IAEFluidStack> update() public List<IAEFluidStack> update()
@@ -222,20 +215,23 @@ 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(); FluidStack newFS = tankProperties[slot].getContents();
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null ) if (newFS != null) {
{ if (this.fluidHandler.drain( 1, false ) == null){
if( this.fluidHandler.drain( 1, false ) == null )
{
newFS = null; newFS = null;
skipSlots.add( slot );
} }
} }
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes ); this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
} }
@@ -255,6 +251,7 @@ 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;
} }
@@ -33,8 +33,6 @@ import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
import appeng.util.*; import appeng.util.*;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntity;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@@ -50,7 +48,6 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper; import net.minecraftforge.items.wrapper.RangedWrapper;
@@ -112,8 +109,6 @@ import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
{ {
@@ -1240,13 +1235,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final IBlockState directedBlockState = hostWorld.getBlockState( targ ); final IBlockState directedBlockState = hostWorld.getBlockState( targ );
final Block directedBlock = directedBlockState.getBlock(); final Block directedBlock = directedBlockState.getBlock();
ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getMetaFromState( directedBlockState ) ); ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getMetaFromState( directedBlockState ) );
if ( Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine )
{
MetaTileEntity metaTileEntity = getMetaTileEntity(hostWorld, targ);
return metaTileEntity.getMetaFullName();
}
try try
{ {
Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 ); Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 );
@@ -19,7 +19,6 @@
package appeng.me.storage; package appeng.me.storage;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickRateModulation;
@@ -31,8 +30,4 @@ public interface ITickingMonitor
void setActionSource( IActionSource actionSource ); void setActionSource( IActionSource actionSource );
default void setMode( StorageFilter setting )
{
}
} }
@@ -26,9 +26,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import appeng.api.config.Settings; import it.unimi.dsi.fastutil.ints.IntList;
import appeng.api.config.StorageFilter;
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;
@@ -59,18 +59,12 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private final IItemHandler itemHandler; private final IItemHandler itemHandler;
private final IGridProxyable proxyable; private final IGridProxyable proxyable;
private final InventoryCache cache; private final InventoryCache cache;
private StorageFilter mode;
ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy ) ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy )
{ {
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
this.proxyable = proxy; this.proxyable = proxy;
if( this.proxyable instanceof PartStorageBus ) this.cache = new InventoryCache( this.itemHandler );
{
PartStorageBus partStorageBus = (PartStorageBus) this.proxyable;
this.mode = ( (StorageFilter) partStorageBus.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
this.cache = new InventoryCache( this.itemHandler, this.mode );
} }
@Override @Override
@@ -276,12 +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 final StorageFilter mode; private ArrayList<Integer> skipSlots;
public InventoryCache( IItemHandler itemHandler, StorageFilter mode ) public InventoryCache( IItemHandler itemHandler )
{ {
this.mode = mode;
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 )
@@ -299,18 +293,20 @@ 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 ); ItemStack newIS = this.itemHandler.getStackInSlot( slot );
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !newIS.isEmpty() ) if (!newIS.isEmpty()) {
{ if (this.itemHandler.extractItem( slot,1,true ).isEmpty()){
if( this.itemHandler.extractItem( slot, 1, true ).isEmpty() )
{
newIS = ItemStack.EMPTY; newIS = ItemStack.EMPTY;
skipSlots.add( slot );
} }
} }
this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes ); this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes );
@@ -333,6 +329,7 @@ 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;
@@ -484,7 +484,6 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
this.monitor = (ITickingMonitor) inv; this.monitor = (ITickingMonitor) inv;
this.monitor.setActionSource( new MachineSource( this ) ); this.monitor.setActionSource( new MachineSource( this ) );
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
} }
if( inv != null ) if( inv != null )
@@ -44,9 +44,6 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public String in = "";
public String out = "";
public boolean onlyInterfacesWithFreeSlots = false;
public PartInterfaceTerminal( final ItemStack is ) public PartInterfaceTerminal( final ItemStack is )
{ {
@@ -72,8 +69,4 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
} }
public void saveSearchStrings(String in, String out){
this.in = in;
this.out = out;
}
} }
@@ -197,7 +197,7 @@ public class AdaptorItemRepository extends InventoryAdaptor
@Override @Override
public boolean hasSlots() public boolean hasSlots()
{ {
return true; return false;
} }
@Override @Override