Skip to content

Commit

Permalink
Merge pull request #45 from repo-alt/feature/OredictFilter
Browse files Browse the repository at this point in the history
Oredictionary filter card
  • Loading branch information
Dream-Master authored Apr 14, 2021
2 parents a6a0b36 + a7e81c1 commit 7aa4a95
Show file tree
Hide file tree
Showing 31 changed files with 528 additions and 95 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ buildscript {
}
}

sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = aeversion + "-" + aechannel + "-" + aebuild
group = aegroup
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aeversion=rv3
aechannel=beta
aebuild=44-GTNH
aebuild=45-GTNH
#KEEP V6 FOR MOD SUPPORT
aegroup=appeng
aebasename=appliedenergistics2
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/appeng/api/config/ActionItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

public enum ActionItems
{
WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION, SLOT_CONFIG
WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION, SLOT_CONFIG, ORE_FILTER
}
2 changes: 1 addition & 1 deletion src/api/java/appeng/api/config/Upgrades.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum Upgrades
/**
* Diamond Tier Upgrades.
*/
FUZZY( 1 ), SPEED( 1 ), INVERTER( 1 ), PATTERN_CAPACITY(1);
FUZZY( 1 ), SPEED( 1 ), INVERTER( 1 ), PATTERN_CAPACITY(1), ORE_FILTER(1);

