Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat/multi-loader-1.20.4' into feat/multi-lo…
Browse files Browse the repository at this point in the history
…ader-1.21

# Conflicts:
#	forge/src/main/java/dev/engine_room/flywheel/impl/FlywheelForge.java
#	forge/src/main/java/dev/engine_room/flywheel/impl/mixin/MinecraftMixin.java
#	gradle.properties
  • Loading branch information
IThundxr committed Jun 7, 2024
2 parents effc39c + 045771d commit 34eba91
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ class SubprojectPlugin: Plugin<Project> {
}
}

@Suppress("UnstableApiUsage")
private fun setupLoom(project: Project) {
val loom = project.the<LoomGradleExtensionAPI>()
loom.silentMojangMappingsLicense()

// FIXME y tho? :(
loom.mixin.useLegacyMixinAp = true
loom.mixin.defaultRefmapName = "flywheel.refmap.json"
//fixme is this still needed?
// loom.mixin.defaultRefmapName = "flywheel.refmap.json"
}

private fun setupJava(project: Project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ abstract class MinecraftMixin {
}
}

@Inject(method = "clearClientLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
private void flywheel$onClearLevel(CallbackInfo ci) {
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
private void flywheel$onDisconnect(CallbackInfo ci) {
if (level != null) {
LevelAttached.invalidateLevel(level);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
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.neoforged.bus.api.Event;

/**
* This event is posted to the Forge event bus.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package dev.engine_room.flywheel.api.event;

import net.neoforged.bus.api.Event;

import org.joml.Matrix4f;

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.neoforged.bus.api.Event;

/**
* This event is posted to the Forge event bus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
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;
Expand All @@ -23,6 +20,8 @@
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.neoforged.neoforge.client.ChunkRenderTypeSet;
import net.neoforged.neoforge.client.model.data.ModelData;

final class BakedModelBufferer {
static final RenderType[] CHUNK_LAYERS = RenderType.chunkBufferLayers().toArray(RenderType[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.function.BiFunction;

import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.PoseStack;
Expand All @@ -18,6 +16,7 @@
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.data.ModelData;

public final class ForgeBakedModelBuilder extends BakedModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.function.BiFunction;

import net.neoforged.neoforge.client.model.data.ModelData;

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.PoseStack;
Expand All @@ -16,6 +14,7 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.data.ModelData;

public final class ForgeBlockModelBuilder extends BlockModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
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;
Expand All @@ -17,6 +15,7 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.neoforged.neoforge.client.model.data.ModelData;

public final class ForgeMultiBlockModelBuilder extends MultiBlockModelBuilder {
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

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.neoforged.neoforge.client.event.ModelEvent;

@ApiStatus.Internal
public final class PartialModelEventHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.neoforged.neoforge.common.ModConfigSpec.BooleanValue;
import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue;

public final class FlwCommands {
private FlwCommands() {
Expand All @@ -25,7 +26,7 @@ private FlwCommands() {
public static void registerClientCommands(RegisterClientCommandsEvent event) {
LiteralArgumentBuilder<CommandSourceStack> command = Commands.literal("flywheel");

ModConfigSpec.ConfigValue<String> backendValue = ForgeFlwConfig.INSTANCE.client.backend;
ConfigValue<String> backendValue = ForgeFlwConfig.INSTANCE.client.backend;
command.then(Commands.literal("backend")
.executes(context -> {
Backend backend = BackendManager.getBackend();
Expand Down Expand Up @@ -55,7 +56,7 @@ public static void registerClientCommands(RegisterClientCommandsEvent event) {
return Command.SINGLE_SUCCESS;
})));

ModConfigSpec.BooleanValue limitUpdatesValue = ForgeFlwConfig.INSTANCE.client.limitUpdates;
BooleanValue limitUpdatesValue = ForgeFlwConfig.INSTANCE.client.limitUpdates;
command.then(Commands.literal("limitUpdates")
.executes(context -> {
if (limitUpdatesValue.get()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
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;
Expand All @@ -10,6 +8,7 @@
import dev.engine_room.flywheel.api.event.RenderStage;
import dev.engine_room.flywheel.api.event.RenderStageEvent;
import net.minecraft.client.multiplayer.ClientLevel;
import net.neoforged.neoforge.common.NeoForge;

public class FlwImplXplatImpl implements FlwImplXplat {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

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;
Expand All @@ -23,6 +20,8 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.fml.ModList;
import net.neoforged.fml.util.ObfuscationReflectionHelper;

public class FlwLibXplatImpl implements FlwLibXplat {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
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.ModLoadingContext;

import net.neoforged.fml.common.Mod;

import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
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.entity.EntityJoinLevelEvent;

import net.neoforged.neoforge.event.entity.EntityLeaveLevelEvent;

import net.neoforged.neoforge.event.level.LevelEvent;
import net.neoforged.neoforge.event.tick.LevelTickEvent;
import net.neoforged.neoforge.registries.RegisterEvent;

import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.jetbrains.annotations.UnknownNullability;

Expand All @@ -40,17 +17,35 @@
import dev.engine_room.flywheel.lib.util.LevelAttached;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
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.ModContainer;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
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.entity.EntityJoinLevelEvent;
import net.neoforged.neoforge.event.entity.EntityLeaveLevelEvent;
import net.neoforged.neoforge.event.level.LevelEvent;
import net.neoforged.neoforge.event.tick.LevelTickEvent;
import net.neoforged.neoforge.registries.RegisterEvent;

@Mod(Flywheel.ID)
public final class FlywheelForge {
@UnknownNullability
private static ArtifactVersion version;

public FlywheelForge(IEventBus modEventBus) {
public FlywheelForge(IEventBus modEventBus, ModContainer modContainer) {
ModLoadingContext modLoadingContext = ModLoadingContext.get();

version = modLoadingContext
.getActiveContainer()
version = modContainer
.getModInfo()
.getVersion();

Expand Down Expand Up @@ -96,7 +91,7 @@ private static void registerImplEventListeners(IEventBus forgeEventBus, IEventBu
FlwDebugInfo.addDebugInfo(minecraft, e.getRight());
});

modEventBus.addListener((EndClientResourceReloadEvent e) -> BackendManagerImpl.onEndClientResourceReload(e.error() != null));
modEventBus.addListener((EndClientResourceReloadEvent e) -> BackendManagerImpl.onEndClientResourceReload(e.error().isPresent()));

modEventBus.addListener((FMLCommonSetupEvent e) -> {
ArgumentTypeInfos.registerByClass(BackendArgument.class, BackendArgument.INFO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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;

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.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.common.ModConfigSpec;

public class ForgeFlwConfig implements FlwConfig {
public static final ForgeFlwConfig INSTANCE = new ForgeFlwConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
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;
Expand All @@ -15,14 +13,13 @@
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

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.server.packs.resources.ReloadableResourceManager;
import net.neoforged.fml.ModLoader;

@Mixin(value = Minecraft.class, remap = false)
@Mixin(Minecraft.class)
abstract class MinecraftMixin {
@Shadow
@Final
Expand All @@ -36,12 +33,12 @@ abstract class MinecraftMixin {
}

@Inject(method = "lambda$new$7", at = @At("HEAD"))
private void flywheel$onEndInitialResourceReload(@Coerce Object minecraft$gameloadcookie, Optional<Throwable> error, CallbackInfo ci) {
private void flywheel$onEndInitialResourceReload(@Coerce Object gameLoadCookie, Optional<Throwable> error, CallbackInfo ci) {
ModLoader.postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, true, error));
}

@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) {
private void flywheel$onEndManualResourceReload(boolean recovery, @Coerce Object gameLoadCookie, CompletableFuture<Void> completablefuture, Optional<Throwable> error, CallbackInfo ci) {
ModLoader.postEvent(new EndClientResourceReloadEvent((Minecraft) (Object) this, resourceManager, false, error));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
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.neoforged.fml.loading.LoadingModList;

public class SodiumMixinPlugin implements IMixinConfigPlugin {
private static final Supplier<Boolean> IS_SODIUM_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById("rubidium") != null);
private static final Supplier<Boolean> IS_SODIUM_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById("embeddium") != null);

@Override
public void onLoad(String mixinPackage) {
Expand Down
8 changes: 0 additions & 8 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,3 @@ modId = "neoforge"
type = "required"
versionRange = "${neoforge_version_range}"
side = "CLIENT"

# Breaks dependency
[[dependencies.${mod_id}]]
modId = "rubidium"
type = "incompatible"
reason = "mixin crash with any version of rubidium under 0.7.0"
versionRange = "[0.7.0,)"
side = "CLIENT"

0 comments on commit 34eba91

Please sign in to comment.