mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 11:27:54 +01:00
Port to 1.20.4
This commit is contained in:
parent
ee3958b140
commit
56b0fce44d
27 changed files with 129 additions and 88 deletions
|
@ -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"
|
||||
|
|
|
@ -53,6 +53,8 @@ class SubprojectPlugin: Plugin<Project> {
|
|||
val loom = project.the<LoomGradleExtensionAPI>()
|
||||
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",
|
||||
)
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Throwable> error, CallbackInfo ci) {
|
||||
@Inject(method = "method_53522", at = @At("HEAD"))
|
||||
private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional<Throwable> 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<Void> future,
|
||||
private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture<Void> future,
|
||||
Optional<Throwable> error, CallbackInfo ci) {
|
||||
EndClientResourceReloadCallback.EVENT.invoker()
|
||||
.onEndClientResourceReload((Minecraft) (Object) this, resourceManager, false, error);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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")}")
|
||||
|
|
|
@ -1 +1 @@
|
|||
loom.platform = forge
|
||||
loom.platform = neoforge
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<CommandSourceStack> command = Commands.literal("flywheel");
|
||||
|
||||
ConfigValue<String> backendValue = ForgeFlwConfig.INSTANCE.client.backend;
|
||||
ModConfigSpec.ConfigValue<String> 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()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<ClientConfig, ForgeConfigSpec> clientPair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
|
||||
Pair<ClientConfig, ModConfigSpec> 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<String> backend;
|
||||
public final ForgeConfigSpec.BooleanValue limitUpdates;
|
||||
public final ForgeConfigSpec.IntValue workerThreads;
|
||||
public final ModConfigSpec.ConfigValue<String> 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());
|
||||
|
||||
|
|
|
@ -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<Throwable> error, CallbackInfo ci) {
|
||||
@Inject(method = "lambda$new$7", at = @At("HEAD"))
|
||||
private void flywheel$onEndInitialResourceReload(@Coerce Object minecraft$gameloadcookie, Optional<Throwable> 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<Void> future, Optional<Throwable> error, CallbackInfo ci) {
|
||||
@Inject(method = "lambda$reloadResourcePacks$39", at = @At("HEAD"))
|
||||
private void flywheel$onEndManualResourceReload(boolean bl, @Coerce Object minecraft$gameloadcookie, CompletableFuture<Void> completablefuture, Optional<Throwable> error, CallbackInfo ci) {
|
||||
ModLoader.get().postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Boolean> IS_SODIUM_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById("rubidium") != null);
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue