Skip to content

Commit

Permalink
Update to 20w46a
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Nov 14, 2020
1 parent 46dcea2 commit ca92d48
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<CompoundTag> 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<ScoreboardState> ci) {
if (this.field_27936 != null) { // weird deferred loading thing
((ComponentProvider) this.field_27936).getComponentContainer().fromTag(tag);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ public abstract class MixinServerWorld extends MixinWorld {

@Inject(at = @At("RETURN"), method = "<init>*")
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"))
Expand All @@ -77,5 +80,4 @@ public <C extends AutoSyncedComponent> CustomPayloadS2CPacket toComponentPacket(
writer.writeSyncPacket(buf, recipient);
return new CustomPayloadS2CPacket(ComponentsWorldNetworking.PACKET_ID, buf);
}

}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca92d48

Please sign in to comment.