Compare commits

...

38 Commits

Author SHA1 Message Date
James Seibel 1787d2c6d9 Fix BlockStateWrapper compiling 2023-12-03 18:38:17 -06:00
James Seibel 1a07fb83b6 Revert Sqlite update 3.44.1.0 -> 3.43.0.0
The new version caused java module issues. I'll have to look into it again another time.
2023-12-03 17:55:01 -06:00
James Seibel 4d2ee292bb Remove "-dev" from the version number 2023-12-03 17:19:30 -06:00
James Seibel 0fdde61fe5 Add a config to enable/disable using MC's lighting engine 2023-12-02 12:37:30 -06:00
James Seibel ae8a4912a6 Add a limit to the number of queued update chunks 2023-12-02 12:24:22 -06:00
James Seibel ffd8ea8751 Fix snow light rendering 2023-12-02 12:07:35 -06:00
James Seibel 4cd10a82fd Fix DH lighting failing for water 2023-12-01 07:50:14 -06:00
James Seibel 4955d22649 Fix block lighting being ignored in MC 1.20.2 2023-12-01 07:49:36 -06:00
James Seibel 425b761f8e Fix pack.mcmeta typo 2023-11-30 07:37:13 -06:00
James Seibel ab3bfd457f Merge branch 'Lorenzo_Giannini-main-patch-20902' into 'main'
multiversion vanilla support

See merge request jeseibel/distant-horizons!43
2023-11-30 13:30:46 +00:00
James Seibel 0faa64112a Refactor, comment, and rename 2023-11-30 07:25:57 -06:00
James Seibel 46519b096c Merge branch 'distant-horizons-lightmapfix' 2023-11-30 07:08:46 -06:00
James Seibel cb7d980e15 Fix a typo in the bug issue template 2023-11-30 07:03:15 -06:00
James Seibel 6c1562ac33 Merge Null's fragment shader culling !38 2023-11-29 07:44:27 -06:00
James Seibel 5e17e4ea8c Update Sqlite 3.43.0.0 -> =3.44.1.0 2023-11-28 07:13:44 -06:00
Fourmisain b8e7b14fbb fix light map update being done on non-light-map textures 2023-11-27 16:58:54 +01:00
James Seibel 5d8eb185bc Merge branch 'Lorenzo_Giannini-main-patch-41483' into 'main'
fix links

See merge request jeseibel/distant-horizons!42
2023-11-25 21:08:43 +00:00
Lorenzo Giannini 7325cedba6 Update pack.mcmeta 2023-11-25 18:31:10 +00:00
Lorenzo Giannini e5043d6d9b fix links 2023-11-25 18:21:21 +00:00
James Seibel 13e53a18e3 Change the default MC version from 1.20.1 -> 1.20.2 2023-11-25 12:13:18 -06:00
James Seibel dd60c7620f Fix null pointer when joining some multiverse servers 2023-11-25 11:39:53 -06:00
James Seibel 83c01cabfb Fix lighting on some servers 2023-11-25 11:08:44 -06:00
James Seibel a95171dbbe Add constants to BlockStateWrapper 2023-11-25 08:46:03 -06:00
James Seibel 10d542ed14 Fix incorrect ChunkWrapper IndexOutOfBounds checking 2023-11-25 08:45:23 -06:00
James Seibel 7e1c55a0c5 Fix merging for transparent LODs over the void 2023-11-24 14:02:33 -06:00
James Seibel 4e25d318ec Fix a potential concurrent error on DhClientServerWorld shutdown 2023-11-24 09:46:51 -06:00
James Seibel c4228f4e63 Improve multiverse similarity logic and fix incorrect log 2023-11-21 07:44:28 -06:00
James Seibel 1411091f60 Fix null pointers when moving between multiverse levels 2023-11-20 07:35:26 -06:00
coolGi 6a2278949e Updated core submodule 2023-11-20 21:59:12 +10:30
coolGi 374b859882 Fixed Indium dialog not showing 2023-11-20 21:47:35 +10:30
coolGi a98bdb94b8 Fixed <br/> not being parsed correctly 2023-11-20 00:40:16 +10:30
coolGi de390f5d70 Fixed updater's back up method deleting the wrong jar 2023-11-19 22:48:46 +10:30
coolGi 9d4968351b Fixed updater crashing without network 2023-11-19 20:07:35 +10:30
coolGi e99fbb76bf Added temporary solution to file update from 1.6 2023-11-18 23:52:30 +10:30
coolGi fd175d2f36 Updated core sub-project 2023-11-18 21:45:52 +10:30
coolGi 0db862e42b Added a notification when Indium is not installed (cus people don't read the crash logs!!!) 2023-11-18 21:32:38 +10:30
coolGi 58f5d64f91 Bumped version number to 2.0.1-a-dev 2023-11-18 20:34:22 +10:30
James Seibel bb54a94acd re-add "-dev" to the version number
For future releases the version number should be changed immediately beforehand.
2023-11-16 19:09:37 -06:00
17 changed files with 276 additions and 48 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
## Chcek off each item in this list before submitting: ## Check off each item in this list before submitting:
<!-- <!--
To mark a section as complete either put an "x" in between the square brackets, example: "[x]" To mark a section as complete either put an "x" in between the square brackets, example: "[x]"
@@ -57,7 +57,7 @@ public class LodCommonMain
public static void initConfig() public static void initConfig()
{ {
ConfigBase.INSTANCE = new ConfigBase(ModInfo.ID, ModInfo.NAME, Config.class, 1); ConfigBase.INSTANCE = new ConfigBase(ModInfo.ID, ModInfo.NAME, Config.class, 2);
Config.completeDelayedSetup(); Config.completeDelayedSetup();
} }
@@ -0,0 +1,32 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.util;
/**
* Added to MC's dynamic textures via mixins
* in order to denote whether a texture is a lightmap or not. <br><br>
*
* If not done any dynamic texture could be used as the lightmap
* which causes some weird rendering bugs.
*/
public interface ILightTextureMarker
{
void markLightTexture();
}
@@ -41,6 +41,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.world.level.EmptyBlockGetter;
#else #else
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@@ -79,6 +80,11 @@ public class BlockStateWrapper implements IBlockStateWrapper
public final BlockState blockState; public final BlockState blockState;
/** technically final, but since it requires a method call to generate it can't be marked as such */ /** technically final, but since it requires a method call to generate it can't be marked as such */
private String serialString; private String serialString;
/**
* Cached opacity value, -1 if not populated. <br>
* Should be between {@link IBlockStateWrapper#FULLY_OPAQUE} and {@link IBlockStateWrapper#FULLY_OPAQUE}
*/
private int opacity = -1;
@@ -173,17 +179,39 @@ public class BlockStateWrapper implements IBlockStateWrapper
@Override @Override
public int getOpacity() public int getOpacity()
{ {
// this method isn't perfect, but works well enough for our use case // use the cached opacity value if possible
if (this.isAir() || !this.blockState.canOcclude()) if (this.opacity != -1)
{ {
// completely transparent return this.opacity;
return 0; }
// this method isn't perfect, but works well enough for our use case
int opacity;
if (this.isAir())
{
opacity = FULLY_TRANSPARENT;
}
else if (this.isLiquid() && !this.blockState.canOcclude())
{
// probably not a waterlogged block (which should block light entirely)
// +1 to indicate that the block is translucent (in between transparent and opaque)
opacity = FULLY_TRANSPARENT + 1;
}
else if (this.blockState.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO))
{
opacity = FULLY_TRANSPARENT;
} }
else else
{ {
// completely opaque // default for all other blocks
return 16; opacity = FULLY_OPAQUE;
} }
this.opacity = opacity;
return this.opacity;
} }
@Override @Override
@@ -31,6 +31,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IBiomeWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import net.minecraft.client.multiplayer.ClientChunkCache; import net.minecraft.client.multiplayer.ClientChunkCache;
import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
@@ -77,7 +78,7 @@ public class ChunkWrapper implements IChunkWrapper
private static final Logger LOGGER = DhLoggerBuilder.getLogger(); private static final Logger LOGGER = DhLoggerBuilder.getLogger();
/** useful for debugging, but can slow down chunk operations quite a bit due to being called every time. */ /** useful for debugging, but can slow down chunk operations quite a bit due to being called every time. */
private static final boolean RUN_RELATIVE_POS_INDEX_VALIDATION = false; private static final boolean RUN_RELATIVE_POS_INDEX_VALIDATION = ModInfo.IS_DEV_BUILD;
/** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */ /** can be used for interactions with the underlying chunk where creating new BlockPos objects could cause issues for the garbage collector. */
private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos()); private static final ThreadLocal<BlockPos.MutableBlockPos> MUTABLE_BLOCK_POS_REF = ThreadLocal.withInitial(() -> new BlockPos.MutableBlockPos());
@@ -387,7 +388,7 @@ public class ChunkWrapper implements IChunkWrapper
{ {
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ())); this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
}); });
#elif MC_1_20_1 #else
this.chunk.findBlockLightSources((blockPos, blockState) -> this.chunk.findBlockLightSources((blockPos, blockState) ->
{ {
this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ())); this.blockLightPosList.add(new DhBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()));
@@ -432,6 +433,8 @@ public class ChunkWrapper implements IChunkWrapper
@Override @Override
public IBlockStateWrapper getBlockState(int relX, int relY, int relZ) public IBlockStateWrapper getBlockState(int relX, int relY, int relZ)
{ {
this.throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(relX, relY, relZ);
BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get(); BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get();
blockPos.setX(relX); blockPos.setX(relX);
@@ -511,7 +514,7 @@ public class ChunkWrapper implements IChunkWrapper
/** used to prevent accidentally attempting to get/set values outside this chunk's boundaries */ /** used to prevent accidentally attempting to get/set values outside this chunk's boundaries */
private void throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(int x, int y, int z) throws IndexOutOfBoundsException private void throwIndexOutOfBoundsIfRelativePosOutsideChunkBounds(int x, int y, int z) throws IndexOutOfBoundsException
{ {
if (RUN_RELATIVE_POS_INDEX_VALIDATION) if (!RUN_RELATIVE_POS_INDEX_VALIDATION)
{ {
return; return;
} }
@@ -27,6 +27,7 @@ import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource; import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -54,8 +55,14 @@ public class ClientLevelWrapper implements IClientLevelWrapper
// wrapper logic // // wrapper logic //
//===============// //===============//
public static IClientLevelWrapper getWrapper(ClientLevel level) @Nullable
public static IClientLevelWrapper getWrapper(@Nullable ClientLevel level)
{ {
if (level == null)
{
return null;
}
// used if the client is connected to a server that defines the currently loaded level // used if the client is connected to a server that defines the currently loaded level
if (KEYED_CLIENT_LEVEL_MANAGER.getUseOverrideWrapper()) if (KEYED_CLIENT_LEVEL_MANAGER.getUseOverrideWrapper())
{ {
@@ -64,10 +71,7 @@ public class ClientLevelWrapper implements IClientLevelWrapper
return getWrapperIgnoringOverride(level); return getWrapperIgnoringOverride(level);
} }
public static IClientLevelWrapper getWrapperIgnoringOverride(ClientLevel level) public static IClientLevelWrapper getWrapperIgnoringOverride(@NotNull ClientLevel level) { return LEVEL_WRAPPER_BY_CLIENT_LEVEL.computeIfAbsent(level, ClientLevelWrapper::new); }
{
return LEVEL_WRAPPER_BY_CLIENT_LEVEL.computeIfAbsent(level, ClientLevelWrapper::new);
}
@Nullable @Nullable
@Override @Override
@@ -37,6 +37,8 @@ import com.seibel.distanthorizons.fabric.wrappers.modAccessor.*;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import javax.swing.*;
/** /**
* Initialize and setup the Mod. <br> * Initialize and setup the Mod. <br>
* If you are looking for the real start of the mod * If you are looking for the real start of the mod
@@ -92,6 +94,11 @@ public class FabricMain
// If sodium is installed Indium is also necessary in order to use the Fabric rendering API // If sodium is installed Indium is also necessary in order to use the Fabric rendering API
if (!modChecker.isModLoaded("indium")) if (!modChecker.isModLoaded("indium"))
{ {
// People don't read the crash logs!!!
// So, just put a notification, so they hopefully realise what's the problem (and dont just open issues)
System.setProperty("java.awt.headless", "false"); // Required to make it work
JOptionPane.showMessageDialog(null, ModInfo.READABLE_NAME + " now relies on Indium to work with Sodium.\nPlease download Indium from https://modrinth.com/mod/indium", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
String errorMessage = "loading Distant Horizons. Distant Horizons requires Indium in order to run with Sodium."; String errorMessage = "loading Distant Horizons. Distant Horizons requires Indium in order to run with Sodium.";
String exceptionError = "Distant Horizons conditional mod Exception"; String exceptionError = "Distant Horizons conditional mod Exception";
@@ -27,9 +27,9 @@ public class MixinClientPacketListener
void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); } void onHandleLoginEnd(CallbackInfo ci) { ClientApi.INSTANCE.onClientOnlyConnected(); }
@Inject(method = "handleRespawn", at = @At("HEAD")) @Inject(method = "handleRespawn", at = @At("HEAD"))
void onHandleRespawnStart(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level)); } void onHandleRespawnStart(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.level)); }
@Inject(method = "handleRespawn", at = @At("RETURN")) @Inject(method = "handleRespawn", at = @At("RETURN"))
void onHandleRespawnEnd(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(level)); } void onHandleRespawnEnd(CallbackInfo ci) { ClientApi.INSTANCE.clientLevelLoadEvent(ClientLevelWrapper.getWrapper(this.level)); }
#if PRE_MC_1_19_4 #if PRE_MC_1_19_4
@Inject(method = "cleanup", at = @At("HEAD")) @Inject(method = "cleanup", at = @At("HEAD"))
@@ -38,10 +38,9 @@ public class MixinClientPacketListener
#endif #endif
void onCleanupStart(CallbackInfo ci) void onCleanupStart(CallbackInfo ci)
{ {
// TODO Is this even needed here? if (this.level != null)
if (level != null)
{ {
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level)); ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(this.level));
} }
ClientApi.INSTANCE.onClientOnlyDisconnected(); ClientApi.INSTANCE.onClientOnlyDisconnected();
} }
@@ -1,3 +1,22 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.fabric.mixins.client; package com.seibel.distanthorizons.fabric.mixins.client;
@@ -6,37 +25,45 @@ import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapp
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.common.util.ILightTextureMarker;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(DynamicTexture.class) @Mixin(DynamicTexture.class)
public class MixinLightmap public class MixinDynamicTexture implements ILightTextureMarker
{ {
/** Used to prevent accidentally using other dynamic textures as a lightmap */
@Unique
private boolean isLightTexture = false;
@Shadow @Shadow
@Final @Final
private NativeImage pixels; private NativeImage pixels;
@Inject(method = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V", at = @At("HEAD"), cancellable = true) @Inject(method = "upload()V", at = @At("HEAD"))
public void updateLightTexture(CallbackInfo ci) public void updateLightTexture(CallbackInfo ci)
{ {
// since the light map is always updated on the client render thread we should be able to access the client level at the same time // since the light map is always updated on the client render thread we should be able to access the client level at the same time
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if ( if (!this.isLightTexture
mc == null || || mc == null
mc.getWrappedClientLevel() == null || mc.getWrappedClientLevel() == null
) )
{
return; return;
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel(); }
//ApiShared.LOGGER.info("Lightmap update"); //ApiShared.LOGGER.info("Lightmap update");
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel); MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel);
} }
public void markLightTexture() { this.isLightTexture = true; }
} }
@@ -0,0 +1,47 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.fabric.mixins.client;
import com.seibel.distanthorizons.common.util.ILightTextureMarker;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightTexture.class)
public class MixinLightTexture
{
@Shadow
@Final
private DynamicTexture lightTexture;
@Inject(method = "<init>", at = @At("RETURN"))
public void markLightTexture(CallbackInfo ci)
{
//
((ILightTextureMarker) this.lightTexture).markLightTexture();
}
}
@@ -15,7 +15,8 @@
"client.MixinFogRenderer", "client.MixinFogRenderer",
"client.MixinGameRenderer", "client.MixinGameRenderer",
"client.MixinLevelRenderer", "client.MixinLevelRenderer",
"client.MixinLightmap", "client.MixinDynamicTexture",
"client.MixinLightTexture",
"client.MixinOptionsScreen", "client.MixinOptionsScreen",
"client.MixinMinecraft", "client.MixinMinecraft",
"client.MixinTextureUtil" "client.MixinTextureUtil"
@@ -1,42 +1,72 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.client; package com.seibel.distanthorizons.forge.mixins.client;
import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; import com.seibel.distanthorizons.common.util.ILightTextureMarker;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(DynamicTexture.class) @Mixin(DynamicTexture.class)
public class MixinLightmap public class MixinDynamicTexture implements ILightTextureMarker
{ {
/** Used to prevent accidentally using other dynamic textures as a lightmap */
@Unique
private boolean isLightTexture = false;
@Shadow @Shadow
@Final @Final
private NativeImage pixels; private NativeImage pixels;
@Inject(method = "Lnet/minecraft/client/renderer/texture/DynamicTexture;upload()V", at = @At("HEAD"), cancellable = true) @Inject(method = "upload()V", at = @At("HEAD"))
public void updateLightTexture(CallbackInfo ci) public void updateLightTexture(CallbackInfo ci)
{ {
// since the light map is always updated on the client render thread we should be able to access the client level at the same time // since the light map is always updated on the client render thread we should be able to access the client level at the same time
IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
if ( if (!this.isLightTexture
mc == null || || mc == null
mc.getWrappedClientLevel() == null || mc.getWrappedClientLevel() == null
) )
{
return; return;
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel(); }
//ApiShared.LOGGER.info("Lightmap update"); //ApiShared.LOGGER.info("Lightmap update");
IClientLevelWrapper clientLevel = mc.getWrappedClientLevel();
MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel); MinecraftRenderWrapper.INSTANCE.updateLightmap(this.pixels, clientLevel);
} }
public void markLightTexture() { this.isLightTexture = true; }
} }
@@ -0,0 +1,45 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2023 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.forge.mixins.client;
import com.seibel.distanthorizons.common.util.ILightTextureMarker;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LightTexture.class)
public class MixinLightTexture
{
@Shadow
@Final
private DynamicTexture lightTexture;
@Inject(method = "<init>", at = @At("RETURN"))
public void markLightTexture(CallbackInfo ci) { ((ILightTextureMarker) this.lightTexture).markLightTexture(); }
}
@@ -14,7 +14,8 @@
"client.MixinFogRenderer", "client.MixinFogRenderer",
"client.MixinGameRenderer", "client.MixinGameRenderer",
"client.MixinLevelRenderer", "client.MixinLevelRenderer",
"client.MixinLightmap", "client.MixinDynamicTexture",
"client.MixinLightTexture",
"client.MixinOptionsScreen", "client.MixinOptionsScreen",
"client.MixinTextureUtil" "client.MixinTextureUtil"
], ],
+6 -2
View File
@@ -1,6 +1,10 @@
{ {
"pack": { "pack": {
"description": "", "pack_format": 7,
"pack_format": 7 "supported_formats": {
"min_inclusive": 16,
"max_inclusive": 90000
},
"description": "Distant Horizons"
} }
} }
+4 -4
View File
@@ -5,7 +5,7 @@ org.gradle.caching=true
# Mod Info # Mod Info
mod_name=DistantHorizons mod_name=DistantHorizons
mod_version=2.0.0-a mod_version=2.0.1-a
api_version=1.0.0 api_version=1.0.0
maven_group=com.seibel.distanthorizons maven_group=com.seibel.distanthorizons
mod_readable_name=Distant Horizons mod_readable_name=Distant Horizons
@@ -13,8 +13,8 @@ mod_description=This mod generates and renders simplified terrain beyond the nor
# Note: In forge's mods.toml this is hard coded because Architectury throws an error with setting it as a varuable # Note: In forge's mods.toml this is hard coded because Architectury throws an error with setting it as a varuable
mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom"] mod_authors=["James Seibel", "Leonardo Amato", "Cola", "coolGi", "Ran", "Leetom"]
mod_homepage=https://modrinth.com/mod/distanthorizons mod_homepage=https://modrinth.com/mod/distanthorizons
mod_source=https://gitlab.com/jeseibel/minecraft-lod-mod/ mod_source=https://gitlab.com/jeseibel/distant-horizons
mod_issues=https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues mod_issues=https://gitlab.com/jeseibel/distant-horizons/-/issues
mod_discord=https://discord.gg/xAB8G4cENx mod_discord=https://discord.gg/xAB8G4cENx
# Global Plugin Versions # Global Plugin Versions
@@ -44,7 +44,7 @@ versionStr=
# This defines what MC version Intellij will use for the preprocessor # This defines what MC version Intellij will use for the preprocessor
# and what version is used automatically by build and run commands # and what version is used automatically by build and run commands
mcVer=1.20.1 mcVer=1.20.2
# Defines the maximum amount of memory Minecraft is allowed when run in a developement environment # Defines the maximum amount of memory Minecraft is allowed when run in a developement environment
minecraftMemoryJavaArg="-Xmx4G" minecraftMemoryJavaArg="-Xmx4G"