diff --git a/build.gradle.kts b/build.gradle.kts index 0989d7f74..1939dd3ec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,6 @@ import net.fabricmc.loom.build.nesting.IncludedJarFactory import net.fabricmc.loom.build.nesting.JarNester import net.fabricmc.loom.util.Constants -import net.fabricmc.loom.util.GroovyXmlUtil import org.apache.commons.codec.digest.DigestUtils import org.eclipse.jgit.api.Git import java.util.* @@ -46,7 +45,6 @@ val upstreamVersion = version ext["upstreamVersion"] = upstreamVersion -group = "org.sinytra" version = "$upstreamVersion+$implementationVersion+$versionMc" println("Version: $version") @@ -60,6 +58,8 @@ allprojects { apply(plugin = "java-library") apply(plugin = "dev.architectury.loom") + group = "org.sinytra.forgified-fabric-api" + java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) withSourcesJar() @@ -125,7 +125,7 @@ allprojects { dependencies { // Include Forgified Fabric Loader - include("org.sinytra:fabric-loader:$versionForgifiedFabricLoader:full") + include("org.sinytra:forgified-fabric-loader:$versionForgifiedFabricLoader:full") } tasks { @@ -153,10 +153,6 @@ allprojects { apply(plugin = "ffapi.neo-entrypoint") apply(plugin = "ffapi.package-info") - if (!META_PROJECTS.contains(name) && project != rootProject) { -// apply(plugin = "ffapi.neo-compat") TODO - } - allprojects.forEach { p -> if (!META_PROJECTS.contains(p.name)) { loom.mods.register(p.name) { @@ -178,9 +174,7 @@ allprojects { publishing { publications { register("mavenJava") { - pom { -// addPomMetadataInformation(project, pom) TODO - } + from(components["java"]) } } } @@ -193,31 +187,12 @@ dependencies { return@forEach } - api(project(proj.path, "namedElements")) + include(api(project(proj.path, "namedElements"))!!) "testmodImplementation"(proj.sourceSets.getByName("testmod").output) } } } -publishing { - publications { - named("mavenJava") { - from(components["java"]) - - pom.withXml { - val depsNode = GroovyXmlUtil.getOrCreateNode(asNode(), "dependencies") - rootProject.configurations.include.get().dependencies.forEach { - val depNode = depsNode.appendNode("dependency") - depNode.appendNode("groupId", it.group) - depNode.appendNode("artifactId", it.name) - depNode.appendNode("version", it.version) - depNode.appendNode("scope", "compile") - } - } - } - } -} - val git: Git? = runCatching { Git.open(rootDir) }.getOrNull() fun getSubprojectVersion(project: Project): String { @@ -245,24 +220,6 @@ fun moduleDependencies(project: Project, depNames: List) { api(it) } } - - // As we manually handle the maven artifacts, we need to also manually specify the deps. - project.publishing { - publications { - named("mavenJava") { - pom.withXml { - val depsNode = asNode().appendNode("dependencies") - deps.forEach { - val depNode = depsNode.appendNode("dependency") - depNode.appendNode("groupId", it.group) - depNode.appendNode("artifactId", it.name) - depNode.appendNode("version", it.version) - depNode.appendNode("scope", "compile") - } - } - } - } - } } fun testDependencies(project: Project, depNames: List) { diff --git a/buildSrc/src/main/kotlin/ffapi.neo-compat.gradle.kts b/buildSrc/src/main/kotlin/ffapi.neo-compat.gradle.kts deleted file mode 100644 index b9b69226a..000000000 --- a/buildSrc/src/main/kotlin/ffapi.neo-compat.gradle.kts +++ /dev/null @@ -1,101 +0,0 @@ -import net.fabricmc.loom.LoomGradleExtension -import net.fabricmc.loom.api.LoomGradleExtensionAPI -import net.fabricmc.loom.api.mappings.layered.MappingsNamespace -import net.fabricmc.loom.task.RemapJarTask -import java.io.FileOutputStream - -val versionMc: String by rootProject -val upstreamVersion: String by rootProject.ext -val versionFabricLoader: String by rootProject -val versionJCC: String by rootProject - -val loom = extensions.getByType() as LoomGradleExtension - -val apiLibs: Configuration by configurations.creating { - extendsFrom(configurations.getByName("api")) - isCanBeResolved = true -} -val baseLib: Configuration by configurations.creating -val referenceApi: Configuration by configurations.creating -val jarCompatChecker: Configuration by configurations.creating - -dependencies { - baseLib("net.fabricmc:fabric-loader:$versionFabricLoader") - - referenceApi("net.fabricmc.fabric-api:fabric-api:$upstreamVersion+$versionMc") - referenceApi("net.fabricmc.fabric-api:fabric-api-deprecated:$upstreamVersion+$versionMc") - - jarCompatChecker("net.neoforged:jarcompatibilitychecker:$versionJCC:all") -} - -val compareJar by tasks.registering(Jar::class) { - from(zipTree(tasks.named("jar").flatMap { it.archiveFile })) - archiveClassifier = "compare" - destinationDirectory = project.layout.buildDirectory.dir("devlibs") -} - -val remapReferenceApi by tasks.creating(RemapJarTask::class) { - group = "sinytra" - outputs.cacheIf { true } - inputFile.fileProvider(provider { - val deps = referenceApi.resolvedConfiguration - val referenceDep = - deps.lenientConfiguration.allModuleDependencies.find { it.moduleGroup == "net.fabricmc.fabric-api" && it.moduleName == project.name } - return@provider referenceDep!!.allModuleArtifacts.first().file - }) - sourceNamespace = MappingsNamespace.INTERMEDIARY.toString() - targetNamespace = MappingsNamespace.NAMED.toString() - destinationDirectory = project.layout.buildDirectory.dir(name) - classpath.from(loom.getMinecraftJarsCollection(MappingsNamespace.INTERMEDIARY)) -} - -val checkReferenceCompatibility by tasks.registering(JavaExec::class) { - group = "verification" - - classpath(jarCompatChecker) - mainClass = "net.neoforged.jarcompatibilitychecker.ConsoleTool" - args("--api", "--annotation-check-mode", "warn_added", "--internal-ann-mode", "skip") - val outputLog = project.layout.buildDirectory.dir(name).map { it.file("output.log") } - inputs.file(remapReferenceApi.inputFile) - .withPropertyName("inputFile") - .withPathSensitivity(PathSensitivity.RELATIVE) - outputs.file(outputLog) - .withPropertyName("outputFile") - outputs.cacheIf { true } - doFirst { - standardOutput = FileOutputStream(outputLog.get().asFile) - } -} - -afterEvaluate { - tasks.configureEach { - if (name == "prepareRemapReferenceApi") { - doFirst { - loom.mixin.useLegacyMixinAp = false - } - doLast { - loom.mixin.useLegacyMixinAp = true - } - } - } - checkReferenceCompatibility.configure { - dependsOn(compareJar, remapReferenceApi) - args( - "--base-jar", - remapReferenceApi.archiveFile.get().asFile.absolutePath, - "--input-jar", - compareJar.get().archiveFile.get().asFile.absolutePath - ) - (configurations.getByName("minecraftNamedCompile") + configurations.getByName("apiLibs")).forEach { - args( - "--lib", - it.absolutePath - ) - } - baseLib.resolve().forEach { args("--base-lib", it.absolutePath) } - } -} - -tasks.named("check") { - dependsOn(checkReferenceCompatibility) -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts b/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts index 6b1eff325..04a4d84d6 100644 --- a/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts +++ b/buildSrc/src/main/kotlin/ffapi.neo-setup.gradle.kts @@ -34,17 +34,10 @@ val testmod: SourceSet by sourceSets.creating { } dependencies { - // TODO Update gradle module metadata in FFLoader to avoid this - "compileOnly"("org.sinytra:fabric-loader:$versionForgifiedFabricLoader") - "runtimeOnly"("org.sinytra:fabric-loader:$versionForgifiedFabricLoader:full") { - isTransitive = false - } + "implementation"("org.sinytra:forgified-fabric-loader:$versionForgifiedFabricLoader") "testmodImplementation"(mainSourceSet.output) - "testmodCompileOnly"("org.sinytra:fabric-loader:$versionForgifiedFabricLoader") - "testmodRuntimeOnly"("org.sinytra:fabric-loader:$versionForgifiedFabricLoader:full") { - isTransitive = false - } + "testmodImplementation"("org.sinytra:forgified-fabric-loader:$versionForgifiedFabricLoader") if (project.name != "fabric-gametest-api-v1") { "testmodImplementation"(project(":fabric-gametest-api-v1", "namedElements")) @@ -68,8 +61,6 @@ loom.apply { configureEach { isIdeConfigGenerated = project.rootProject == project property("mixin.debug", "true") - // FIXME Set this from fabric-api-base as ResourcePackProfileMixin fails otherwise - property("mixin.initialiserInjectionMode", "safe") } create("gametest") { diff --git a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/TillableBlockRegistry.java b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/TillableBlockRegistry.java index 92b928200..0322a5dc8 100644 --- a/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/TillableBlockRegistry.java +++ b/fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry/TillableBlockRegistry.java @@ -23,7 +23,6 @@ import java.util.function.Predicate; import com.mojang.datafixers.util.Pair; -import net.fabricmc.fabric.mixin.content.registry.HoeItemAccessor; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.HoeItem; import net.minecraft.world.item.context.UseOnContext; @@ -32,7 +31,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.neoforge.common.ToolActions; +import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.event.level.BlockEvent; /** @@ -93,7 +92,7 @@ public static void register(Block input, Predicate usagePredicate, @SubscribeEvent static void modify(BlockEvent.BlockToolModificationEvent event) { - if (event.getToolAction() == ToolActions.HOE_TILL && event.getHeldItemStack().canPerformAction(ToolActions.HOE_TILL)) { + if (event.getItemAbility() == ItemAbilities.HOE_TILL && event.getHeldItemStack().canPerformAction(ItemAbilities.HOE_TILL)) { var modified = TILLABLES.get(event.getState().getBlock()); if (modified != null && modified.getFirst().test(event.getContext())) { if (!event.isSimulated() && !event.getLevel().isClientSide()) { diff --git a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/impl/entity/event/EntityEventHooks.java b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/impl/entity/event/EntityEventHooks.java index c0e9fc1f9..488f91bf3 100644 --- a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/impl/entity/event/EntityEventHooks.java +++ b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/impl/entity/event/EntityEventHooks.java @@ -26,8 +26,8 @@ import net.minecraft.world.entity.player.Player; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.neoforge.event.entity.living.LivingAttackEvent; import net.neoforged.neoforge.event.entity.living.LivingConversionEvent; +import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent; import net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent; import net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; @@ -36,7 +36,7 @@ public final class EntityEventHooks { @SubscribeEvent - public static void onLivingAttack(LivingAttackEvent event) { + public static void onLivingAttack(LivingIncomingDamageEvent event) { LivingEntity entity = event.getEntity(); if (!entity.level().isClientSide() && !ServerLivingEntityEvents.ALLOW_DAMAGE.invoker().allowDamage(entity, event.getSource(), event.getAmount())) { event.setCanceled(true); diff --git a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java index 529199aa2..831e424f0 100644 --- a/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java +++ b/fabric-entity-events-v1/src/main/java/net/fabricmc/fabric/mixin/entity/event/LivingEntityMixin.java @@ -74,13 +74,6 @@ boolean beforeEntityKilled(LivingEntity livingEntity, DamageSource source, float return isDeadOrDying() && ServerLivingEntityEvents.ALLOW_DEATH.invoker().allowDeath(livingEntity, source, amount); } - @Inject(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isSleeping()Z"), cancellable = true) - private void beforeDamage(DamageSource source, float amount, CallbackInfoReturnable cir) { - if (!ServerLivingEntityEvents.ALLOW_DAMAGE.invoker().allowDamage((LivingEntity) (Object) this, source, amount)) { - cir.setReturnValue(false); - } - } - @Inject(method = "startSleeping", at = @At("RETURN")) private void onSleep(BlockPos pos, CallbackInfo info) { EntitySleepEvents.START_SLEEPING.invoker().onStartSleeping((LivingEntity) (Object) this, pos); diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/GameRuleCommandVisitorMixin.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/GameRuleCommandVisitorMixin.java index 65c68c9f3..afebe49cc 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/GameRuleCommandVisitorMixin.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/mixin/gamerule/GameRuleCommandVisitorMixin.java @@ -31,7 +31,7 @@ @Mixin(targets = "net/minecraft/server/commands/GameRuleCommand$1") public abstract class GameRuleCommandVisitorMixin { @Final - @Shadow + @Shadow(aliases = {"val$literalargumentbuilder"}) LiteralArgumentBuilder val$base; @Inject(at = @At("HEAD"), method = "visit(Lnet/minecraft/world/level/GameRules$Key;Lnet/minecraft/world/level/GameRules$Type;)V", cancellable = true) diff --git a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java index 4c6e5a6d8..7c9bb523e 100644 --- a/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java +++ b/fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/impl/itemgroup/ItemGroupEventsImpl.java @@ -16,18 +16,18 @@ package net.fabricmc.fabric.impl.itemgroup; -import java.util.HashMap; -import java.util.Map; - -import org.jetbrains.annotations.Nullable; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class ItemGroupEventsImpl { - private static final Map, Event> ITEM_GROUP_EVENT_MAP = new HashMap<>(); + private static final Map, Event> ITEM_GROUP_EVENT_MAP = new ConcurrentHashMap<>(); public static Event getOrCreateModifyEntriesEvent(ResourceKey registryKey) { return ITEM_GROUP_EVENT_MAP.computeIfAbsent(registryKey, (g -> createModifyEvent())); diff --git a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/EntityRenderersMixin.java b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/EntityRenderersMixin.java index bce93f4f3..e04ae0d05 100644 --- a/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/EntityRenderersMixin.java +++ b/fabric-rendering-v1/src/client/java/net/fabricmc/fabric/mixin/client/rendering/EntityRenderersMixin.java @@ -34,7 +34,7 @@ public abstract class EntityRenderersMixin { // synthetic lambda in reloadEntityRenderers @SuppressWarnings({"unchecked", "rawtypes"}) - @Redirect(method = "lambda$createEntityRenderers$26", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRendererProvider;create(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;)Lnet/minecraft/client/renderer/entity/EntityRenderer;")) + @Redirect(method = {"lambda$createEntityRenderers$26", "lambda$createEntityRenderers$2"}, require = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRendererProvider;create(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;)Lnet/minecraft/client/renderer/entity/EntityRenderer;")) private static EntityRenderer createEntityRenderer(EntityRendererProvider entityRendererFactory, EntityRendererProvider.Context context, ImmutableMap.Builder builder, EntityRendererProvider.Context context2, EntityType entityType) { EntityRenderer entityRenderer = entityRendererFactory.create(context); @@ -48,7 +48,7 @@ private static EntityRenderer createEntityRenderer(EntityRendererProvider // private static synthetic method_32175(Lcom/google/common/collect/ImmutableMap$Builder;Lnet/minecraft/class_5617$class_5618;Ljava/lang/String;Lnet/minecraft/class_5617;)V @SuppressWarnings({"unchecked", "rawtypes"}) - @Redirect(method = "lambda$createPlayerRenderers$27", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRendererProvider;create(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;)Lnet/minecraft/client/renderer/entity/EntityRenderer;")) + @Redirect(method = {"lambda$createPlayerRenderers$27", "lambda$createPlayerRenderers$3"}, require = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRendererProvider;create(Lnet/minecraft/client/renderer/entity/EntityRendererProvider$Context;)Lnet/minecraft/client/renderer/entity/EntityRenderer;")) private static EntityRenderer createPlayerEntityRenderer(EntityRendererProvider playerEntityRendererFactory, EntityRendererProvider.Context context) { EntityRenderer entityRenderer = playerEntityRendererFactory.create(context); diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileMixin.java index 1ce74fd7d..ec8eec408 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileMixin.java @@ -16,14 +16,17 @@ package net.fabricmc.fabric.mixin.resource.loader; +import java.util.List; import java.util.Set; import java.util.function.Predicate; +import net.minecraft.server.packs.PackSelectionConfig; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; 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; import net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile; import net.fabricmc.fabric.impl.resource.loader.ResourcePackSourceTracker; @@ -44,11 +47,16 @@ abstract class ResourcePackProfileMixin implements FabricResourcePackProfile { @Unique private static final Predicate> DEFAULT_PARENT_PREDICATE = parents -> true; @Unique - private Predicate> parentsPredicate = DEFAULT_PARENT_PREDICATE; + private Predicate> parentsPredicate; @Shadow public abstract PackLocationInfo location(); + @Inject(method = "(Lnet/minecraft/server/packs/PackLocationInfo;Lnet/minecraft/server/packs/repository/Pack$ResourcesSupplier;Lnet/minecraft/server/packs/repository/Pack$Metadata;Lnet/minecraft/server/packs/PackSelectionConfig;Ljava/util/List;)V", at = @At("TAIL")) + private void onInit(PackLocationInfo arg, Pack.ResourcesSupplier arg2, Pack.Metadata arg3, PackSelectionConfig arg4, List children, CallbackInfo ci) { + this.parentsPredicate = DEFAULT_PARENT_PREDICATE; + } + @Inject(method = "open", at = @At("RETURN")) private void onCreateResourcePack(CallbackInfoReturnable info) { ResourcePackSourceTracker.setSource(info.getReturnValue(), location().source()); diff --git a/ffapi.gradle.properties b/ffapi.gradle.properties index cf57b9c9b..67d14abd1 100644 --- a/ffapi.gradle.properties +++ b/ffapi.gradle.properties @@ -4,7 +4,6 @@ fabric.loom.dontRemap=true implementationVersion=2.0.0 versionMc=1.21 -versionForge=21.0.10-beta -versionForgifiedFabricLoader=2.6.14+0.15.10+1.21 -versionJCC=0.1.6 +versionForge=21.0.57-beta +versionForgifiedFabricLoader=2.5.24+0.15.10+1.21 versionFabricLoader=0.15.10