/**
* @deprecated use {@link Upgrades#getTier()}
Expand Down
2 changes: 2 additions & 0 deletions src/api/java/appeng/api/definitions/IMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,6 @@ public interface IMaterials
IItemDefinition blankPattern();

IItemDefinition cardPatternCapacity();

IItemDefinition cardOreFilter();
}
81 changes: 81 additions & 0 deletions src/main/java/appeng/client/gui/implementations/GuiOreFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package appeng.client.gui.implementations;

import appeng.client.gui.AEBaseGui;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerOreFilter;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IOreFilterable;
import appeng.parts.automation.PartSharedItemBus;
import appeng.parts.misc.PartStorageBus;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;

import java.io.IOException;

public class GuiOreFilter extends AEBaseGui {
private GuiTextField filter;
public GuiOreFilter(InventoryPlayer ip, IOreFilterable obj) {
super(new ContainerOreFilter(ip, obj));
}

@Override
public void initGui() {
super.initGui();
this.filter = new GuiTextField(this.fontRendererObj, this.guiLeft + 13, this.guiTop + 36, 150, this.fontRendererObj.FONT_HEIGHT);
this.filter.setEnableBackgroundDrawing(false);
this.filter.setMaxStringLength(32);
this.filter.setTextColor(0xFFFFFF);
this.filter.setVisible(true);
this.filter.setFocused(true);
((ContainerOreFilter) this.inventorySlots).setTextField(this.filter);
}

@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString( GuiText.OreFilterLabel.getLocal(), 12, 8, 4210752 );
}

@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture( "guis/renamer.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.filter.drawTextBox();
}

@Override
protected void keyTyped(final char character, final int key) {
if (key == 28) // Enter
{
try
{
NetworkHandler.instance.sendToServer(new PacketValueConfig("OreFilter", this.filter.getText()));
}
catch (IOException e)
{
AELog.debug(e);
}
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
GuiBridge OriginalGui = null;
if (target instanceof PartStorageBus)
OriginalGui = GuiBridge.GUI_STORAGEBUS;
else if (target instanceof PartSharedItemBus)
OriginalGui = GuiBridge.GUI_BUS;

if (OriginalGui != null)
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
else
this.mc.thePlayer.closeScreen();
}
else if (this.filter.textboxKeyTyped(character, key))
{
((ContainerOreFilter) this.inventorySlots).setFilter(filter.getText());
}
else
super.keyTyped(character, key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected void addButtons()
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.oreFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.ACTIONS, ActionItems.ORE_FILTER);

this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );

Expand All @@ -69,6 +70,7 @@ protected void addButtons()
this.buttonList.add( this.rwMode );
this.buttonList.add( this.partition );
this.buttonList.add( this.clear );
this.buttonList.add( this.oreFilter );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.parts.automation.PartExportBus;
import appeng.parts.automation.PartImportBus;
import net.minecraft.client.gui.GuiButton;
Expand All @@ -44,6 +46,7 @@ public class GuiUpgradeable extends AEBaseGui
protected GuiImgButton fuzzyMode;
protected GuiImgButton craftMode;
protected GuiImgButton schedulingMode;
protected GuiImgButton oreFilter;

public GuiUpgradeable( final InventoryPlayer inventoryPlayer, final IUpgradeableHost te )
{
Expand Down Expand Up @@ -78,11 +81,13 @@ protected void addButtons()
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
this.oreFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.ORE_FILTER);

this.buttonList.add( this.craftMode );
this.buttonList.add( this.redstoneMode );
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.schedulingMode );
this.buttonList.add( this.oreFilter );
}

@Override
Expand Down Expand Up @@ -137,7 +142,7 @@ protected void handleButtonVisibility()
}
if( this.fuzzyMode != null )
{
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 && this.bc.getInstalledUpgrades( Upgrades.ORE_FILTER ) == 0);
}
if( this.craftMode != null )
{
Expand All @@ -147,6 +152,10 @@ protected void handleButtonVisibility()
{
this.schedulingMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CAPACITY ) > 0 && this.bc instanceof PartExportBus );
}
if( this.oreFilter != null )
{
this.oreFilter.setVisibility( this.bc.getInstalledUpgrades( Upgrades.ORE_FILTER ) > 0);
}
}

protected String getBackground()
Expand Down Expand Up @@ -190,5 +199,10 @@ protected void actionPerformed( final GuiButton btn )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.schedulingMode.getSetting(), backwards ) );
}

if( btn == this.oreFilter )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_ORE_FILTER ) );
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/appeng/client/gui/widgets/GuiImgButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ public GuiImgButton( final int x, final int y, final Enum idx, final Enum val )
this.registerApp( 16 * 15, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeDefault );
this.registerApp( 16 * 15 + 1, Settings.SCHEDULING_MODE, SchedulingMode.ROUNDROBIN, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRoundRobin );
this.registerApp( 16 * 15 + 2, Settings.SCHEDULING_MODE, SchedulingMode.RANDOM, ButtonToolTips.SchedulingMode, ButtonToolTips.SchedulingModeRandom );

this.registerApp( 70, Settings.ACTIONS, ActionItems.ORE_FILTER, ButtonToolTips.OreFilter, ButtonToolTips.OreFilterHint );

}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/appeng/container/guisync/SyncData.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private void updateString( final Object oldValue, final String val )
try
{
this.field.set( this.source, val );
this.source.onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) );
}
catch( final IllegalArgumentException e )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package appeng.container.implementations;

import appeng.api.config.SecurityPermissions;
import appeng.api.parts.IPart;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.helpers.IOreFilterable;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.tileentity.TileEntity;

public class ContainerOreFilter extends AEBaseContainer
{
private final IOreFilterable filterHost;
@SideOnly( Side.CLIENT )
private GuiTextField textField;
@GuiSync( 2 )
public String filter = "";

public ContainerOreFilter( final InventoryPlayer ip, final IOreFilterable te)
{
super( ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
this.filterHost = te;
}

@SideOnly( Side.CLIENT )
public void setTextField( final GuiTextField f )
{
this.textField = f;
this.textField.setText(filter);
}

public void setFilter( final String newValue)
{
this.filterHost.setFilter(newValue);
this.filter = newValue;
}

@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if (Platform.isServer())
this.filter = this.filterHost.getFilter();
super.detectAndSendChanges();
}
@Override
public void onUpdate( final String field, final Object oldValue, final Object newValue )
{
if (field.equals("filter") && this.textField != null)
this.textField.setText(filter);

super.onUpdate( field, oldValue, newValue );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,8 @@ protected void setupConfig()
{
for( int x = 0; x < 9; x++ )
{
if( y < 2 )
{
this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
}
else
{
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
}
// this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y ) );
}
}

Expand Down Expand Up @@ -121,9 +115,12 @@ public void detectAndSendChanges()
@Override
public boolean isSlotEnabled( final int idx )
{
if (this.getUpgradeable().getInstalledUpgrades(Upgrades.ORE_FILTER) > 0)
return false;

final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );

return upgrades > idx;
return upgrades > (idx-2);
}

public void clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ protected void setupConfig()
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final int y = 40;
final int x = 80;
this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );

this.addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 0, x, y, 0, 0, 0 ) );
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
Expand Down Expand Up @@ -248,6 +247,12 @@ protected void standardDetectAndSendChanges()
@Override
public boolean isSlotEnabled( final int idx )
{
if (this.getUpgradeable().getInstalledUpgrades( Upgrades.ORE_FILTER ) > 0)
return false;

if (idx == 0)
return true;

final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );

if( idx == 1 && upgrades > 0 )
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,15 @@ void postInit( final FMLPostInitializationEvent event )
Upgrades.REDSTONE.registerItem( parts.importBus(), 1 );
Upgrades.CAPACITY.registerItem( parts.importBus(), 2 );
Upgrades.SPEED.registerItem( parts.importBus(), 4 );
Upgrades.ORE_FILTER.registerItem( parts.importBus(), 1 );

// Export Bus
Upgrades.FUZZY.registerItem( parts.exportBus(), 1 );
Upgrades.REDSTONE.registerItem( parts.exportBus(), 1 );
Upgrades.CAPACITY.registerItem( parts.exportBus(), 2 );
Upgrades.SPEED.registerItem( parts.exportBus(), 4 );
Upgrades.CRAFTING.registerItem( parts.exportBus(), 1 );
Upgrades.ORE_FILTER.registerItem( parts.exportBus(), 1 );

// Storage Cells
Upgrades.FUZZY.registerItem( items.cell1k(), 1 );
Expand All @@ -621,11 +623,13 @@ void postInit( final FMLPostInitializationEvent event )
Upgrades.FUZZY.registerItem( parts.storageBus(), 1 );
Upgrades.INVERTER.registerItem( parts.storageBus(), 1 );
Upgrades.CAPACITY.registerItem( parts.storageBus(), 5 );
Upgrades.ORE_FILTER.registerItem( parts.storageBus(), 1 );

// Formation Plane
Upgrades.FUZZY.registerItem( parts.formationPlane(), 1 );
Upgrades.INVERTER.registerItem( parts.formationPlane(), 1 );
Upgrades.CAPACITY.registerItem( parts.formationPlane(), 5 );
//Upgrades.ORE_FILTER.registerItem( parts.formationPlane(), 1 );

// Matter Cannon
Upgrades.FUZZY.registerItem( items.massCannon(), 1 );
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/appeng/core/api/definitions/ApiMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public final class ApiMaterials implements IMaterials
private final IItemDefinition cardFuzzy;
private final IItemDefinition cardInverter;
private final IItemDefinition cardCrafting;

private final IItemDefinition cardOreFilter;
private final IItemDefinition enderDust;
private final IItemDefinition flour;
private final IItemDefinition goldDust;
Expand Down Expand Up @@ -153,6 +153,7 @@ public ApiMaterials( final DefinitionConstructor constructor )
this.cardFuzzy = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardFuzzy ) );
this.cardInverter = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardInverter ) );
this.cardCrafting = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardCrafting ) );
this.cardOreFilter = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.CardOreFilter ) );

this.enderDust = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.EnderDust ) );
this.flour = new DamagedItemDefinition( itemMultiMaterial.createMaterial( MaterialType.Flour ) );
Expand Down Expand Up @@ -364,10 +365,10 @@ public IItemDefinition cardCapacity()
}

@Override
public IItemDefinition cardPatternCapacity()
{
return this.cardPatternCapacity;
}
public IItemDefinition cardPatternCapacity() { return this.cardPatternCapacity; }

@Override
public IItemDefinition cardOreFilter() { return this.cardOreFilter; }

@Override
public IItemDefinition cardFuzzy()
Expand Down
Loading

0 comments on commit 7aa4a95

Please sign in to comment.