diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 4853b6a15..6393c5701 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,8 +7,8 @@ plugins { repositories { gradlePluginPortal() mavenCentral() - maven("https://maven.minecraftforge.net/") { - name = "MinecraftForge" + maven("https://maven.neoforged.net/releases/") { + name = "NeoForged" } maven("https://maven.architectury.dev/") { name = "Architectury" diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt index 8dd2dbd9d..8398fa57e 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/subproject/SubprojectPlugin.kt @@ -53,6 +53,8 @@ class SubprojectPlugin: Plugin { val loom = project.the() loom.silentMojangMappingsLicense() + // FIXME y tho? :( + loom.mixin.useLegacyMixinAp = true loom.mixin.defaultRefmapName = "flywheel.refmap.json" } @@ -182,6 +184,6 @@ val processResourcesExpandProperties = listOf( "minecraft_semver_version_range", "minecraft_maven_version_range", "fabric_api_version_range", - "forge_version_range", + "neoforge_version_range", ) diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java index 9cbcf2790..dadebbbf1 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/LevelRendererMixin.java @@ -102,7 +102,7 @@ abstract class LevelRendererMixin { flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN); } - @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER)) + @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderSectionLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", ordinal = 6, shift = Shift.AFTER)) private void flywheel$onStage$afterTranslucentTerrain(CallbackInfo ci) { flywheel$dispatch(RenderStage.AFTER_TRANSLUCENT_TERRAIN); } @@ -113,6 +113,7 @@ abstract class LevelRendererMixin { flywheel$dispatch(RenderStage.AFTER_PARTICLES); } + //fixme take a look over if this is still needed @Group(name = "onStage$afterParticles") @Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;)V", shift = Shift.AFTER)) private void flywheel$onStage$afterParticles$forge(CallbackInfo ci) { diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/visualmanage/RebuildTaskMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/visualmanage/RebuildTaskMixin.java index c55c532fa..cd98fb932 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/visualmanage/RebuildTaskMixin.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/visualmanage/RebuildTaskMixin.java @@ -9,9 +9,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import dev.engine_room.flywheel.lib.visual.VisualizationHelper; import net.minecraft.world.level.block.entity.BlockEntity; -@Mixin(targets = "net.minecraft.client.renderer.chunk.ChunkRenderDispatcher$RenderChunk$RebuildTask") +@Mixin(targets = "net.minecraft.client.renderer.chunk.SectionRenderDispatcher$RenderSection$RebuildTask") abstract class RebuildTaskMixin { - @Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "handleBlockEntity(Lnet/minecraft/client/renderer/chunk/SectionRenderDispatcher$RenderSection$RebuildTask$CompileResults;Lnet/minecraft/world/level/block/entity/BlockEntity;)V", at = @At("HEAD"), cancellable = true) private void flywheel$tryAddBlockEntity(@Coerce Object compileResults, BlockEntity blockEntity, CallbackInfo ci) { if (VisualizationHelper.tryAddBlockEntity(blockEntity)) { ci.cancel(); diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java index f96a68595..dcab8eeec 100644 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java +++ b/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java @@ -7,6 +7,7 @@ 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; +import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -30,14 +31,14 @@ abstract class MinecraftMixin { FabricFlwConfig.INSTANCE.load(); } - @Inject(method = "method_24040", at = @At("HEAD")) - private void flywheel$onEndInitialResourceReload(Optional error, CallbackInfo ci) { + @Inject(method = "method_53522", at = @At("HEAD")) + private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional error, CallbackInfo ci) { EndClientResourceReloadCallback.EVENT.invoker() .onEndClientResourceReload((Minecraft) (Object) this, resourceManager, true, error); } @Inject(method = "method_24228", at = @At("HEAD")) - private void flywheel$onEndManualResourceReload(boolean recovery, CompletableFuture future, + private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture future, Optional error, CallbackInfo ci) { EndClientResourceReloadCallback.EVENT.invoker() .onEndClientResourceReload((Minecraft) (Object) this, resourceManager, false, error); diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/fabric/MinecraftMixin.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/fabric/MinecraftMixin.java index e7d8b7af2..6ff63b33d 100644 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/fabric/MinecraftMixin.java +++ b/fabric/src/main/java/dev/engine_room/flywheel/impl/mixin/fabric/MinecraftMixin.java @@ -22,7 +22,7 @@ abstract class MinecraftMixin { } } - @Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD")) + @Inject(method = "clearClientLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD")) private void flywheel$onClearLevel(CallbackInfo ci) { if (level != null) { LevelAttached.invalidateLevel(level); diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 5f51cc55e..c2779acd8 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -61,12 +61,6 @@ defaultPackageInfos { } loom { - forge { - mixinConfig("flywheel.backend.mixins.json") - mixinConfig("flywheel.impl.mixins.json") - mixinConfig("flywheel.impl.sodium.mixins.json") - } - runs { configureEach { property("forge.logging.markers", "") @@ -75,8 +69,12 @@ loom { } } +repositories { + maven("https://maven.neoforged.net/releases/") +} + dependencies { - forge("net.minecraftforge:forge:${property("minecraft_version")}-${property("forge_version")}") + neoForge("net.neoforged:neoforge:${property("neoforge_version")}") modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}") modCompileOnly("maven.modrinth:oculus:${property("oculus_version")}") diff --git a/forge/gradle.properties b/forge/gradle.properties index a58ba1416..2e6ed7676 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -1 +1 @@ -loom.platform = forge +loom.platform = neoforge diff --git a/forge/src/api/java/dev/engine_room/flywheel/api/event/BeginFrameEvent.java b/forge/src/api/java/dev/engine_room/flywheel/api/event/BeginFrameEvent.java index 5da48c419..d96741099 100644 --- a/forge/src/api/java/dev/engine_room/flywheel/api/event/BeginFrameEvent.java +++ b/forge/src/api/java/dev/engine_room/flywheel/api/event/BeginFrameEvent.java @@ -1,6 +1,6 @@ package dev.engine_room.flywheel.api.event; -import net.minecraftforge.eventbus.api.Event; +import net.neoforged.bus.api.Event; /** * This event is posted to the Forge event bus. diff --git a/forge/src/api/java/dev/engine_room/flywheel/api/event/EndClientResourceReloadEvent.java b/forge/src/api/java/dev/engine_room/flywheel/api/event/EndClientResourceReloadEvent.java index 8e102c4ba..bacc99531 100644 --- a/forge/src/api/java/dev/engine_room/flywheel/api/event/EndClientResourceReloadEvent.java +++ b/forge/src/api/java/dev/engine_room/flywheel/api/event/EndClientResourceReloadEvent.java @@ -4,8 +4,8 @@ import java.util.Optional; import net.minecraft.client.Minecraft; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.event.IModBusEvent; +import net.neoforged.bus.api.Event; +import net.neoforged.fml.event.IModBusEvent; /** * This event is posted to mod event buses. diff --git a/forge/src/api/java/dev/engine_room/flywheel/api/event/ReloadLevelRendererEvent.java b/forge/src/api/java/dev/engine_room/flywheel/api/event/ReloadLevelRendererEvent.java index e74e792c9..a6a9ed00c 100644 --- a/forge/src/api/java/dev/engine_room/flywheel/api/event/ReloadLevelRendererEvent.java +++ b/forge/src/api/java/dev/engine_room/flywheel/api/event/ReloadLevelRendererEvent.java @@ -1,9 +1,10 @@ package dev.engine_room.flywheel.api.event; +import net.neoforged.bus.api.Event; + import org.jetbrains.annotations.Nullable; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraftforge.eventbus.api.Event; /** * This event is posted to the Forge event bus. diff --git a/forge/src/api/java/dev/engine_room/flywheel/api/event/RenderStageEvent.java b/forge/src/api/java/dev/engine_room/flywheel/api/event/RenderStageEvent.java index 4b0ec8254..d9c27aad7 100644 --- a/forge/src/api/java/dev/engine_room/flywheel/api/event/RenderStageEvent.java +++ b/forge/src/api/java/dev/engine_room/flywheel/api/event/RenderStageEvent.java @@ -1,5 +1,7 @@ package dev.engine_room.flywheel.api.event; +import net.neoforged.bus.api.Event; + import org.joml.Matrix4f; import com.mojang.blaze3d.vertex.PoseStack; @@ -7,7 +9,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.RenderBuffers; -import net.minecraftforge.eventbus.api.Event; /** * This event is posted to the Forge event bus. diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/BakedModelBufferer.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/BakedModelBufferer.java index 50162d4b9..4453ec5b8 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/BakedModelBufferer.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/BakedModelBufferer.java @@ -3,6 +3,9 @@ package dev.engine_room.flywheel.lib.model.baked; import java.util.Iterator; import java.util.function.Function; +import net.neoforged.neoforge.client.ChunkRenderTypeSet; +import net.neoforged.neoforge.client.model.data.ModelData; + import org.jetbrains.annotations.Nullable; import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer; @@ -20,8 +23,6 @@ import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; -import net.minecraftforge.client.ChunkRenderTypeSet; -import net.minecraftforge.client.model.data.ModelData; final class BakedModelBufferer { static final RenderType[] CHUNK_LAYERS = RenderType.chunkBufferLayers().toArray(RenderType[]::new); diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBakedModelBuilder.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBakedModelBuilder.java index 10714e848..3d9cf4885 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBakedModelBuilder.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBakedModelBuilder.java @@ -2,6 +2,8 @@ package dev.engine_room.flywheel.lib.model.baked; import java.util.function.BiFunction; +import net.neoforged.neoforge.client.model.data.ModelData; + import org.jetbrains.annotations.Nullable; import com.mojang.blaze3d.vertex.PoseStack; @@ -16,7 +18,6 @@ import net.minecraft.client.resources.model.BakedModel; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.ModelData; public final class ForgeBakedModelBuilder extends BakedModelBuilder { @Nullable diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBlockModelBuilder.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBlockModelBuilder.java index 4e1d9df82..d09730dc7 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBlockModelBuilder.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeBlockModelBuilder.java @@ -2,6 +2,8 @@ package dev.engine_room.flywheel.lib.model.baked; import java.util.function.BiFunction; +import net.neoforged.neoforge.client.model.data.ModelData; + import org.jetbrains.annotations.Nullable; import com.mojang.blaze3d.vertex.PoseStack; @@ -14,7 +16,6 @@ import dev.engine_room.flywheel.lib.model.SimpleModel; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.client.model.data.ModelData; public final class ForgeBlockModelBuilder extends BlockModelBuilder { @Nullable diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeMultiBlockModelBuilder.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeMultiBlockModelBuilder.java index 183e03d84..9bbf47079 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeMultiBlockModelBuilder.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/ForgeMultiBlockModelBuilder.java @@ -3,6 +3,8 @@ package dev.engine_room.flywheel.lib.model.baked; import java.util.function.BiFunction; import java.util.function.Function; +import net.neoforged.neoforge.client.model.data.ModelData; + import org.jetbrains.annotations.Nullable; import com.mojang.blaze3d.vertex.PoseStack; @@ -15,7 +17,6 @@ import dev.engine_room.flywheel.lib.model.SimpleModel; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraftforge.client.model.data.ModelData; public final class ForgeMultiBlockModelBuilder extends MultiBlockModelBuilder { @Nullable diff --git a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/PartialModelEventHandler.java b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/PartialModelEventHandler.java index 5c490dcd7..f84fc5ff3 100644 --- a/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/PartialModelEventHandler.java +++ b/forge/src/lib/java/dev/engine_room/flywheel/lib/model/baked/PartialModelEventHandler.java @@ -2,11 +2,12 @@ package dev.engine_room.flywheel.lib.model.baked; import java.util.Map; +import net.neoforged.neoforge.client.event.ModelEvent; + import org.jetbrains.annotations.ApiStatus; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.client.event.ModelEvent; @ApiStatus.Internal public final class PartialModelEventHandler { diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwCommands.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwCommands.java index 227973f4e..830c0fb0f 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwCommands.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwCommands.java @@ -15,9 +15,8 @@ import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.Entity; -import net.minecraftforge.client.event.RegisterClientCommandsEvent; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; +import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; +import net.neoforged.neoforge.common.ModConfigSpec; public final class FlwCommands { private FlwCommands() { @@ -26,7 +25,7 @@ public final class FlwCommands { public static void registerClientCommands(RegisterClientCommandsEvent event) { LiteralArgumentBuilder command = Commands.literal("flywheel"); - ConfigValue backendValue = ForgeFlwConfig.INSTANCE.client.backend; + ModConfigSpec.ConfigValue backendValue = ForgeFlwConfig.INSTANCE.client.backend; command.then(Commands.literal("backend") .executes(context -> { Backend backend = BackendManager.getBackend(); @@ -56,7 +55,7 @@ public final class FlwCommands { return Command.SINGLE_SUCCESS; }))); - BooleanValue limitUpdatesValue = ForgeFlwConfig.INSTANCE.client.limitUpdates; + ModConfigSpec.BooleanValue limitUpdatesValue = ForgeFlwConfig.INSTANCE.client.limitUpdates; command.then(Commands.literal("limitUpdates") .executes(context -> { if (limitUpdatesValue.get()) { diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java index 4ebf4532b..cddd85e4e 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java @@ -1,5 +1,7 @@ package dev.engine_room.flywheel.impl; +import net.neoforged.neoforge.common.NeoForge; + import org.jetbrains.annotations.Nullable; import dev.engine_room.flywheel.api.event.BeginFrameEvent; @@ -8,22 +10,21 @@ import dev.engine_room.flywheel.api.event.RenderContext; import dev.engine_room.flywheel.api.event.RenderStage; import dev.engine_room.flywheel.api.event.RenderStageEvent; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraftforge.common.MinecraftForge; public class FlwImplXplatImpl implements FlwImplXplat { @Override public void dispatchBeginFrameEvent(RenderContext context) { - MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(context)); + NeoForge.EVENT_BUS.post(new BeginFrameEvent(context)); } @Override public void dispatchReloadLevelRendererEvent(@Nullable ClientLevel level) { - MinecraftForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level)); + NeoForge.EVENT_BUS.post(new ReloadLevelRendererEvent(level)); } @Override public void dispatchRenderStageEvent(RenderContext context, RenderStage stage) { - MinecraftForge.EVENT_BUS.post(new RenderStageEvent(context, stage)); + NeoForge.EVENT_BUS.post(new RenderStageEvent(context, stage)); } @Override diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java index 7aa29a9b0..203460ef1 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwLibXplatImpl.java @@ -2,6 +2,9 @@ package dev.engine_room.flywheel.impl; import java.lang.reflect.Field; +import net.neoforged.fml.ModList; +import net.neoforged.fml.util.ObfuscationReflectionHelper; + import org.jetbrains.annotations.Nullable; import dev.engine_room.flywheel.lib.internal.FlwLibXplat; @@ -20,8 +23,6 @@ import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.util.ObfuscationReflectionHelper; public class FlwLibXplatImpl implements FlwLibXplat { @Override @@ -33,6 +34,7 @@ public class FlwLibXplatImpl implements FlwLibXplat { field.setAccessible(true); field.set(dispatcher, field.get(defaultDispatcher)); } + // fixme ~ is this still needed? neoforge uses mojmap at runtime ObfuscationReflectionHelper.setPrivateValue(BlockRenderDispatcher.class, dispatcher, new ModelBlockRenderer(Minecraft.getInstance().getBlockColors()), "f_110900_"); } catch (Exception e) { FlwImpl.LOGGER.error("Failed to initialize vanilla BlockRenderDispatcher!", e); diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java index 72e5ada1f..7eb1fd24f 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java @@ -1,5 +1,30 @@ package dev.engine_room.flywheel.impl; +import net.minecraft.core.registries.Registries; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.CrashReportCallables; +import net.neoforged.fml.DistExecutor; +import net.neoforged.fml.LogicalSide; +import net.neoforged.fml.ModLoadingContext; + +import net.neoforged.fml.common.Mod; + +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.common.NeoForge; + +import net.neoforged.neoforge.event.TickEvent; + +import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent; + +import net.neoforged.neoforge.event.entity.EntityLeaveLevelEvent; + +import net.neoforged.neoforge.event.level.LevelEvent; +import net.neoforged.neoforge.registries.RegisterEvent; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.jetbrains.annotations.UnknownNullability; @@ -41,7 +66,7 @@ public final class FlywheelForge { @UnknownNullability private static ArtifactVersion version; - public FlywheelForge() { + public FlywheelForge(IEventBus modEventBus) { ModLoadingContext modLoadingContext = ModLoadingContext.get(); version = modLoadingContext @@ -49,9 +74,7 @@ public final class FlywheelForge { .getModInfo() .getVersion(); - IEventBus forgeEventBus = MinecraftForge.EVENT_BUS; - IEventBus modEventBus = FMLJavaModLoadingContext.get() - .getModEventBus(); + IEventBus forgeEventBus = NeoForge.EVENT_BUS; ForgeFlwConfig.INSTANCE.registerSpecs(modLoadingContext); @@ -86,23 +109,23 @@ public final class FlywheelForge { forgeEventBus.addListener((CustomizeGuiOverlayEvent.DebugText e) -> { Minecraft minecraft = Minecraft.getInstance(); - if (!minecraft.options.renderDebug) { + if (!minecraft.getDebugOverlay().showDebugScreen()) { return; } FlwDebugInfo.addDebugInfo(minecraft, e.getRight()); }); - modEventBus.addListener((EndClientResourceReloadEvent e) -> BackendManagerImpl.onEndClientResourceReload(e.error().isPresent())); + modEventBus.addListener((EndClientResourceReloadEvent e) -> BackendManagerImpl.onEndClientResourceReload(e.error() != null)); modEventBus.addListener((FMLCommonSetupEvent e) -> { ArgumentTypeInfos.registerByClass(BackendArgument.class, BackendArgument.INFO); ArgumentTypeInfos.registerByClass(DebugModeArgument.class, DebugModeArgument.INFO); }); modEventBus.addListener((RegisterEvent e) -> { - if (e.getRegistryKey().equals(ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES)) { - e.register(ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES, Flywheel.rl("backend"), () -> BackendArgument.INFO); - e.register(ForgeRegistries.Keys.COMMAND_ARGUMENT_TYPES, Flywheel.rl("debug_mode"), () -> DebugModeArgument.INFO); + if (e.getRegistryKey().equals(Registries.COMMAND_ARGUMENT_TYPE)) { + e.register(Registries.COMMAND_ARGUMENT_TYPE, Flywheel.rl("backend"), () -> BackendArgument.INFO); + e.register(Registries.COMMAND_ARGUMENT_TYPE, Flywheel.rl("debug_mode"), () -> DebugModeArgument.INFO); } }); } diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/ForgeFlwConfig.java b/forge/src/main/java/dev/engine_room/flywheel/impl/ForgeFlwConfig.java index 69fd054c0..60832455d 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/ForgeFlwConfig.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/ForgeFlwConfig.java @@ -1,5 +1,9 @@ package dev.engine_room.flywheel.impl; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.config.ModConfig; +import net.neoforged.neoforge.common.ModConfigSpec; + import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; @@ -7,18 +11,15 @@ import dev.engine_room.flywheel.api.backend.Backend; import dev.engine_room.flywheel.api.backend.BackendManager; import net.minecraft.ResourceLocationException; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.config.ModConfig; public class ForgeFlwConfig implements FlwConfig { public static final ForgeFlwConfig INSTANCE = new ForgeFlwConfig(); public final ClientConfig client; - private final ForgeConfigSpec clientSpec; + private final ModConfigSpec clientSpec; private ForgeFlwConfig() { - Pair clientPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); + Pair clientPair = new ModConfigSpec.Builder().configure(ClientConfig::new); this.client = clientPair.getLeft(); clientSpec = clientPair.getRight(); } @@ -68,11 +69,11 @@ public class ForgeFlwConfig implements FlwConfig { } public static class ClientConfig { - public final ForgeConfigSpec.ConfigValue backend; - public final ForgeConfigSpec.BooleanValue limitUpdates; - public final ForgeConfigSpec.IntValue workerThreads; + public final ModConfigSpec.ConfigValue backend; + public final ModConfigSpec.BooleanValue limitUpdates; + public final ModConfigSpec.IntValue workerThreads; - private ClientConfig(ForgeConfigSpec.Builder builder) { + private ClientConfig(ModConfigSpec.Builder builder) { backend = builder.comment("Select the backend to use.") .define("backend", Backend.REGISTRY.getIdOrThrow(BackendManager.getDefaultBackend()).toString()); diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java b/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java index 99ca5d570..2305ba681 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java @@ -4,10 +4,13 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; +import net.neoforged.fml.ModLoader; + 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; +import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -17,12 +20,9 @@ import com.mojang.realmsclient.client.RealmsClient; import dev.engine_room.flywheel.api.event.EndClientResourceReloadEvent; import dev.engine_room.flywheel.impl.FlwImpl; import net.minecraft.client.Minecraft; -import net.minecraft.client.main.GameConfig; -import net.minecraft.server.packs.resources.ReloadInstance; import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraftforge.fml.ModLoader; -@Mixin(Minecraft.class) +@Mixin(value = Minecraft.class, remap = false) abstract class MinecraftMixin { @Shadow @Final @@ -35,13 +35,13 @@ abstract class MinecraftMixin { return arg0; } - @Inject(method = "lambda$new$5", at = @At("HEAD")) - private void flywheel$onEndInitialResourceReload(RealmsClient realmsClient, ReloadInstance reloadInstance, GameConfig gameConfig, Optional error, CallbackInfo ci) { + @Inject(method = "lambda$new$7", at = @At("HEAD")) + private void flywheel$onEndInitialResourceReload(@Coerce Object minecraft$gameloadcookie, Optional error, CallbackInfo ci) { ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error)); } - @Inject(method = "lambda$reloadResourcePacks$28", at = @At("HEAD")) - private void flywheel$onEndManualResourceReload(boolean recovery, CompletableFuture future, Optional error, CallbackInfo ci) { + @Inject(method = "lambda$reloadResourcePacks$39", at = @At("HEAD")) + private void flywheel$onEndManualResourceReload(boolean bl, @Coerce Object minecraft$gameloadcookie, CompletableFuture completablefuture, Optional error, CallbackInfo ci) { ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error)); } } diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/SodiumMixinPlugin.java b/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/SodiumMixinPlugin.java index 1048d91fd..5ee303ff0 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/SodiumMixinPlugin.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/mixin/sodium/SodiumMixinPlugin.java @@ -4,14 +4,14 @@ import java.util.List; import java.util.Set; import java.util.function.Supplier; +import net.neoforged.fml.loading.LoadingModList; + import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; import com.google.common.base.Suppliers; -import net.minecraftforge.fml.loading.LoadingModList; - public class SodiumMixinPlugin implements IMixinConfigPlugin { private static final Supplier IS_SODIUM_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById("rubidium") != null); diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 2dc330582..546372adf 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -14,22 +14,29 @@ authors = "Jozufozu, PepperCode1" displayURL = "${mod_homepage}" displayTest = "IGNORE_ALL_VERSION" +[[mixins]] +config = "flywheel.backend.mixins.json" +[[mixins]] +config = "flywheel.impl.mixins.json" +[[mixins]] +config = "flywheel.impl.sodium.mixins.json" + [[dependencies.${mod_id}]] modId = "minecraft" -mandatory = true +type = "required" versionRange = "${minecraft_maven_version_range}" side = "CLIENT" [[dependencies.${mod_id}]] -modId = "forge" -mandatory = true -versionRange = "${forge_version_range}" +modId = "neoforge" +type = "required" +versionRange = "${neoforge_version_range}" side = "CLIENT" +# Breaks dependency [[dependencies.${mod_id}]] -# This replicates a "breaks" dependency. -# There's a mixin crash with Rubidium <0.7.0. modId = "rubidium" -mandatory = false +type = "incompatible" +reason = "mixin crash with any version of rubidium under 0.7.0" versionRange = "[0.7.0,)" side = "CLIENT" diff --git a/gradle.properties b/gradle.properties index 431fbe0d6..db47dc3ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,22 +12,21 @@ mod_issues = https://github.com/Jozufozu/Flywheel/issues mod_homepage = https://github.com/Jozufozu/Flywheel # Mod dependency declarations -minecraft_semver_version_range = >=1.20.1 <1.20.2 -minecraft_maven_version_range = [1.20.1,1.20.2) -fabric_api_version_range = >=0.86.0 -forge_version_range = [47.0.0,) +minecraft_semver_version_range = >=1.20.4 <1.20.5 +minecraft_maven_version_range = [1.20.4,1.20.5) +fabric_api_version_range = >=0.97.0 +neoforge_version_range = [20.4.234,) # General build dependency versions java_version = 17 arch_loom_version = 1.6-SNAPSHOT -cursegradle_version = 1.4.0 -parchment_version = 2023.09.03 +parchment_version = 2024.04.14 # Minecraft build dependency versions -minecraft_version = 1.20.1 -forge_version = 47.2.19 -fabric_loader_version = 0.15.9 -fabric_api_version = 0.92.1+1.20.1 +minecraft_version = 1.20.4 +neoforge_version = 20.4.234 +fabric_loader_version = 0.15.10 +fabric_api_version = 0.97.0+1.20.4 # Build dependency mod versions sodium_version = mc1.20.1-0.5.8 @@ -37,4 +36,4 @@ oculus_version = 1.20.1-1.6.15a # Publication info group = dev.engine_room.flywheel -artifact_minecraft_version = 1.20.1 +artifact_minecraft_version = 1.20.4 diff --git a/settings.gradle.kts b/settings.gradle.kts index cf8fd7a12..5bb943455 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,8 +2,8 @@ pluginManagement { repositories { gradlePluginPortal() mavenCentral() - maven("https://maven.minecraftforge.net/") { - name = "MinecraftForge" + maven("https://maven.neoforged.net/releases/") { + name = "NeoForged" } maven("https://maven.architectury.dev/") { name = "Architectury"