-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Implemented a Find Block operation #349
base: master
Are you sure you want to change the base?
Conversation
|
||
class ResultDialog(SimpleDialog): | ||
def __init__(self, parent, block_location_info): | ||
super(ResultDialog, self).__init__(parent, "Block Locations") |
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.
You can just do super().__init__(parent, "Block Locations")
|
||
class FindBlock(SimpleOperationPanel): | ||
def __init__(self, parent, canvas, world, options_path): | ||
SimpleOperationPanel.__init__(self, parent, canvas, world, options_path) |
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.
You can just do super().__init__(parent, canvas, world, options_path)
def _find_single_blockstate(self, world, dimension, selection): | ||
target = world.block_palette.get_add_block(self._get_target_block()) | ||
|
||
iter_count = len(list(world.get_chunk_slice_box(dimension, selection, False))) |
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.
I know I have done this a bit but there is a quicker way. I should look into fixing the other places.
len(list(world.get_coord_box(dimension, selection, False)))
This should get the same length (or at least close) without having to pre-load all the chunks.
options.get("target_block_options", []) | ||
or [world.level_wrapper.platform] | ||
), | ||
show_pick_block=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.
You haven't hooked up the pick block tool to the render.
Check out the fill operation for an example of how to do that.
I like what you have done. I have commented on some minor code issues. Sorry about the next bit. It is a bit rambly but I don't know how to explain it concisely Example: Universal blocks in the world If you match in universal only the first will match. The blocks in world converted to Bedrock 1.17 will all be the same as the first blockstate. |
For finding locations of a single blockstate I compare using the universal format, but for finding all the substates of a block I first convert everything to the versioned block, are you saying that I should do the same for searching when doing a single blockstate? |
You should should be converting to the version that is chosen in the BlockDefine UI not the world version that way you are matching in whatever format the user defined the block in. Doing this will allow it to match any blocks that equate to the chosen block in the chosen version. Sorry about closing the issue. I think I hit shift + enter on autopilot to do a new line like in discord which sent the message and closed the issue |
blocks_to_find = blocks_to_find.union( | ||
filter( | ||
lambda b: b[1].namespaced_name == versioned_block_name, | ||
map( | ||
lambda b: (b[0], block_translator.from_universal(b[1])[0]), | ||
world.block_palette.items(), | ||
), | ||
), | ||
) |
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 up here is fine but as each chunk is loaded if new blockstates are found in that chunk they will be added to the block palette.
In the loop below you should check if the palette size has changed and scan the new blocks
for internal_id, block in blocks_to_find: | ||
extend_func = results[block.full_blockstate].extend | ||
for chunk, slices, _ in chunk_slices: |
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.
These loops would be better the other way around so that you are only loading each chunk once and doing all the work on that chunk in one go.
It is also worth mentioning that I am working on a UI that will allow the user to pick one or more values for each property. |
…k substate finding functioned
|
This adds a new operation that finds a specific block (or all substates of a given block's namespaced name) and then reports the results in a tree control dialog with all of the coordinates
Example of the find block results dialog: