Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Filters and some Covers to MUI + Filter Rework #2345

Merged
merged 260 commits into from
Apr 4, 2024

Conversation

ghzdude
Copy link
Contributor

@ghzdude ghzdude commented Jan 14, 2024

What

Rework Filter Behavior
remove FilterTypeRegistry
Port some Covers to MUI

Implementation Details

port filters to mui
make filters open a gui on rightclick
remove FilterTypeRegistry
create the filter behavior as a metaitem component
filter settings are now stored/read from item NBT
deprecate old mui methods
add method slice() to GTGuiTextures for slicing an image into an array
make CoverWithUI::createTitleRow() static
fix buttons not being adaptable enough

Outcome

Currently, the covers ported are:

  • (simple) item filter
  • smart item filter
  • oredict item filter
  • (simple) fluid filter
  • conveyor
  • robot arm
  • pump
  • regulator
  • item voiding + advanced
  • fluid voiding + advanced
  • ender fluid link cover

As a result of the changes to filter UI and behavior, some covers that accept filters don't work correctly:

  • advanced item detector
  • advanced fluid detector

Todo

this may be updated in the future

  • port simple item filter
  • port smart item filter
  • port oredict filter
  • port fluid filter
  • fix item voiding + advanced
  • fix fluid voiding + advanced
  • fix ender fluid link cover
  • add buttons for pipe distribution
  • add overlays for certain buttons
    • conveyor manual IO
    • conveyor transfer mode
    • robot arm transfer mode
    • bucket mode
    • voiding mode
    • filter mode
  • fix lang for
    • item/fluid filter as cover

Potential Compatibility Issues

At the moment, some method that previously existed or had functionality may be commented out or removed. If this will cause issues, let me know. There might also some parts where NBT saved in older worlds is not read to the new filter system

@ghzdude ghzdude added the type: refactor Suggestion to refactor a section of code label Jan 14, 2024
@ghzdude ghzdude marked this pull request as ready for review January 19, 2024 23:43
@ghzdude ghzdude requested review from a team as code owners January 19, 2024 23:43
@ghzdude ghzdude changed the title Port Filters, Conveyors and Robot Arm to MUI + Filter Rework Port Filters and some Covers to MUI + Filter Rework Jan 20, 2024
Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed the following issue with tooltips while in creative mode with an item on the cursor and having moved the filter popup window over to the side. Seems like it would be mainly a MUI issue, but I thought I would bring it up here
2024-01-19_17 53 53

ItemStacks in Filters in Robot Arms need to have a tooltip added to them explaining the various ways to increment/decrement the count of the itemstack in the filter. IE: Key Combo + Scroll, or Key Combo + Click
And example from the fluid filter:
2024-01-19_18-46

Since you added the ability to configure filters when the are in your inventory and keeping NBT, you need to add shapeless NBT clearing recipes for all the filters

You can currently crash trying to put an itemstack into the fluid slots of a fluid filter

Currently you can shift right click to clear the filter NBT when it is in your inventory. This needs a tooltip.

And yeah, as talked about on discord, I think we should move button state in these reworked covers to match that of the machine controller

You are currently making GUIs both the old way and the new way for a bunch of the filters that were converted. Any reason you are keeping the old implementations around?

You are currently limited to 1 bucket per slot maximum in a fluid filter, when configuring it in inventory. Any reason for this?

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 20, 2024

And yeah, as talked about on discord, I think we should move button state in these reworked covers to match that of the machine controller

I've switched around the background textures for the enum rows, so it should look better now

@ALongStringOfNumbers
Copy link
Contributor

Found a voiding issue: Give yourself a stack of filters, right click to configure, and it sets the stacksize to 1

Also, should you be able to have duplicate itemstacks in filters? I don't think it would serve any purpose

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 20, 2024

Found a voiding issue: Give yourself a stack of filters, right click to configure, and it sets the stacksize to 1

should be fixed now with 2f200cb

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 22, 2024

ItemStacks in Filters in Robot Arms need to have a tooltip added to them explaining the various ways to increment/decrement the count of the itemstack in the filter. IE: Key Combo + Scroll, or Key Combo + Click

fixed with 5cb80df

I also noticed that the lang for fluid filter configuration has shift left/right-click to double/halve, but MUI does not do this behavior by default, should I add that behavior back for item and fluid filter slots?

