Skip to content

Commit

Permalink
Merge pull request #157 from KyoriPowered/snapshots/1.21.2
Browse files Browse the repository at this point in the history
1.21.2
  • Loading branch information
zml2008 authored Oct 23, 2024
2 parents 62ce846 + 47f5423 commit 2a39f4b
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 54 deletions.
6 changes: 3 additions & 3 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
alias(libs.plugins.loom)
alias(libs.plugins.configurateTransformations)
id("standard-conventions")
// id("publishing-conventions") // disable until 1.21.2
id("publishing-conventions")
}

dependencies {
Expand Down Expand Up @@ -225,8 +225,8 @@ tasks.withType(GenerateSourcesTask::class).configureEach {

// Workaround for both loom and indra doing publication logic in an afterEvaluate :(
indra.includeJavaSoftwareComponentInPublications(false)
/*publishing {
publishing {
publications.named("maven", MavenPublication::class) {
from(components["java"])
}
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(TitleScreen.class)
abstract class TitleScreenMixin extends Screen {
protected TitleScreenMixin(final Component title) {
super(title);
}

@Inject(method = "createNormalMenuOptions(II)V", at = @At("HEAD"))
void addMenuOptions(final int y, final int rowHeight, final CallbackInfo ci) {
@Inject(method = "createNormalMenuOptions(II)I", at = @At("HEAD"))
void addMenuOptions(final int y, final int rowHeight, final CallbackInfoReturnable<Integer> cir) {
final Component nativeText = MinecraftClientAudiences.of().asNative(
net.kyori.adventure.text.Component.translatable("menu.singleplayer", TextColor.color(0x9A40D2))
);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=net.kyori
version=6.0.2-SNAPSHOT
version=6.1.0-SNAPSHOT
description=Integration between the adventure library and Minecraft: Java Edition, using the Fabric and NeoForge modding systems

javadocPublishRoot=https://jd.advntr.dev/platform/
Expand Down
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ ansi = "1.1.0"
autoService = "1.1.1"
checkstyle = "10.18.2"
examination = "1.3.0"
fabricApi = "0.100.1+1.21"
fabricLoader = "0.15.11"
fabricApi = "0.106.1+1.21.2"
fabricLoader = "0.16.7"
indra = "3.1.3"
junit = "5.11.2"
minecraft = "1.21"
parchment = "1.20.6:2024.06.02"
minecraft = "1.21.2"
parchment = "1.21:2024.07.28"
vineflower = "1.10.1"
spotless = "6.25.0"
neoforge = "21.0.167"
neoform = "1.21-20240613.152323"
neoforge = "21.2.0-beta"
neoform = "1.21.2-20241022.151510"

[libraries]
adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }
Expand All @@ -33,11 +33,11 @@ adventure-textSerializerAnsi = { module = "net.kyori:adventure-text-serializer-a
ansi = { module = "net.kyori:ansi", version.ref = "ansi" }
examination-api = { module = "net.kyori:examination-api", version.ref = "examination" }
examination-string = { module = "net.kyori:examination-string", version.ref = "examination" }
jetbrainsAnnotations = "org.jetbrains:annotations:25.0.0"
jetbrainsAnnotations = "org.jetbrains:annotations:26.0.0"
option = { module = "net.kyori:option", version = "1.0.0" }

# mod-shared
mixin = "net.fabricmc:sponge-mixin:0.13.4+mixin.0.8.5"
mixin = "net.fabricmc:sponge-mixin:0.15.3+mixin.0.8.7"
mixinExtras = "io.github.llamalad7:mixinextras-common:0.4.1"
# For Renovate, do not use directly
zNeoform = { module = "net.neoforged:neoform", version.ref = "neoform" }
Expand Down Expand Up @@ -81,7 +81,7 @@ zCheckstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "check
[plugins]
configurateTransformations = { id = "ca.stellardrift.configurate-transformations" }
eclipseApt = "com.diffplug.eclipse.apt:4.1.0"
loom = "fabric-loom:1.8.6"
loom = "fabric-loom:1.8.10"
# ModDevGradle settings plugin is putting another version on the classpath, so we can't specify a version :(
ideaExt = { id = "org.jetbrains.gradle.plugin.idea-ext" }
indra = { id = "net.kyori.indra" }
Expand Down
22 changes: 22 additions & 0 deletions mod-shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,29 @@ neoForge {
}
}

@CacheableRule
abstract class RemoveAsmConstraint implements ComponentMetadataRule {
@Override
void execute(final ComponentMetadataContext ctx) {
ctx.details.allVariants {
it.withDependencies { deps ->
deps.forEach { dep ->
if (dep.group == 'org.ow2.asm') {
if (dep.versionConstraint.strictVersion != null) {
dep.version { it.require(it.strictVersion) }
}
}
}
}
}
}
}

dependencies {
components {
// Mojang ships an old version of ASM, which conflicts with our deps. Upstream will probably solve this better when an actual release happens.
withModule('net.neoforged:minecraft-dependencies', RemoveAsmConstraint)
}
compileOnly(libs.mixin)
compileOnly(libs.mixinExtras)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static Identity identity(final GameProfile profile) {
*/
@Contract("null -> null; !null -> !null")
static Sound.Type asSoundType(final SoundEvent soundEvent) {
return (Sound.Type) soundEvent;
return (Sound.Type) (Object) soundEvent;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ public interface MinecraftServerAudiences extends AudienceProvider, MinecraftAud
*/
@NotNull AdventureCommandSourceStack audience(@NotNull CommandSourceStack source);

/**
* Get an audience that will send to the provided {@link ServerPlayer}.
*
* <p>Depending on the specific source, the returned audience may only support
* a subset of abilities.</p>
*
* @param source source to send to
* @return an audience for the source
* @since 6.1.0
*/
@NotNull Audience audience(@NotNull ServerPlayer source);

/**
* Get an audience that will send to the provided {@link CommandSource}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public static void scheduleClickCallbackCleanup() {
final MinecraftAudiencesInternal rendererProvider
) {
final Holder<net.minecraft.network.chat.ChatType> type = rendererProvider.registryAccess()
.registryOrThrow(Registries.CHAT_TYPE)
.getHolder(MinecraftAudiences.asNative(bound.type().key()))
.lookupOrThrow(Registries.CHAT_TYPE)
.get(MinecraftAudiences.asNative(bound.type().key()))
.orElseThrow(() -> new IllegalArgumentException("Could not resolve chat type for key " + bound.type().key()));

return new net.minecraft.network.chat.ChatType.Bound(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,28 @@ private Iterable<Audience> audiences(final Iterable<? extends ServerPlayer> play
throw new IllegalArgumentException("The AdventureCommandSource mixin failed!");
}

return internal.adventure$audience(this.audience(internal.adventure$source()), this);
final Audience backingAudience = source.getEntity() instanceof final ServerPlayer ply && ply.commandSource() == internal.adventure$source()
? this.audience(ply)
: this.audience(internal.adventure$source());
return internal.adventure$audience(backingAudience, this);
}

@Override
public @NotNull Audience audience(final @NotNull ServerPlayer source) {
return switch (source) {
case final RenderableAudience render -> render.renderUsing(this);
case final Audience audience -> audience; // todo: how to pass component renderer through
default -> new ServerPlayerAudience(source, this);
};
}

@Override
public @NotNull Audience audience(final @NotNull CommandSource source) {
if (source instanceof final RenderableAudience renderable) {
return renderable.renderUsing(this);
} else if (source instanceof final Audience audience) {
// TODO: How to pass component renderer through
return audience;
} else {
return new CommandSourceAudience(source, this);
}
return switch (source) {
case final RenderableAudience render -> render.renderUsing(this);
case final Audience audience -> audience; // todo: how to pass component renderer through
default -> new CommandSourceAudience(source, this);
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ private long seed(final @NotNull Sound sound) {

private Holder<SoundEvent> eventHolder(final @NotNull Sound sound) {
final var soundEventRegistry = this.controller.registryAccess()
.registryOrThrow(Registries.SOUND_EVENT);
.lookupOrThrow(Registries.SOUND_EVENT);
final var soundKey = MinecraftAudiences.asNative(sound.name());

final var eventOptional = soundEventRegistry.getHolder(ResourceKey.create(Registries.SOUND_EVENT, soundKey));
final var eventOptional = soundEventRegistry.get(ResourceKey.create(Registries.SOUND_EVENT, soundKey));
return eventOptional.isPresent() ? eventOptional.get() : Holder.direct(SoundEvent.createVariableRangeEvent(soundKey));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public final class DataComponentValueConverterProvider implements DataComponentV
}

private static DataComponentType<?> resolveComponentType(final Key key) {
final DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(MinecraftAudiences.asNative(key));
final DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.getValue(MinecraftAudiences.asNative(key));
if (type == null) {
throw new IllegalArgumentException("Unknown data component type " + key.asString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -49,6 +51,7 @@
@Mixin(CommandSourceStack.class)
public abstract class CommandSourceStackMixin implements AdventureCommandSourceStackInternal {
// @formatter:off
@Shadow @Final private Entity entity;
@Shadow @Final private CommandSource source;
@Shadow @Final private boolean silent;
@Shadow @Final private MinecraftServer server;
Expand Down Expand Up @@ -88,7 +91,7 @@ public void sendFailure(final @NotNull Component text) {
throw new IllegalStateException("Cannot use adventure operations without an available server!");
}
this.adventure$controller = MinecraftServerAudiences.of(this.server);
this.adventure$out = this.adventure$controller.audience(this.source);
this.adventure$out = this.entity instanceof final ServerPlayer ply && ply.commandSource() == this.source ? this.adventure$controller.audience(ply) : this.adventure$controller.audience(this.source);
}
return this.adventure$out;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected ServerPlayerMixin(final EntityType<? extends LivingEntity> entityType,
// This is just setting it to the default en_us, to avoid event calls if it doesn't change (this is the reason for our target not being TAIL)
this.adventure$locale = LocaleHolderBridge.toLocale(this.language);

this.adventure$backing = MinecraftServerAudiences.of(this.server).audience(this);
this.adventure$backing = MinecraftServerAudiences.of(this.server).audience((ServerPlayer) (Object) this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class EntityMixin implements Sound.Emitter, EntityHoverEventSour
@Override
public @NotNull HoverEvent<ShowEntity> asHoverEvent(final @NotNull UnaryOperator<ShowEntity> op) {
final Key entityType = (Key) (Object) this.level.registryAccess()
.registryOrThrow(Registries.ENTITY_TYPE)
.lookupOrThrow(Registries.ENTITY_TYPE)
.getKey(this.shadow$getType());

final ShowEntity data = HoverEvent.ShowEntity.showEntity(
Expand Down
4 changes: 2 additions & 2 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ config="adventure-platform-neoforge.mixins.json"
[[dependencies.adventure_platform_neoforge]]
modId="neoforge"
type="required"
versionRange="[21.0.0-beta,)"
versionRange="[21.2.0-beta,)"
ordering="NONE"
side="BOTH"

[[dependencies.adventure_platform_neoforge]]
modId="minecraft"
type="required"
versionRange="[1.21,1.21.1)"
versionRange="[1.21.2,1.22)"
ordering="NONE"
side="BOTH"
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(TitleScreen.class)
abstract class TitleScreenMixin extends Screen {
protected TitleScreenMixin(final Component title) {
super(title);
}

@Inject(method = "createNormalMenuOptions(II)V", at = @At("HEAD"))
void addMenuOptions(final int y, final int rowHeight, final CallbackInfo ci) {
@Inject(method = "createNormalMenuOptions(II)I", at = @At("HEAD"))
void addMenuOptions(final int y, final int rowHeight, final CallbackInfoReturnable<Integer> cir) {
final Component nativeText = MinecraftClientAudiences.of().asNative(
net.kyori.adventure.text.Component.translatable("menu.singleplayer", TextColor.color(0x9A40D2))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ config="adventure-platform-neoforge-tester.mixins.json"
[[dependencies.adventure_platform_neoforge_tester]]
modId="neoforge"
type="required"
versionRange="[21.0.0-beta,)"
versionRange="[21.2.0-beta,)"
ordering="NONE"
side="BOTH"

[[dependencies.adventure_platform_neoforge_tester]]
modId="minecraft"
type="required"
versionRange="[1.21,1.21.1)"
versionRange="[1.21.2,1.22)"
ordering="NONE"
side="BOTH"

Expand Down
31 changes: 18 additions & 13 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pluginManagement {

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("fabric-loom") version "1.8.6"
id("net.neoforged.moddev.repositories") version "1.0.20"
id("fabric-loom") version "1.8.10"
id("net.neoforged.moddev.repositories") version "1.0.21"
}

rootProject.name = "adventure-platform-mod-parent"
Expand All @@ -46,19 +46,24 @@ dependencyResolutionManagement {
}
}

setOf("fabric", "neoforge", "mod-shared").forEach {
include(it)
findProject(":$it")?.name = "adventure-platform-$it"
fun includeAndRename(path: String, name: String? = null) {
include(path)
findProject(":$path")?.name = "adventure-platform-${name ?: path.replace(":", "-")}"
}

include(":adventure-platform-fabric:mod-shared-repack")
findProject(":adventure-platform-fabric:mod-shared-repack")?.name = "adventure-platform-mod-shared-fabric-repack"

include(":adventure-platform-neoforge:tester")
findProject(":adventure-platform-neoforge:tester")?.name = "adventure-platform-neoforge-tester"

include(":adventure-platform-neoforge:services")
findProject(":adventure-platform-neoforge:services")?.name = "adventure-platform-neoforge-services"
// Common
includeAndRename("mod-shared")

include(":test-resources")
findProject(":test-resources")?.projectDir = file("mod-shared/test-resources")

// Fabric
includeAndRename("fabric")
includeAndRename("adventure-platform-fabric:mod-shared-repack", "mod-shared-fabric-repack")

// NeoForge

includeAndRename("neoforge")
includeAndRename("adventure-platform-neoforge:tester", "neoforge-tester")
includeAndRename("adventure-platform-neoforge:services", "neoforge-services")

0 comments on commit 2a39f4b

Please sign in to comment.