Wand / Brushes / mcstructures#8
Conversation
Review Summary by QodoAdd brush system, mcstructure loading, stack command
WalkthroughsDescription• Added brush system with sphere, cylinder, cube shapes • Implemented mask command for brush filtering • Added mcstructure file loading support • Added stack command for cloning selections • Enhanced wand tool with NBT identification Diagramflowchart LR
A["Wand Tool<br/>NBT Identification"] --> B["Brush System<br/>Sphere/Cylinder/Cube"]
B --> C["Mask Command<br/>Block Filtering"]
B --> D["Brush Execution<br/>on Right Click"]
E["MCStructure<br/>File Reader"] --> F["Load Command<br/>Place Blocks"]
G["Stack Command<br/>Clone Selection"] --> H["Direction Detection<br/>Based on Yaw"]
D --> I["Plugin Event<br/>Handler Integration"]
F --> I
H --> I
File Changes1. src/endstone_worldedit/commands/brush.py
|
Code Review by Qodo
1.
|
| if brush_type == "none": | ||
| item = sender.inventory.item_in_main_hand | ||
| if item and item.nbt and "worldedit" in item.nbt and item.nbt["worldedit"].value == "brush": | ||
| item.nbt = CompoundTag() | ||
| sender.send_message("Brush unbound from current item.") | ||
| else: | ||
| sender.send_message("No brush bound to current item.") | ||
| return True |
There was a problem hiding this comment.
2. Item nbt overwritten 🐞 Bug ☼ Reliability
/brush (bind/unbind) and /mask replace the entire item.nbt CompoundTag, which can wipe unrelated item data (e.g., enchantments/durability/custom NBT) and cause irreversible inventory data loss. Unbinding with CompoundTag() also clears everything rather than removing only WorldEdit keys.
Agent Prompt
### Issue description
WorldEdit brush/mask operations currently overwrite the entire `ItemStack.nbt`, which can delete unrelated NBT data.
### Issue Context
- `/brush none` sets `item.nbt = CompoundTag()`.
- Brush binding sets `item.nbt = CompoundTag({"worldedit": ..., "brush": ...})`.
- `/mask` similarly overwrites `item.nbt`.
### Fix Focus Areas
- src/endstone_worldedit/commands/brush.py[26-33]
- src/endstone_worldedit/commands/brush.py[101-117]
- src/endstone_worldedit/commands/mask.py[48-55]
### What to change
- When binding/updating, start from existing NBT:
- `nbt = item.nbt or CompoundTag()`
- set/update only `nbt["worldedit"]` and `nbt["brush"]`
- assign back `item.nbt = nbt`
- When unbinding, delete only WorldEdit keys:
- `del nbt["worldedit"]` / `del nbt["brush"]` if present (or set them to neutral values)
- do **not** replace the entire tag with an empty CompoundTag.
- Consider also restoring/clearing display name/lore when unbinding to avoid leaving misleading metadata.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Added all this features
TODO: