Bug fixes and refactoring.
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.modAccessor;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ImmersivePortalsAbstractAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
#if MC_VER > MC_1_19_2
|
||||
import org.joml.Matrix4f;
|
||||
#else
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
#endif
|
||||
|
||||
#if MC_VER < MC_1_17_1
|
||||
import java.lang.reflect.Field;
|
||||
#endif
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ImmersivePortalsAccessorCommon extends ImmersivePortalsAbstractAccessor
|
||||
{
|
||||
@Override
|
||||
protected Object getClientLevel()
|
||||
{
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
@Override
|
||||
protected Class<?> getLevelClass()
|
||||
{
|
||||
return Level.class;
|
||||
}
|
||||
@Override
|
||||
protected Iterable<?> getEntitiesForRendering()
|
||||
{
|
||||
return Minecraft.getInstance().level.entitiesForRendering();
|
||||
}
|
||||
|
||||
private static Matrix4f getProjectionMatrix() {
|
||||
#if MC_VER > MC_1_16_5
|
||||
return RenderSystem.getProjectionMatrix();
|
||||
#else
|
||||
try {
|
||||
Class<?> renderStates = Class.forName("com.qouteall.immersive_portals.render.context_management.RenderStates");
|
||||
Field projectionMatrix = renderStates.getField("projectionMatrix");
|
||||
return (Matrix4f) projectionMatrix.get(null);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_19_2
|
||||
protected abstract Matrix4f convert(Mat4f matrix);
|
||||
#endif
|
||||
|
||||
@Override
|
||||
protected Supplier<?> getFrustumSupplier()
|
||||
{
|
||||
return Suppliers.memoize(() -> {
|
||||
Frustum frustum = new Frustum(
|
||||
#if MC_VER > MC_1_19_2
|
||||
ClientApi.RENDER_STATE.mcModelViewMatrix.createJomlMatrix(),
|
||||
#else
|
||||
convert(ClientApi.RENDER_STATE.mcModelViewMatrix),
|
||||
#endif
|
||||
getProjectionMatrix()
|
||||
);
|
||||
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
frustum.prepare(cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
||||
return frustum;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
Submodule coreSubProjects updated: 7fe0c9b0e8...f5ac5c56b4
@@ -21,6 +21,7 @@ package com.seibel.distanthorizons.fabric;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
|
||||
@@ -143,16 +143,6 @@ public class FabricServerProxy implements AbstractModInitializer.IEventProxy
|
||||
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) ->
|
||||
{
|
||||
ServerApi.INSTANCE.serverPlayerJoinEvent(this.getServerPlayerWrapper(handler.player));
|
||||
|
||||
// Send identification for all loaded levels to the joining player
|
||||
// This is necessary for Immersive Portals which can render multiple dimensions at once
|
||||
for (ServerLevel level : server.getAllLevels())
|
||||
{
|
||||
if (level != handler.player.level())
|
||||
{
|
||||
ServerApi.INSTANCE.serverLevelLoadEvent(this.getServerLevelWrapper(level));
|
||||
}
|
||||
}
|
||||
});
|
||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) ->
|
||||
{
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.seibel.distanthorizons.fabric.mixins.client;
|
||||
|
||||
#if MC_VER <= MC_1_19_2
|
||||
import com.mojang.math.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(Matrix4f.class)
|
||||
public interface AccessorMatrix4f
|
||||
{
|
||||
|
||||
@Accessor("m00")
|
||||
void setM00(float v);
|
||||
@Accessor("m01")
|
||||
void setM01(float v);
|
||||
@Accessor("m02")
|
||||
void setM02(float v);
|
||||
@Accessor("m03")
|
||||
void setM03(float v);
|
||||
|
||||
@Accessor("m10")
|
||||
void setM10(float v);
|
||||
@Accessor("m11")
|
||||
void setM11(float v);
|
||||
@Accessor("m12")
|
||||
void setM12(float v);
|
||||
@Accessor("m13")
|
||||
void setM13(float v);
|
||||
|
||||
@Accessor("m20")
|
||||
void setM20(float v);
|
||||
@Accessor("m21")
|
||||
void setM21(float v);
|
||||
@Accessor("m22")
|
||||
void setM22(float v);
|
||||
@Accessor("m23")
|
||||
void setM23(float v);
|
||||
|
||||
|
||||
@Accessor("m30")
|
||||
void setM30(float v);
|
||||
@Accessor("m31")
|
||||
void setM31(float v);
|
||||
@Accessor("m32")
|
||||
void setM32(float v);
|
||||
@Accessor("m33")
|
||||
void setM33(float v);
|
||||
|
||||
}
|
||||
#else
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public interface AccessorMatrix4f
|
||||
{ /* not present in newer MC versions */ }
|
||||
#endif
|
||||
+1
@@ -27,6 +27,7 @@ import com.mojang.math.Matrix4f;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
#elif MC_VER < MC_1_21_6
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
+32
-38
@@ -1,47 +1,41 @@
|
||||
package com.seibel.distanthorizons.fabric.wrappers.modAccessor;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ImmersivePortalsAbstractAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
#if MC_VER <= MC_1_19_2
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.seibel.distanthorizons.fabric.mixins.client.AccessorMatrix4f;
|
||||
#endif
|
||||
|
||||
public class ImmersivePortalsAccessorFabric extends ImmersivePortalsAbstractAccessor
|
||||
public class ImmersivePortalsAccessorFabric extends ImmersivePortalsAccessorCommon
|
||||
{
|
||||
#if MC_VER <= MC_1_19_2
|
||||
@Override
|
||||
protected Object getClientLevel()
|
||||
{
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
@Override
|
||||
protected Class<?> getLevelClass()
|
||||
{
|
||||
return Level.class;
|
||||
}
|
||||
@Override
|
||||
protected Iterable<?> getEntitiesForRendering()
|
||||
{
|
||||
return Minecraft.getInstance().level.entitiesForRendering();
|
||||
}
|
||||
@Override
|
||||
protected Supplier<?> getFrustumSupplier()
|
||||
{
|
||||
return Suppliers.memoize(() -> {
|
||||
Frustum frustum = new Frustum(
|
||||
ClientApi.RENDER_STATE.mcModelViewMatrix.createJomlMatrix(),
|
||||
RenderSystem.getProjectionMatrix()
|
||||
);
|
||||
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
frustum.prepare(cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
||||
return frustum;
|
||||
});
|
||||
protected Matrix4f convert(Mat4f matrix) {
|
||||
Matrix4f returnMatrix = new Matrix4f();
|
||||
AccessorMatrix4f accessibleMatrix = (AccessorMatrix4f) returnMatrix;
|
||||
accessibleMatrix.setM00(matrix.m00);
|
||||
accessibleMatrix.setM01(matrix.m01);
|
||||
accessibleMatrix.setM02(matrix.m02);
|
||||
accessibleMatrix.setM03(matrix.m03);
|
||||
|
||||
accessibleMatrix.setM10(matrix.m10);
|
||||
accessibleMatrix.setM11(matrix.m11);
|
||||
accessibleMatrix.setM12(matrix.m12);
|
||||
accessibleMatrix.setM13(matrix.m13);
|
||||
|
||||
accessibleMatrix.setM20(matrix.m20);
|
||||
accessibleMatrix.setM21(matrix.m21);
|
||||
accessibleMatrix.setM22(matrix.m22);
|
||||
accessibleMatrix.setM23(matrix.m23);
|
||||
|
||||
accessibleMatrix.setM30(matrix.m30);
|
||||
accessibleMatrix.setM31(matrix.m31);
|
||||
accessibleMatrix.setM32(matrix.m32);
|
||||
accessibleMatrix.setM33(matrix.m33);
|
||||
return returnMatrix;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"minVersion": "0.8",
|
||||
"package": "com.seibel.distanthorizons.fabric.mixins",
|
||||
"mixins": [
|
||||
"client.AccessorMatrix4f",
|
||||
"server.MixinChunkGenerator",
|
||||
"server.MixinChunkMap",
|
||||
"server.MixinEntity",
|
||||
|
||||
@@ -106,37 +106,6 @@ public class ForgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// world events //
|
||||
//==============//
|
||||
|
||||
@SubscribeEvent
|
||||
#if MC_VER < MC_1_19_2
|
||||
public void clientLevelLoadEvent(WorldEvent.Load event)
|
||||
#else
|
||||
public void clientLevelLoadEvent(LevelEvent.Load event)
|
||||
#endif
|
||||
{
|
||||
LOGGER.info("level load");
|
||||
|
||||
#if MC_VER < MC_1_19_2
|
||||
LevelAccessor level = event.getWorld();
|
||||
#else
|
||||
LevelAccessor level = event.getLevel();
|
||||
#endif
|
||||
if (!(level instanceof ClientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// chunk events //
|
||||
//==============//
|
||||
|
||||
+10
-38
@@ -1,47 +1,19 @@
|
||||
package com.seibel.distanthorizons.forge.wrappers.modAccessor;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.seibel.distanthorizons.core.api.internal.ClientApi;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.ImmersivePortalsAbstractAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
#if MC_VER <= MC_1_19_2
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
#endif
|
||||
|
||||
public class ImmersivePortalsAccessorForge extends ImmersivePortalsAbstractAccessor
|
||||
public class ImmersivePortalsAccessorForge extends ImmersivePortalsAccessorCommon
|
||||
{
|
||||
#if MC_VER <= MC_1_19_2
|
||||
@Override
|
||||
protected Object getClientLevel()
|
||||
{
|
||||
return Minecraft.getInstance().level;
|
||||
}
|
||||
@Override
|
||||
protected Class<?> getLevelClass()
|
||||
{
|
||||
return Level.class;
|
||||
}
|
||||
@Override
|
||||
protected Iterable<?> getEntitiesForRendering()
|
||||
{
|
||||
return Minecraft.getInstance().level.entitiesForRendering();
|
||||
}
|
||||
@Override
|
||||
protected Supplier<?> getFrustumSupplier()
|
||||
{
|
||||
return Suppliers.memoize(() -> {
|
||||
Frustum frustum = new Frustum(
|
||||
ClientApi.RENDER_STATE.mcModelViewMatrix.createJomlMatrix(),
|
||||
RenderSystem.getProjectionMatrix()
|
||||
);
|
||||
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
frustum.prepare(cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
||||
return frustum;
|
||||
});
|
||||
protected Matrix4f convert(Mat4f matrix) {
|
||||
return new Matrix4f(matrix.getValuesAsArray());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ versionStr=
|
||||
|
||||
# This defines what MC version Intellij will use for the preprocessor
|
||||
# and what version is used automatically by build and run commands
|
||||
mcVer=26.1.2
|
||||
mcVer=1.21.1
|
||||
|
||||
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment
|
||||
minecraftMemoryJavaArg=-Xmx6G
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.seibel.distanthorizons.neoforge;
|
||||
|
||||
import com.seibel.distanthorizons.common.AbstractModInitializer;
|
||||
import com.seibel.distanthorizons.common.ImmersivePortalsCompat;
|
||||
import com.seibel.distanthorizons.common.util.ProxyUtil;
|
||||
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
|
||||
@@ -52,7 +51,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.neoforge.client.event.InputEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import com.seibel.distanthorizons.common.ImmersivePortalsCompat;
|
||||
|
||||
#if MC_VER < MC_1_20_6
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
@@ -75,28 +73,6 @@ public class NeoforgeClientProxy implements AbstractModInitializer.IEventProxy
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// world events //
|
||||
//==============//
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientLevelLoadEvent(LevelEvent.Load event)
|
||||
{
|
||||
LOGGER.info("level load");
|
||||
|
||||
LevelAccessor level = event.getLevel();
|
||||
if (!(level instanceof ClientLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientLevel clientLevel = (ClientLevel) level;
|
||||
IClientLevelWrapper clientLevelWrapper = ClientLevelWrapper.getWrapper(clientLevel, true);
|
||||
ClientApi.INSTANCE.clientLevelLoadEvent(clientLevelWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// chunk events //
|
||||
//==============//
|
||||
|
||||
@@ -30,16 +30,10 @@ import com.seibel.distanthorizons.core.network.messages.AbstractNetworkMessage;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IPluginPacketSender;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.IServerPlayerWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IC2meAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IIrisAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IModChecker;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.IOptifineAccessor;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.modAccessor.*;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.C2meAccessor;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.IrisAccessor;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.*;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.NeoforgeMinecraftRenderWrapper;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.ModChecker;
|
||||
import com.seibel.distanthorizons.neoforge.wrappers.modAccessor.OptifineAccessor;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.neoforged.bus.api.EventPriority;
|
||||
@@ -148,6 +142,7 @@ public class NeoforgeMain extends AbstractModInitializer
|
||||
{
|
||||
this.tryCreateModCompatAccessor("optifine", IOptifineAccessor.class, OptifineAccessor::new);
|
||||
this.tryCreateModCompatAccessor("c2me", IC2meAccessor.class, C2meAccessor::new);
|
||||
this.tryCreateModCompatAccessor("immersive_portals_core", IImmersivePortalsAccessor.class, ImmersivePortalsAccessorNeoForge::new);
|
||||
|
||||
#if MC_VER >= MC_1_20_6
|
||||
// 1.20.6 is the lowest version Iris supports Neoforge
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.seibel.distanthorizons.neoforge.wrappers.modAccessor;
|
||||
|
||||
import com.seibel.distanthorizons.common.wrappers.modAccessor.ImmersivePortalsAccessorCommon;
|
||||
|
||||
public class ImmersivePortalsAccessorNeoForge extends ImmersivePortalsAccessorCommon
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user