Skip to content

Commit

Permalink
Make MinecraftAudiences.update non-static
Browse files Browse the repository at this point in the history
fixes issues with registry-aware components
  • Loading branch information
jpenilla committed Jul 26, 2024
1 parent da666f4 commit 006e0af
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.Keyed;
import net.kyori.adventure.platform.modcommon.impl.AdventureCommon;
import net.kyori.adventure.platform.modcommon.impl.MinecraftAudiencesInternal;
import net.kyori.adventure.platform.modcommon.impl.NonWrappingComponentSerializer;
import net.kyori.adventure.platform.modcommon.impl.WrappedComponent;
import net.kyori.adventure.platform.modcommon.impl.nbt.ModDataComponentValue;
Expand Down Expand Up @@ -83,7 +84,7 @@ public interface MinecraftAudiences {
* @return new component
* @since 6.0.0
*/
static net.minecraft.network.chat.@NotNull Component update(final net.minecraft.network.chat.@NotNull Component input, final UnaryOperator<Component> modifier) {
default net.minecraft.network.chat.@NotNull Component update(final net.minecraft.network.chat.@NotNull Component input, final UnaryOperator<Component> modifier) {
final Component modified;
final @Nullable Function<Pointered, ?> partition;
final @Nullable ComponentRenderer<Pointered> renderer;
Expand All @@ -92,12 +93,12 @@ public interface MinecraftAudiences {
partition = ((WrappedComponent) input).partition();
renderer = ((WrappedComponent) input).renderer();
} else {
final Component original = NonWrappingComponentSerializer.INSTANCE.deserialize(input);
final Component original = this.toAdventure(input);
modified = modifier.apply(original);
partition = null;
renderer = null;
}
return AdventureCommon.HOOKS.createWrappedComponent(modified, partition, renderer, null);
return AdventureCommon.HOOKS.createWrappedComponent(modified, partition, renderer, new NonWrappingComponentSerializer(((MinecraftAudiencesInternal) this)::registryAccess));
}

/**
Expand Down

0 comments on commit 006e0af

Please sign in to comment.