-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
TheElenium: BLockESP: Added support for NBT-Data filtering #5933
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
base: master
Are you sure you want to change the base?
Conversation
crosby-moe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 'NBT Data' is the wrong nomenclature here since they only apply to block entities & entities, you should call them 'Properties' instead
- property filters should apply to all blocks
- please dont touch the formatting on lines you dont otherwise modify
| private final Map< | ||
| Block, | ||
| Map<Property<?>, Comparable<?>> | ||
| > activeFilterCache = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this map is always empty
| sgFilters.add(new StringListSetting.Builder() | ||
| .name("NBT-Data") | ||
| .description("Filters with states (e.g. 'waterlogged=false', 'facing=north', 'ominous=true'). Only blocks matching ALL filters will be shown.") | ||
| .defaultValue(new ArrayList<>()) | ||
| .onModuleActivated(stringSetting -> stringSetting.set(blockData.stateFilters)) | ||
| .onChanged(filters -> { | ||
| blockData.stateFilters.clear(); | ||
| blockData.stateFilters.addAll(filters); | ||
| onChanged(); | ||
| }) | ||
| .build() | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho using a string list for this is super unintuitive, it should be a separate setting type
| public boolean tracer; | ||
| public SettingColor tracerColor; | ||
|
|
||
| public List<String> stateFilters = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be final
| private boolean matchesStateFilters(BlockState state, Block block, List<String> filters) { | ||
| for (String filter : filters) { | ||
| try { | ||
| // Parse "key=value" format | ||
| String[] kv = filter.split("="); | ||
| if (kv.length != 2) continue; | ||
|
|
||
| String propertyName = kv[0].trim(); | ||
| String expectedValue = kv[1].trim(); | ||
|
|
||
| Property<?> property = block.getStateManager().getProperty(propertyName); | ||
| if (property == null) continue; | ||
|
|
||
| Optional<?> parsedValue = property.parse(expectedValue); | ||
| if (parsedValue.isEmpty()) continue; | ||
|
|
||
| if (!state.get(property).equals(parsedValue.get())) { | ||
| return false; | ||
| } | ||
| } catch (Exception e) { | ||
| // Invalid filter format | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a hot method, parsing should be done ahead of time
Type of change
Description
Added a feature to the BlockESP module to allow players to filter searched block by nbt data (e.g. waterlogged, facing=north/west etc.). Mainly implemented it, because i wanted an easier way to find ominous trial vaults, but the normal esp modules had no option to distinguish between a normal and an ominous, since they are the same block (minecraft:vault).
Related issues
None
How Has This Been Tested?
I created some blocks that only differ in the nbt data and filtered the in the blockesp module for those tags in the specific block configs
Checklist: