Skip to content

Commit

Permalink
add DataFixer
Browse files Browse the repository at this point in the history
  • Loading branch information
PTOM76 committed Aug 31, 2024
1 parent 66f5986 commit 2874538
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ repositories {
maven { url "https://maven.shedaniel.me/" }
}

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

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ loader_version=0.15.11
fabric_version=0.100.4+1.21

# Mod Properties
mod_version = 1.4.0-1.21
mod_version = 1.4.2-1.21
maven_group = net.pitan76
archives_base_name = storagebox

changelog = Port to 1.21
changelog = DataFixer????????
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.pitan76.storagebox.mixin;

import com.mojang.serialization.Dynamic;
import net.minecraft.datafixer.fix.ItemStackComponentizationFix;
import net.pitan76.storagebox.StorageBoxMod;
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 = "fixStack", at = @At("TAIL"))
private static void storagebox$fixStack(ItemStackComponentizationFix.StackData data, Dynamic<?> dynamic, CallbackInfo ci) {
if (data.itemEquals("storagebox:storagebox")) {
data.moveToComponent("StorageSize", StorageBoxMod.id("size").toString());
data.moveToComponent("StorageAuto", StorageBoxMod.id("auto").toString());
data.moveToComponent("StorageItemData", StorageBoxMod.id("item_data").toString());
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"environment": "*"
}
],
"accessWidener": "storagebox.accesswidener",
"depends": {
"fabricloader": "*",
"fabric": "*",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/storagebox.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessWidener v1 named
accessible class net/minecraft/datafixer/fix/ItemStackComponentizationFix$StackData
3 changes: 2 additions & 1 deletion src/main/resources/storagebox.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"package": "net.pitan76.storagebox.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ItemEntityAccessor",
"ItemPickupMixin",
"ItemEntityAccessor"
"ItemStackComponentizationFixMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 2874538

Please sign in to comment.