@ALongStringOfNumbers
Copy link
Contributor

ItemStacks in Filters in Robot Arms need to have a tooltip added to them explaining the various ways to increment/decrement the count of the itemstack in the filter. IE: Key Combo + Scroll, or Key Combo + Click

fixed with 5cb80df

I also noticed that the lang for fluid filter configuration has shift left/right-click to double/halve, but MUI does not do this behavior by default, should I add that behavior back for item and fluid filter slots?

That one I am on the fence about, since you can key combo + scroll. I think it could be left out for now maybe

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 23, 2024

I'm not totally sure about the appearance of the fluid voiding overlays from 04451a0, would like some feedback on that

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 26, 2024

You are currently limited to 1 bucket per slot maximum in a fluid filter, when configuring it in inventory. Any reason for this?

i consider it the default behavior of a fluid filter, as that's the behavior for a fluid filter in a pump. I could probably make it not render the fluid amount unless the fluid filter is in a regulator or advanced fluid voiding cover.

@brachy84
Copy link
Contributor

Phantom fluid slots have a controllsAmount property or in the sync handler. This makes the slot only be able to hold 1mb and not render the amount.

@ghzdude
Copy link
Contributor Author

ghzdude commented Jan 27, 2024

Phantom fluid slots have a controllsAmount property or in the sync handler. This makes the slot only be able to hold 1mb and not render the amount.

i'm using that now with 5fb69a4, thanks

@ghzdude ghzdude mentioned this pull request Jan 30, 2024
7 tasks
Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An in progress review

}

