partial implementation of oredict storage bus
missing proper GUI, text, item models, memorycard support. logic works
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.implementations.ContainerPartOreDictStorageBus;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.misc.PartOreDicStorageBus;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class GuiPartOreDictStorageBus extends AEBaseGui
|
||||
{
|
||||
PartOreDicStorageBus part;
|
||||
|
||||
private static final Pattern ORE_DICTIONARY_FILTER = Pattern.compile( "\\*?[a-zA-Z0-9_]*\\*?" );
|
||||
private MEGuiTextField searchFieldInputs;
|
||||
|
||||
public GuiPartOreDictStorageBus( final InventoryPlayer inventoryPlayer, final PartOreDicStorageBus te )
|
||||
{
|
||||
super( new ContainerPartOreDictStorageBus( inventoryPlayer, te ) );
|
||||
part = te;
|
||||
this.ySize = 84;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + 3, this.guiTop + 18, 170, 36 );
|
||||
this.searchFieldInputs.setEnableBackgroundDrawing( false );
|
||||
this.searchFieldInputs.setMaxStringLength( 512 );
|
||||
this.searchFieldInputs.setTextColor( 0xFFFFFF );
|
||||
this.searchFieldInputs.setVisible( true );
|
||||
this.searchFieldInputs.setFocused( false );
|
||||
this.searchFieldInputs.setValidator( str -> ORE_DICTIONARY_FILTER.matcher( str ).matches() );
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "OreDictStorageBus.getRegex", "1" ) );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fillRegex( String regex )
|
||||
{
|
||||
this.searchFieldInputs.setText( regex );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
|
||||
{
|
||||
boolean wasFocused = this.searchFieldInputs.isFocused();
|
||||
this.searchFieldInputs.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if( btn == 1 && this.searchFieldInputs.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
this.searchFieldInputs.setText( "" );
|
||||
}
|
||||
|
||||
if( !searchFieldInputs.isFocused() && wasFocused )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "OreDictStorageBus.save", searchFieldInputs.getText() ) );
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( !this.searchFieldInputs.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.bindTexture( "guis/oredictstoragebus.png" );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 175, 85 );
|
||||
|
||||
if( this.searchFieldInputs != null )
|
||||
{
|
||||
this.searchFieldInputs.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.misc.PartOreDicStorageBus;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class ContainerPartOreDictStorageBus extends AEBaseContainer
|
||||
{
|
||||
private final PartOreDicStorageBus part;
|
||||
|
||||
public ContainerPartOreDictStorageBus( final InventoryPlayer ip, final PartOreDicStorageBus anchor )
|
||||
{
|
||||
super( ip, anchor );
|
||||
this.part = anchor;
|
||||
|
||||
this.bindPlayerInventory( ip, 14, 256 - /* height of player inventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
}
|
||||
|
||||
public void saveOreMatch( String value )
|
||||
{
|
||||
part.saveOreMatch( value );
|
||||
part.upgradesChanged();
|
||||
}
|
||||
|
||||
public void sendRegex()
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( "OreDictStorageBus.sendRegex", part.getOreMatch() ), (EntityPlayerMP) getInventoryPlayer().player );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public final class ApiParts implements IParts
|
||||
private final IItemDefinition toggleBus;
|
||||
private final IItemDefinition invertedToggleBus;
|
||||
private final IItemDefinition storageBus;
|
||||
private final IItemDefinition oreDictStorageBus;
|
||||
private final IItemDefinition importBus;
|
||||
private final IItemDefinition exportBus;
|
||||
private final IItemDefinition iface;
|
||||
@@ -113,6 +114,7 @@ public final class ApiParts implements IParts
|
||||
this.toggleBus = new DamagedItemDefinition( "part.toggle_bus", itemPart.createPart( PartType.TOGGLE_BUS ) );
|
||||
this.invertedToggleBus = new DamagedItemDefinition( "part.toggle_bus.inverted", itemPart.createPart( PartType.INVERTED_TOGGLE_BUS ) );
|
||||
this.storageBus = new DamagedItemDefinition( "part.bus.storage", itemPart.createPart( PartType.STORAGE_BUS ) );
|
||||
this.oreDictStorageBus = new DamagedItemDefinition( "part.bus.ore_dict_storage", itemPart.createPart( PartType.ORE_DICT_STORAGE_BUS ) );
|
||||
this.importBus = new DamagedItemDefinition( "part.bus.import", itemPart.createPart( PartType.IMPORT_BUS ) );
|
||||
this.exportBus = new DamagedItemDefinition( "part.bus.export", itemPart.createPart( PartType.EXPORT_BUS ) );
|
||||
this.iface = new DamagedItemDefinition( "part.interface", itemPart.createPart( PartType.INTERFACE ) );
|
||||
@@ -247,6 +249,12 @@ public final class ApiParts implements IParts
|
||||
return this.storageBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition oreDictStorageBus()
|
||||
{
|
||||
return this.oreDictStorageBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition importBus()
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.core.sync;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import appeng.container.implementations.*;
|
||||
import appeng.parts.misc.PartOreDicStorageBus;
|
||||
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -140,6 +141,8 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
GUI_STORAGEBUS( ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_OREDICTSTORAGEBUS( ContainerPartOreDictStorageBus.class, PartOreDicStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_STORAGEBUS_FLUID( ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import appeng.client.gui.implementations.GuiPartOreDictStorageBus;
|
||||
import appeng.container.implementations.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -289,6 +290,20 @@ public class PacketValueConfig extends AppEngPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "OreDictStorageBus" ) )
|
||||
{
|
||||
if( c instanceof ContainerPartOreDictStorageBus )
|
||||
{
|
||||
if( this.Name.equals( "OreDictStorageBus.save" ) )
|
||||
{
|
||||
( (ContainerPartOreDictStorageBus) c ).saveOreMatch( this.Value );
|
||||
}
|
||||
if( this.Name.equals( "OreDictStorageBus.getRegex" ) )
|
||||
{
|
||||
( (ContainerPartOreDictStorageBus) c ).sendRegex();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
|
||||
{
|
||||
final ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
@@ -365,6 +380,14 @@ public class PacketValueConfig extends AppEngPacket
|
||||
( (GuiCraftingCPU) gs ).clearItems();
|
||||
}
|
||||
}
|
||||
else if( this.Name.equals( "OreDictStorageBus.sendRegex" ) )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if( gs instanceof GuiPartOreDictStorageBus )
|
||||
{
|
||||
( (GuiPartOreDictStorageBus) gs ).fillRegex( this.Value );
|
||||
}
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
final IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import appeng.parts.misc.*;
|
||||
import appeng.parts.reporting.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -58,11 +59,6 @@ import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartIdentityAnnihilationPlane;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.parts.misc.PartCableAnchor;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartInvertedToggleBus;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.parts.misc.PartToggleBus;
|
||||
import appeng.parts.networking.PartCableCovered;
|
||||
import appeng.parts.networking.PartCableGlass;
|
||||
import appeng.parts.networking.PartCableSmart;
|
||||
@@ -185,14 +181,13 @@ public enum PartType
|
||||
|
||||
MONITOR( 160, "monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartPanel.class, "itemIlluminatedPanel" ),
|
||||
|
||||
SEMI_DARK_MONITOR( 180, "semi_dark_monitor", EnumSet.of( AEFeature.PANELS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartSemiDarkPanel.class, "itemIlluminatedPanel" ),
|
||||
SEMI_DARK_MONITOR( 180, "semi_dark_monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartSemiDarkPanel.class, "itemIlluminatedPanel" ),
|
||||
|
||||
DARK_MONITOR( 200, "dark_monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class, "itemIlluminatedPanel" ),
|
||||
|
||||
STORAGE_BUS( 220, "storage_bus", EnumSet.of( AEFeature.STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),
|
||||
FLUID_STORAGE_BUS( 221, "fluid_storage_bus", EnumSet.of( AEFeature.FLUID_STORAGE_BUS ), EnumSet
|
||||
.noneOf( IntegrationType.class ), PartFluidStorageBus.class ),
|
||||
FLUID_STORAGE_BUS( 221, "fluid_storage_bus", EnumSet.of( AEFeature.FLUID_STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidStorageBus.class ),
|
||||
ORE_DICT_STORAGE_BUS( 222, "ore_dict_storage_bus", EnumSet.of( AEFeature.STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartOreDicStorageBus.class ),
|
||||
|
||||
IMPORT_BUS( 240, "import_bus", EnumSet.of( AEFeature.IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartImportBus.class ),
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package appeng.parts.misc;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.me.storage.ITickingMonitor;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.OreHelper;
|
||||
import appeng.util.prioritylist.OreDictPriorityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
|
||||
public class PartOreDicStorageBus extends PartStorageBus
|
||||
{
|
||||
public String oreMatch = "";
|
||||
|
||||
public PartOreDicStorageBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_OREDICTSTORAGEBUS );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_OREDICTSTORAGEBUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MEInventoryHandler<IAEItemStack> getInternalHandler()
|
||||
{
|
||||
if( this.cached )
|
||||
{
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
final boolean wasSleeping = this.monitor == null;
|
||||
|
||||
this.cached = true;
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) );
|
||||
final int newHandlerHash = this.createHandlerHash( target );
|
||||
|
||||
if( newHandlerHash != 0 && newHandlerHash == this.handlerHash )
|
||||
{
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
if( this.monitor != null )
|
||||
{
|
||||
( (IBaseMonitor<IAEItemStack>) monitor ).removeListener( this );
|
||||
}
|
||||
this.monitor = null;
|
||||
if( target != null )
|
||||
{
|
||||
IMEInventory<IAEItemStack> inv = this.getInventoryWrapper( target );
|
||||
|
||||
if( inv instanceof ITickingMonitor )
|
||||
{
|
||||
this.monitor = (ITickingMonitor) inv;
|
||||
this.monitor.setActionSource( mySrc );
|
||||
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||
}
|
||||
|
||||
if( inv != null )
|
||||
{
|
||||
this.handler = new MEInventoryHandler<>( inv, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) );
|
||||
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.handler.setPriority( this.priority );
|
||||
|
||||
this.handler.setPartitionList( new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreMatch ), oreMatch ) );
|
||||
|
||||
if( inv instanceof IBaseMonitor )
|
||||
{
|
||||
if( ( (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS ) ).hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
( (IBaseMonitor<IAEItemStack>) inv ).addListener( this, this.handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update sleep state...
|
||||
if( wasSleeping != ( this.monitor == null ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
final ITickManager tm = this.getProxy().getTick();
|
||||
if( this.monitor == null )
|
||||
{
|
||||
tm.sleepDevice( this.getProxy().getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// force grid to update handlers...
|
||||
( (GridStorageCache) this.getProxy().getGrid().getCache( IStorageGrid.class ) ).cellUpdate( null );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :3
|
||||
}
|
||||
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
public String getOreMatch()
|
||||
{
|
||||
if( this.oreMatch == null )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return oreMatch;
|
||||
}
|
||||
|
||||
public void saveOreMatch( String oreMatch )
|
||||
{
|
||||
this.oreMatch = oreMatch;
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.oreMatch = data.getString( "oreMatch" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setString( "oreMatch", oreMatch );
|
||||
}
|
||||
}
|
||||
@@ -96,13 +96,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" ) );
|
||||
@CapabilityInject( IItemRepository.class )
|
||||
public static Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY = null;
|
||||
private final IActionSource mySrc;
|
||||
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
private int priority = 0;
|
||||
private boolean cached = false;
|
||||
private ITickingMonitor monitor = null;
|
||||
private MEInventoryHandler<IAEItemStack> handler = null;
|
||||
private int handlerHash = 0;
|
||||
protected final IActionSource mySrc;
|
||||
protected final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
|
||||
protected int priority = 0;
|
||||
protected boolean cached = false;
|
||||
protected ITickingMonitor monitor = null;
|
||||
protected MEInventoryHandler<IAEItemStack> handler = null;
|
||||
protected int handlerHash = 0;
|
||||
private boolean wasActive = false;
|
||||
private byte resetCacheLogic = 0;
|
||||
private boolean accessChanged;
|
||||
@@ -409,7 +409,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
}
|
||||
}
|
||||
|
||||
private IMEInventory<IAEItemStack> getInventoryWrapper( TileEntity target )
|
||||
IMEInventory<IAEItemStack> getInventoryWrapper( TileEntity target )
|
||||
{
|
||||
|
||||
EnumFacing targetSide = this.getSide().getFacing().getOpposite();
|
||||
@@ -452,7 +452,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
|
||||
}
|
||||
|
||||
private int createHandlerHash( TileEntity target )
|
||||
int createHandlerHash( TileEntity target )
|
||||
{
|
||||
if( target == null )
|
||||
{
|
||||
|
||||
@@ -19,13 +19,8 @@
|
||||
package appeng.util.item;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
@@ -116,7 +111,7 @@ public class OreHelper
|
||||
boolean sameOre( final AEItemStack aeItemStack, final IAEItemStack is )
|
||||
{
|
||||
final OreReference a = aeItemStack.getOre().orElse( null );
|
||||
final OreReference b = aeItemStack.getOre().orElse( null );
|
||||
final OreReference b = ( (AEItemStack) is ).getOre().orElse( null );
|
||||
|
||||
return this.sameOre( a, b );
|
||||
}
|
||||
@@ -160,8 +155,53 @@ public class OreHelper
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} )
|
||||
.orElse( false );
|
||||
} ).orElse( false );
|
||||
}
|
||||
|
||||
public Set<Integer> getMatchingOre( String allow )
|
||||
{
|
||||
List<String> matchingOres = new ArrayList<>();
|
||||
ConcurrentMap<String, List<ItemStack>> oreKeys = oreDictCache.asMap();
|
||||
|
||||
oreKeys.forEach( ( s, l ) -> {
|
||||
|
||||
if( allow.startsWith( "*" ) && allow.endsWith( "*" ) )
|
||||
{
|
||||
if( s.contains( allow.substring( 1, allow.length() - 1 ) ) )
|
||||
{
|
||||
matchingOres.add( s );
|
||||
}
|
||||
}
|
||||
else if( allow.startsWith( "*" ) )
|
||||
{
|
||||
if( s.endsWith( allow.substring( 1 ) ) )
|
||||
{
|
||||
matchingOres.add( s );
|
||||
}
|
||||
}
|
||||
else if( allow.endsWith( "*" ) )
|
||||
{
|
||||
if( s.startsWith( allow.substring( 0, allow.length() - 1 ) ) )
|
||||
{
|
||||
matchingOres.add( s );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( s.matches( allow ) )
|
||||
{
|
||||
matchingOres.add( s );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
Set<Integer> oreIDs = new HashSet<>();
|
||||
for( String matchingOre : matchingOres )
|
||||
{
|
||||
oreIDs.add( OreDictionary.getOreID( matchingOre ) );
|
||||
}
|
||||
|
||||
return oreIDs;
|
||||
}
|
||||
|
||||
List<ItemStack> getCachedOres( final String oreName )
|
||||
|
||||
@@ -65,8 +65,8 @@ public class OreReference
|
||||
return this.aeOtherOptions;
|
||||
}
|
||||
|
||||
Collection<Integer> getOres()
|
||||
{
|
||||
return this.ores;
|
||||
}
|
||||
public Collection<Integer> getOres()
|
||||
{
|
||||
return this.ores;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package appeng.util.prioritylist;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.OreReference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class OreDictPriorityList<T extends IAEStack<T>> implements IPartitionList<T>
|
||||
{
|
||||
private final Set<Integer> oreIDs;
|
||||
private final String oreMatch;
|
||||
|
||||
public OreDictPriorityList( Set<Integer> oreIDs, String oreMatch )
|
||||
{
|
||||
this.oreIDs = oreIDs;
|
||||
this.oreMatch = oreMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListed( final T input )
|
||||
{
|
||||
OreReference or = ( (AEItemStack) input ).getOre().orElse( null );
|
||||
if( or != null )
|
||||
{
|
||||
for( Integer oreID : or.getOres() )
|
||||
{
|
||||
if( this.oreIDs.contains( oreID ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return oreMatch.equals( "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> getItems()
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user