diff --git a/cardinal-components-scoreboard/src/main/java/dev/onyxstudios/cca/mixin/scoreboard/MixinScoreboardState.java b/cardinal-components-scoreboard/src/main/java/dev/onyxstudios/cca/mixin/scoreboard/MixinScoreboardState.java index 06954871..ed782998 100644 --- a/cardinal-components-scoreboard/src/main/java/dev/onyxstudios/cca/mixin/scoreboard/MixinScoreboardState.java +++ b/cardinal-components-scoreboard/src/main/java/dev/onyxstudios/cca/mixin/scoreboard/MixinScoreboardState.java @@ -28,6 +28,7 @@ import net.minecraft.scoreboard.Scoreboard; import net.minecraft.scoreboard.ScoreboardState; import net.minecraft.scoreboard.Team; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -41,18 +42,19 @@ @Mixin(ScoreboardState.class) public abstract class MixinScoreboardState { + @Final @Shadow - private Scoreboard scoreboard; + private Scoreboard field_27936; @Inject(method = "toTag", at = @At("RETURN")) private void saveComponents(CompoundTag tag, CallbackInfoReturnable cir) { - ((ComponentProvider) this.scoreboard).getComponentContainer().toTag(tag); + ((ComponentProvider) this.field_27936).getComponentContainer().toTag(tag); } - @Inject(method = "fromTag", at = @At("RETURN")) - private void loadComponents(CompoundTag tag, CallbackInfo ci) { - if (this.scoreboard != null) { // weird deferred loading thing - ((ComponentProvider) this.scoreboard).getComponentContainer().fromTag(tag); + @Inject(method = "method_32481", at = @At("RETURN")) + private void loadComponents(CompoundTag tag, CallbackInfoReturnable ci) { + if (this.field_27936 != null) { // weird deferred loading thing + ((ComponentProvider) this.field_27936).getComponentContainer().fromTag(tag); } } diff --git a/cardinal-components-world/src/main/java/dev/onyxstudios/cca/internal/world/ComponentPersistentState.java b/cardinal-components-world/src/main/java/dev/onyxstudios/cca/internal/world/ComponentPersistentState.java index 8e8241e9..befb7256 100644 --- a/cardinal-components-world/src/main/java/dev/onyxstudios/cca/internal/world/ComponentPersistentState.java +++ b/cardinal-components-world/src/main/java/dev/onyxstudios/cca/internal/world/ComponentPersistentState.java @@ -29,8 +29,8 @@ public class ComponentPersistentState extends PersistentState { private final ComponentContainer components; - public ComponentPersistentState(String id, ComponentContainer components) { - super(id); + public ComponentPersistentState(ComponentContainer components) { + super(); this.components = components; } @@ -39,13 +39,14 @@ public boolean isDirty() { return true; } - @Override - public void fromTag(CompoundTag tag) { - this.components.fromTag(tag); - } - @Override public CompoundTag toTag(CompoundTag tag) { return this.components.toTag(tag); } + + public static ComponentPersistentState fromTag(ComponentContainer components, CompoundTag tag) { + ComponentPersistentState state = new ComponentPersistentState(components); + state.components.fromTag(tag); + return state; + } } diff --git a/cardinal-components-world/src/main/java/dev/onyxstudios/cca/mixin/world/common/MixinServerWorld.java b/cardinal-components-world/src/main/java/dev/onyxstudios/cca/mixin/world/common/MixinServerWorld.java index 05e08cc2..5ac1ef75 100644 --- a/cardinal-components-world/src/main/java/dev/onyxstudios/cca/mixin/world/common/MixinServerWorld.java +++ b/cardinal-components-world/src/main/java/dev/onyxstudios/cca/mixin/world/common/MixinServerWorld.java @@ -56,8 +56,11 @@ public abstract class MixinServerWorld extends MixinWorld { @Inject(at = @At("RETURN"), method = "*") private void constructor(CallbackInfo ci) { - PersistentStateManager persistentStateManager = this.getPersistentStateManager(); - persistentStateManager.getOrCreate(() -> new ComponentPersistentState(PERSISTENT_STATE_KEY, this.components), PERSISTENT_STATE_KEY); + this.getPersistentStateManager().getOrCreate( + tag -> ComponentPersistentState.fromTag(this.components, tag), + () -> new ComponentPersistentState(this.components), + PERSISTENT_STATE_KEY + ); } @Inject(method = "tick", at = @At("RETURN")) @@ -77,5 +80,4 @@ public CustomPayloadS2CPacket toComponentPacket( writer.writeSyncPacket(buf, recipient); return new CustomPayloadS2CPacket(ComponentsWorldNetworking.PACKET_ID, buf); } - } diff --git a/gradle.properties b/gradle.properties index 7fa14253..61bc8d5b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,15 @@ org.gradle.jvmargs = -Xmx3G #see https://modmuss50.me/fabric.html -minecraft_version=20w45a -yarn_mappings=19 +minecraft_version=20w46a +yarn_mappings=11 loader_version=0.10.6+build.214 #Fabric api -fabric_api_version=0.25.3+1.17 +fabric_api_version=0.25.7+1.17 #Publishing -mod_version = 3.0.0-nightly.1.17-20w45a +mod_version = 3.0.0-nightly.20w46a curseforge_id = 318449 curseforge_versions = 1.16-Snapshot changelog_url = https://github.com/OnyxStudios/Cardinal-Components-API/blob/master/changelog.md