public void setMaxTransferRate(int transferRate) {
transferRate = MathHelper.clamp(transferRate, 1, Integer.MAX_VALUE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The min for transfer rate should be 0 right? Not 1? I remember that currently you can set transfer rates to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can set the max transfer rate (max stack size for items) to 0, but the normal transfer rate is clamped to a min of 1

@ghzdude
Copy link
Contributor Author

ghzdude commented Feb 8, 2024

Summary of latest changes

  • The inner classes in all ItemFilter and FluidFilter classes have been moved out
  • Class hierarchy for filters, filter readers, and filter ui managers has been changed slightly
    • Base Filter -> SimpleItemFilter, SimpleFluidFilter, SmartItemFilter, OreDictionaryItemFilter
    • BaseFilterReader -> SimpleItemFilter, SimpleFluidFilter
      • SimpleItemFilter -> SmartItemFilter, OreDictionaryItemFilter
    • BaseFilterUIManager -> SimpleItemFilter, SimpleFluidFilter, SmartItemFilter, OreDictionaryItemFilter
  • New/renamed interfaces:
    • Filter<> renamed and split to IFilter, IItemFilter, IFluidFilter
    • FilterReader
    • FilterFactory - functional interface that takes an ItemStack and returns a Filter
  • FilterTypeRegistry has been reworked... again
    • store a Map<ItemStack, FilterFactory> and Map<ItemStack, FilterType>
    • previous maps are intended to be removed/deprecated
  • add types to filters to differentiate item filters from fluid filters
  • fixes some issues with reading legacy NBT data
  • fix FilterMode not syncing to client
  • fix issues with robot arm not respecting blacklist on smart filters
  • fix robot arm not working correctly with certain filters
  • the global limit text field should be displayed in correct situations
  • a few other smaller changes that i don't remember right now

Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Robot Arm has the text for "Conveyor Mode" next to its Import and Output mode selection. This should probably be renamed to something more general.

Found an error with the Robot arm and item filters. Place an item filter in a Robot Arm in Transfer Any mode. Change the Mode to Keep Exact, and scrolling to change the item amount is not displayed until the filter is closed and re-opened.

What is the difference between the max stack size and the transfer stack size in BaseFilterContainer?

src/main/java/gregtech/common/covers/CoverItemFilter.java Outdated Show resolved Hide resolved
src/main/java/gregtech/common/covers/CoverFluidFilter.java Outdated Show resolved Hide resolved
}

public void onFilterInstanceChange() {
dirtyNotifiable.markAsDirty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also run the onFilterInstanceChange?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could do that, though we never set the variable ourselves it seems

@ghzdude
Copy link
Contributor Author

ghzdude commented Feb 12, 2024

What is the difference between the max stack size and the transfer stack size in BaseFilterContainer?

transferSize is the value that's set by the text field when there is no filter, if the filter is blacklist, or if it's an oredict/smart filter.
maxTransferSize is the max value that transferSize can be.

your other comments should also be addressed now

@ghzdude ghzdude force-pushed the gh-mui-filter-cover-rework branch 2 times, most recently from 2975608 to 63dcf5e Compare February 18, 2024 05:42
Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was testing the Ore Dictionary filter, and the Case Sensitive stuff didn't seem to work. Was testing a gold ingot, so ingotGold and typing in gold into the bar matched the ingot in both case sensitive and insensitive modes. Figured out that toggling the case sensitivity option does not refresh the displayed match status. This might also happen with the match all button, but I did not test that.

Kind of an ask, but you should be able to hold backspace in the Ore Dict Filter text bar.

The amount incrementing/decrementing tooltips in an item filter should really only be shown in cases where you can change the amount, like the filter being in a robot arm. Currently they are shown when just opening the filter by itself, which is a bit confusing because none of it applies.

Opening an Ore Dictionary filter, doing nothing, and then closing the GUI gives the filter an empty NBT tag. Could this be avoided at all?

There still needs to be an icon for the filter button when in a cover (like the conveyor)

Dupe Found: Place a macerator, place a Conveyor on top (used UV), place a crate on top (Used TungstenSteel), add a stack of crates to the crate, change the mode of the conveyor to import, and it will dupe the stack of crates, 1 stack in the macerator and 1 stack remaining in the crate.
And afterwords I ran the macerator, clearing some space in the input, and the conveyor would not pull in the remaining stack of crates from the crate. However, other items added to the crate would be pulled in, so I am not sure if this is an actual dupe, or just a big desync, although I am leaning towards dupe.

@ghzdude
Copy link
Contributor Author

ghzdude commented Mar 3, 2024

Was testing the Ore Dictionary filter, and the Case Sensitive stuff didn't seem to work. Was testing a gold ingot, so ingotGold and typing in gold into the bar matched the ingot in both case sensitive and insensitive modes. Figured out that toggling the case sensitivity option does not refresh the displayed match status. This might also happen with the match all button, but I did not test that.

this should be fixed now (for both case sensitive and match all buttons)

Kind of an ask, but you should be able to hold backspace in the Ore Dict Filter text bar.

this is already what happens, at least with mui 2.4.3

The amount incrementing/decrementing tooltips in an item filter should really only be shown in cases where you can change the amount, like the filter being in a robot arm. Currently they are shown when just opening the filter by itself, which is a bit confusing because none of it applies.

are you talking about the "Count: #" tooltip? i could probably move that to only robot arm where it's most relevant

Opening an Ore Dictionary filter, doing nothing, and then closing the GUI gives the filter an empty NBT tag. Could this be avoided at all?

it's a consequence of calling getStackTag() for checking if a stack's tag exists, and adding an empty one if it doesn't.

Dupe Found: Place a macerator, place a Conveyor on top (used UV), place a crate on top (Used TungstenSteel), add a stack of crates to the crate, change the mode of the conveyor to import, and it will dupe the stack of crates, 1 stack in the macerator and 1 stack remaining in the crate. And afterwords I ran the macerator, clearing some space in the input, and the conveyor would not pull in the remaining stack of crates from the crate. However, other items added to the crate would be pulled in, so I am not sure if this is an actual dupe, or just a big desync, although I am leaning towards dupe.

i cannot replicate this. i do remember that the crate's UI was not syncing to the client properly in the past, but i'm not seeing that anymore either

@ghzdude
Copy link
Contributor Author

ghzdude commented Mar 4, 2024

There still needs to be an icon for the filter button when in a cover (like the conveyor)

this should be fixed now

@ALongStringOfNumbers
Copy link
Contributor

The amount incrementing/decrementing tooltips in an item filter should really only be shown in cases where you can change the amount, like the filter being in a robot arm. Currently they are shown when just opening the filter by itself, which is a bit confusing because none of it applies.

are you talking about the "Count: #" tooltip? i could probably move that to only robot arm where it's most relevant

I am talking about this tooltip for adjusting the amount of items in the filter
image
The scroll wheel, key combos, click to increase/decrease. But yeah, the count is part of that too. Making that tooltip only show in robot arms would make sense to me, as it is the only time that matters. Except for fluid regulators. It matters there as well

@ghzdude
Copy link
Contributor Author

ghzdude commented Mar 7, 2024

I am talking about this tooltip for adjusting the amount of items in the filter
...
The scroll wheel, key combos, click to increase/decrease. But yeah, the count is part of that too. Making that tooltip only show in robot arms would make sense to me, as it is the only time that matters. Except for fluid regulators. It matters there as well

Ah, I see. I can fix that for the item filters, but MUI adds the tooltip for the phantom fluid slots. In order to change that I would have to override the slot's class or rebuild the tooltip from scratch.

@ghzdude ghzdude force-pushed the gh-mui-filter-cover-rework branch from 68968ce to f66cf3b Compare March 7, 2024 05:22
move draw calls to a more appropriate method
do `string, string` function instead
remove legacy tag when loaded
remove some methods from IFilter
yeet IItemFilter.java and IFluidFilter.java
test/match against Object and cast appropriately
remove MatchResult's generics
move similar methods into BaseFilterContainer
@ALongStringOfNumbers
Copy link
Contributor

Even with the most recent commit, whitelist/blacklist modes are not preserved on existing filters as covers when loading into a world with filters created before switching to this branch.

@ALongStringOfNumbers
Copy link
Contributor

From testing transferring old worlds with old filters, into new worlds, I found the following issues:

  • The above, with whitelist/blacklist with filters as covers
  • In Robot arms, Any items that were filtered in an existing filter in a robot arm are not carried over. Testing case: Robot arm, keep exact, with an item filter. The filter has a stack of 132 EV robot arms in the filter (Although this also happened when the stacksize was 1). We are in whitelist mode. When changing to this branch, the contents of the filter are empty.
  • For filters in robot arms, the Respect NBT setting of the filter is not carried over when changing into the new world. Whitelist/blacklist is carried over correctly, and I did not test Respect Damage
  • For Filters in Pumps, the fluid stored in the filter is not carried over when loading into a new world with this PR. (The filter gets a capacity of 1, unsure if that would be blocking anything)
  • For Filters in Fluid Regulars, the fluid stored in the filter is not carried over when loading into a new world with this PR.
  • For Fluid Regulators, when in supply exact mode with no filter, specifying a supply exact rate and then loading the world with this PR see that the rate is not carried across. (Example, I had a rate of 131, loaded with this PR, and it was 1)
  • In the Item Voiding Cover, when using the Ore Dict filter, the stored ore dict phrase is not carried over after loading this PR
  • In the Item Voiding Cover, when using the Smart Item filter, the filter mode is not carried over after loading this PR
  • In the Item Voiding Cover, using a regular item filter, the filter contents, respect damage, and respect NBT settings are not carried over
  • In the Advanced Item Voiding Cover (Both Void Matching and Void Overflow), using a regular item filter, the filter contents, respect damage, and respect NBT settings are not carried over. (I am not going to report this one any more, because it seems like one fix could fix them all)
  • Same as above with the ore dict filter and smart filter in the regular voiding filter, but in the advanced one
  • The private mode tank Icon in the Ender Fluid Link cover is missing
  • The Pump mode buttons in the Ender Fluid Link cover don't have Icons
  • In the Advanced Fluid Voiding cover, Bucket Mode is not carried over, and also the void overflow amount is not carried over when switching to this PR
  • In the Advanced Item Detector Cover, the Inverted Button is titled "Working Enabled/Disabled" instead of Inverted

@ghzdude
Copy link
Contributor Author

ghzdude commented Mar 30, 2024

i'm pretty sure most if not all of the legacy nbt reading is handled correctly now

  • The private mode tank Icon in the Ender Fluid Link cover is missing

  • The Pump mode buttons in the Ender Fluid Link cover don't have Icons

both of these are fixed now

  • In the Advanced Fluid Voiding cover, Bucket Mode is not carried over, and also the void overflow amount is not carried over when switching to this PR

bucket mode previously was not saved (iirc) for pumps/regulators. i'll try to save it now

  • In the Advanced Item Detector Cover, the Inverted Button is titled "Working Enabled/Disabled" instead of Inverted

fixed now

Copy link
Contributor

@ALongStringOfNumbers ALongStringOfNumbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, but this PR is getting a bit too unwieldy. We should merge this now, and have a followup PR for any required bugfixes

@TechLord22 TechLord22 merged commit f33da7f into GregTechCEu:master Apr 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Suggestion to refactor a section of code
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants