Skip to content

Allow custom items with repairable to be repaired#6505

Merged
valaphee merged 3 commits into
masterfrom
repairable
Jul 10, 2026
Merged

Allow custom items with repairable to be repaired#6505
valaphee merged 3 commits into
masterfrom
repairable

Conversation

@valaphee

@valaphee valaphee commented Jul 4, 2026

Copy link
Copy Markdown
Member

Currently repairables don't work at all as repair_amount is 0 which indicates it's not repairable

This PR now allows all items to be used to repair and are just rejected server-side

Copilot AI review requested due to automatic review settings July 4, 2026 16:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates custom item Bedrock component generation so Java Edition-style “repairable” behavior works (non-zero repair amounts, self-repair with the same base item, and mapped repair materials) instead of currently being effectively non-repairable.

Changes:

  • Adds a “base item” tag to custom items intended to enable self-repair behavior parity with Java Edition.
  • Switches repairable component sourcing to MCPL DataComponentTypes.REPAIRABLE and generates Bedrock minecraft:repairable using Molang formulas.
  • Refactors item tag storage to use String tags instead of Identifier.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +273 to 276
HolderSet repairable = context.components().get(DataComponentTypes.REPAIRABLE);
if (repairable != null) {
computeRepairableProperties(repairable, componentBuilder);
computeRepairableProperties(repairable, componentBuilder, context.vanillaMapping().map(GeyserMappingItem::getBedrockIdentifier).orElse(null));
}
Comment on lines +257 to +259
// Add a base item tag to the item, as in Java Edition they are still the same items and that we can behave the same in Bedrock
context.vanillaMapping().ifPresent(mapping -> addItemTag(componentBuilder, "geyser:" + mapping.getBedrockIdentifier()));

Comment on lines 521 to 523
/**
* This method passes the Java identifiers straight to bedrock - which isn't perfect. Also doesn't work with holder sets that use a tag.
*/
Comment on lines 550 to 575
List<NbtMap> repairItems = new ArrayList<>();
if (baseItem != null) {
repairItems.add(NbtMap.builder()
.putList("items", NbtType.COMPOUND, NbtMap.builder()
.putString("name", baseItem)
.build(), NbtMap.builder()
.putString("tags", "q.all_tags('geyser:" + baseItem + "')")
.build())
.putCompound("repair_amount", NbtMap.builder()
.putString("expression", "math.min(q.remaining_durability + c.other->q.remaining_durability + math.floor(q.max_durability * 0.05), q.max_durability)")
.putShort("version", (short) 12)
.build())
.build());
}
List<NbtMap> items = identifiers.stream()
.map(identifier -> NbtMap.builder()
.putString("name", identifier.toString())
.build()).toList();

componentBuilder.putCompound("minecraft:repairable", NbtMap.builder()
.putList("repair_items", NbtType.COMPOUND, NbtMap.builder()
if (items != null) {
repairItems.add(NbtMap.builder()
.putList("items", NbtType.COMPOUND, items)
.putFloat("repair_amount", 0.0F)
.build())
.putCompound("repair_amount", NbtMap.builder()
.putString("expression", "q.max_durability * 0.25")
.putShort("version", (short) 12)
.build())
.build());
}
componentBuilder.putCompound("minecraft:repairable", NbtMap.builder()
.putList("repair_items", NbtType.COMPOUND, repairItems)
.build());
Copilot AI review requested due to automatic review settings July 4, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +518 to 526
private static void computeRepairableProperties(NbtMapBuilder componentBuilder) {
componentBuilder.putCompound("minecraft:repairable", NbtMap.builder()
.putList("repair_items", NbtType.COMPOUND, NbtMap.builder()
.putList("items", NbtType.COMPOUND, items)
.putFloat("repair_amount", 0.0F)
.putList("items", NbtType.COMPOUND, NbtMap.builder()
.putString("tags", "1")
.build())
.putFloat("repair_amount", 1.0F)
.build())
.build());
@valaphee valaphee changed the title Make repairable behave like Java Edition Allow custom items with repairable to be repaired Jul 4, 2026
@onebeastchris

onebeastchris commented Jul 8, 2026

Copy link
Copy Markdown
Member

Hey! Thanks for the PR - would this mean that the "red x" would never show up for custom items? Or is the client "smart enough" there to show it when the item is e.g. already fully repaired?

@valaphee

valaphee commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

The "red x" would never show up, but I think its better than the "red x" always shows up

there is also a proper solution, but I don't really have an overview over the custom items API, this is more of a temporary minimally invasive fix.

@onebeastchris onebeastchris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For a temporary hack, i'm okay with this. Personally, i think it would be ideal if we could allow users to specify the items / bedrock item tags so someone could spend more time to get a more accurate repairable component mapping though

Added a TODO comment to restrict repairs to the same Java item and its repair materials.
@valaphee valaphee merged commit 56a13d1 into master Jul 10, 2026
3 checks passed
@valaphee valaphee deleted the repairable branch July 10, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants