Skip to content

Commit

Permalink
feat: datafixer for componentization
Browse files Browse the repository at this point in the history
1.20.6 release is waiting on Trinkets release
  • Loading branch information
Jamalam360 committed May 21, 2024
1 parent 3c484ef commit d9a0be8
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 5 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- Remove the Baubly dependency
- This also fixes #42
- Drop Forge and Quilt support (see Discord for reasoning). This was done pre-1.20.6 to reduce the
work needed to remove Baubly.
- Port to 1.20.6
- It should be safe to update worlds from 1.20.4 to 1.20.6 **ON FABRIC** as a datafixer has been
implemented
to migrate from NBT to components, but as always make a backup in case.
- If [Curios#411](https://github.com/TheIllusiveC4/Curios/issues/411) is implemented, it will be
safe to do so on Neoforge. For now, upgrading Neoforge worlds **WILL CAUSE LOSS OF ITEMS IN
THE BELT**.
4 changes: 4 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ architectury {
common(rootProject.enabled_platforms.split(","))
}

loom {
accessWidenerPath = file("src/main/resources/utility_belt.accesswidener")
}

dependencies {
modImplementation libs.fabric.loader
modApi libs.architectury.common
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.jamalam360.utility_belt.mixin.datafixer;

import com.mojang.serialization.Dynamic;
import io.github.jamalam360.utility_belt.UtilityBelt;
import java.util.stream.Stream;
import net.minecraft.util.datafix.fixes.ItemStackComponentizationFix;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ItemStackComponentizationFix.class)
public class ItemStackComponentizationFixMixin {
@Inject(
method = "fixItemStack",
at = @At("TAIL")
)
private static void utilitybelt$moveNbtToComponent(ItemStackComponentizationFix.ItemStackData itemStackData, Dynamic<?> dynamic, CallbackInfo ci) {
if (itemStackData.is(UtilityBelt.id("utility_belt").toString())) {
System.out.println("fixed belt");
itemStackData.moveTagToComponent("Inventory", "utility_belt:utility_belt_inventory", dynamic.createList(Stream.empty()));
}
}
}
3 changes: 3 additions & 0 deletions common/src/main/resources/architectury.common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"accessWidener": "utility_belt.accesswidener"
}
3 changes: 3 additions & 0 deletions common/src/main/resources/utility_belt.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessWidener v2 named

accessible class net/minecraft/util/datafix/fixes/ItemStackComponentizationFix$ItemStackData
3 changes: 2 additions & 1 deletion common/src/main/resources/utility_belt.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"LivingEntityMixin",
"PlayerMixin",
"ServerGamePacketListenerImplMixin",
"ServerPlayerMixin"
"ServerPlayerMixin",
"datafixer.ItemStackComponentizationFixMixin"
],
"client": [
"client.ClientPacketListenerMixin",
Expand Down
4 changes: 4 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ architectury {
fabric()
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}

base {
archivesName = "utility-belt-fabric"
}
Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"mixins": [
"utility_belt.mixins.json"
],
"accessWidener": "utility_belt.accesswidener",
"depends": {
"fabricloader": ">=0.15.0",
"fabric": ">=${fabric_api_version}",
Expand Down
5 changes: 5 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ architectury {
neoForge()
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}

base {
archivesName = "utility-belt-neoforge"
}
Expand Down Expand Up @@ -108,6 +112,7 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
atAccessWideners.add "utility_belt.accesswidener"
}

sourcesJar {
Expand Down

0 comments on commit d9a0be8

Please sign in to comment.