Fix neoforge 1.20.6 compiling
This commit is contained in:
@@ -325,6 +325,7 @@ subprojects { p ->
|
||||
"fabric.mod.json",
|
||||
"quilt.mod.json",
|
||||
"META-INF/mods.toml",
|
||||
"META-INF/NeoForge.mods.toml",
|
||||
|
||||
// The mixins for each of the loaders
|
||||
"DistantHorizons."+ p.name +".fabricLike.mixins.json"
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class GetConfigScreen
|
||||
case JavaFX:
|
||||
return MinecraftScreen.getScreen(parent, new JavaScreenHandlerScreen(new ConfigScreen()), ModInfo.ID + ".title");
|
||||
default:
|
||||
return null;
|
||||
throw new IllegalArgumentException("No config screen implementation defined for ["+useScreen+"].");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,8 +111,8 @@ public class MixinLevelRenderer
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
#else
|
||||
// get the matrices directly from MC
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(projectionMatrix); //frustumMatrix);
|
||||
Mat4f mcProjectionMatrix = new Mat4f();// McObjectConverter.Convert(projectionMatrix);
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
Mat4f mcProjectionMatrix = new Mat4f();
|
||||
mcProjectionMatrix.setIdentity();
|
||||
#endif
|
||||
|
||||
|
||||
+38
-2
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.neoforge;
|
||||
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
@@ -34,6 +35,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapp
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
//import io.netty.buffer.ByteBuf;
|
||||
import com.seibel.distanthorizons.coreapi.util.math.Mat4f;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
@@ -54,10 +56,16 @@ import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.neoforge.client.event.InputEvent;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
#else
|
||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* This handles all events sent to the client,
|
||||
* and is the starting point for most of the mod.
|
||||
@@ -72,8 +80,10 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
|
||||
// private static SimpleChannel multiversePluginChannel;
|
||||
|
||||
// Not the cleanest way of passing this to the LOD renderer, but it'll have to do for now
|
||||
public static Mat4f currentModelViewMatrix = new Mat4f();
|
||||
public static Mat4f currentProjectionMatrix = new Mat4f();
|
||||
|
||||
private static LevelAccessor GetEventLevel(LevelEvent e) { return e.getLevel(); }
|
||||
|
||||
|
||||
|
||||
@@ -90,6 +100,7 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
// tick events //
|
||||
//=============//
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
@SubscribeEvent
|
||||
public void clientTickEvent(TickEvent.ClientTickEvent event)
|
||||
{
|
||||
@@ -98,6 +109,13 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
ClientApi.INSTANCE.clientTickEvent();
|
||||
}
|
||||
}
|
||||
#else
|
||||
@SubscribeEvent
|
||||
public void clientTickEvent(ClientTickEvent.Pre event)
|
||||
{
|
||||
ClientApi.INSTANCE.clientTickEvent();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -281,6 +299,16 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
// rendering //
|
||||
//===========//
|
||||
|
||||
@SubscribeEvent
|
||||
public void beforeLevelRenderEvent(RenderLevelStageEvent event)
|
||||
{
|
||||
if (event.getStage() == RenderLevelStageEvent.Stage.AFTER_SKY)
|
||||
{
|
||||
currentModelViewMatrix = McObjectConverter.Convert(event.getModelViewMatrix());
|
||||
currentProjectionMatrix = McObjectConverter.Convert(event.getProjectionMatrix());
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void afterLevelRenderEvent(RenderLevelStageEvent event)
|
||||
{
|
||||
@@ -301,4 +329,12 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper methods //
|
||||
//================//
|
||||
|
||||
private static LevelAccessor GetEventLevel(LevelEvent e) { return e.getLevel(); }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,13 +35,18 @@ import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
#else
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize and setup the Mod. <br>
|
||||
* If you are looking for the real start of the mod
|
||||
@@ -70,8 +75,14 @@ public class NeoforgeMain extends AbstractModInitializer
|
||||
{
|
||||
this.tryCreateModCompatAccessor("optifine", IOptifineAccessor.class, OptifineAccessor::new);
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class,
|
||||
() -> new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> GetConfigScreen.getScreen(parent)));
|
||||
#else
|
||||
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class,
|
||||
// TODO fix potential null pointer
|
||||
() -> (client, parent) -> GetConfigScreen.getScreen(parent));
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
-3
@@ -12,7 +12,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.neoforge.event.level.ChunkEvent;
|
||||
import net.neoforged.neoforge.event.level.LevelEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
@@ -20,11 +19,17 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
#else
|
||||
import net.neoforged.neoforge.event.tick.ServerTickEvent;
|
||||
#endif
|
||||
|
||||
|
||||
public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
{
|
||||
private static LevelAccessor GetEventLevel(LevelEvent e) { return e.getLevel(); }
|
||||
@@ -58,7 +63,7 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
// events //
|
||||
//========//
|
||||
|
||||
// ServerTickEvent (at end)
|
||||
#if MC_VER < MC_1_20_6
|
||||
@SubscribeEvent
|
||||
public void serverTickEvent(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
@@ -67,6 +72,13 @@ public class NeoforgeServerProxy implements AbstractModInitializer.IEventProxy
|
||||
this.serverApi.serverTickEvent();
|
||||
}
|
||||
}
|
||||
#else
|
||||
@SubscribeEvent
|
||||
public void serverTickEvent(ServerTickEvent.Post event)
|
||||
{
|
||||
this.serverApi.serverTickEvent();
|
||||
}
|
||||
#endif
|
||||
|
||||
// ServerWorldLoadEvent
|
||||
@SubscribeEvent
|
||||
|
||||
+21
-30
@@ -19,10 +19,12 @@
|
||||
|
||||
package com.seibel.distanthorizons.neoforge.mixins.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
#if MC_VER < MC_1_19_4
|
||||
import com.mojang.math.Matrix4f;
|
||||
#else
|
||||
import com.seibel.distanthorizons.neoforge.NeoforgeClientProxy;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -67,30 +69,6 @@ public class MixinLevelRenderer
|
||||
(remap = false)
|
||||
#endif
|
||||
private ClientLevel level;
|
||||
@Unique
|
||||
private static float previousPartialTicks = 0;
|
||||
|
||||
// TODO: Is there any reason why this is here? Can it be deleted?
|
||||
public MixinLevelRenderer()
|
||||
{
|
||||
throw new NullPointerException("Null cannot be cast to non-null type.");
|
||||
}
|
||||
|
||||
#if MC_VER < MC_1_17_1
|
||||
@Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V")
|
||||
private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback)
|
||||
#else
|
||||
@Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true)
|
||||
public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float partialTicks, double cameraX, double cameraY, double cameraZ, CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
// FIXME this is only called when clouds are enabled and vanilla render distance is far enough
|
||||
// not having the partial ticks doesn't appear to be critical currently, but might cause weird issues down the line
|
||||
|
||||
// get the partial ticks since renderBlockLayer doesn't
|
||||
// have access to them
|
||||
previousPartialTicks = partialTicks;
|
||||
}
|
||||
|
||||
|
||||
#if MC_VER < MC_1_17_1
|
||||
@@ -108,12 +86,17 @@ public class MixinLevelRenderer
|
||||
method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback)
|
||||
#else
|
||||
#elif MC_VER < MC_1_20_6
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "Lnet/minecraft/client/renderer/LevelRenderer;renderSectionLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double camX, double camY, double camZ, Matrix4f projectionMatrix, CallbackInfo callback)
|
||||
#endif
|
||||
#else
|
||||
@Inject(at = @At("HEAD"),
|
||||
method = "Lnet/minecraft/client/renderer/LevelRenderer;renderSectionLayer(Lnet/minecraft/client/renderer/RenderType;DDDLorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V",
|
||||
cancellable = true)
|
||||
private void renderChunkLayer(RenderType renderType, double x, double y, double z, Matrix4f projectionMatrix, Matrix4f frustumMatrix, CallbackInfo callback)
|
||||
#endif
|
||||
{
|
||||
// get MC's model view and projection matrices
|
||||
#if MC_VER == MC_1_16_5
|
||||
@@ -125,10 +108,15 @@ public class MixinLevelRenderer
|
||||
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(matrixStackIn.last().pose());
|
||||
|
||||
#else
|
||||
#elif MC_VER <= MC_1_20_4
|
||||
// get the matrices directly from MC
|
||||
Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose());
|
||||
Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix);
|
||||
#else
|
||||
// get the matrices from neoForge's render event.
|
||||
// We can't call the renderer there because we don't have access to the level that's being rendered
|
||||
Mat4f mcModelViewMatrix = NeoforgeClientProxy.currentModelViewMatrix;
|
||||
Mat4f mcProjectionMatrix = NeoforgeClientProxy.currentProjectionMatrix;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -136,11 +124,11 @@ public class MixinLevelRenderer
|
||||
// only render before solid blocks
|
||||
if (renderType.equals(RenderType.solid()))
|
||||
{
|
||||
ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime());
|
||||
ClientApi.INSTANCE.renderLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime());
|
||||
}
|
||||
else if (renderType.equals(RenderType.translucent()))
|
||||
{
|
||||
ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime());
|
||||
ClientApi.INSTANCE.renderDeferredLods(ClientLevelWrapper.getWrapper(this.level), mcModelViewMatrix, mcProjectionMatrix, Minecraft.getInstance().getFrameTime());
|
||||
}
|
||||
|
||||
if (Config.Client.Advanced.Debugging.lodOnlyMode.get())
|
||||
@@ -155,9 +143,12 @@ public class MixinLevelRenderer
|
||||
#elif MC_VER < MC_1_20_1
|
||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"), method = "renderLevel")
|
||||
public void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
||||
#elif MC_VER < MC_1_20_6
|
||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
||||
private void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
||||
#else
|
||||
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"), method = "renderLevel")
|
||||
private void callAfterRunUpdates(PoseStack poseStack, float partialTick, long finishNanoTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, CallbackInfo ci)
|
||||
private void callAfterRunUpdates(CallbackInfo ci)
|
||||
#endif
|
||||
{
|
||||
ChunkWrapper.syncedUpdateClientLightStatus();
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ issueTrackerURL = "${issues}"
|
||||
acceptableRemoteVersions = "*"
|
||||
|
||||
# We may need this to make forge (lexforge) & neoforge work together
|
||||
#[[mixins]]
|
||||
# config = "DistantHorizons.neoforge.mixins.json"
|
||||
[[mixins]]
|
||||
config = "DistantHorizons.neoforge.mixins.json"
|
||||
|
||||
[[dependencies.distanthorizons]]
|
||||
modId = "minecraft"
|
||||
@@ -4,7 +4,7 @@ minecraft_version=1.20.6
|
||||
parchment_version=1.20.6:2024.05.01
|
||||
compatible_minecraft_versions=["1.20.6"]
|
||||
accessWidenerVersion=1_20_2
|
||||
builds_for=fabric
|
||||
builds_for=fabric,neoforge
|
||||
# neoforge can be added once the issue with mixins has been resolved
|
||||
|
||||
# Fabric loader
|
||||
|
||||
Reference in New Issue
Block a user