diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..5083229 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/gradlew.bat b/gradlew.bat index f127cfd..93e3f59 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/src/main/java/me/pepperbell/continuity/client/ContinuityClient.java b/src/main/java/me/pepperbell/continuity/client/ContinuityClient.java index 9c12b21..66acc4d 100644 --- a/src/main/java/me/pepperbell/continuity/client/ContinuityClient.java +++ b/src/main/java/me/pepperbell/continuity/client/ContinuityClient.java @@ -35,6 +35,7 @@ import me.pepperbell.continuity.client.properties.overlay.StandardConnectingOverlayCTMProperties; import me.pepperbell.continuity.client.properties.overlay.StandardOverlayCTMProperties; import me.pepperbell.continuity.client.resource.CustomBlockLayers; +import me.pepperbell.continuity.client.resource.EmissiveIdProvider; import me.pepperbell.continuity.client.util.RenderUtil; import me.pepperbell.continuity.client.util.biome.BiomeHolderManager; import me.pepperbell.continuity.client.util.biome.BiomeRetriever; @@ -55,6 +56,7 @@ public void onInitializeClient() { ProcessingDataKeyRegistryImpl.INSTANCE.init(); BiomeHolderManager.init(); BiomeRetriever.init(); + EmissiveIdProvider.init(); ProcessingDataKeys.init(); RenderUtil.ReloadListener.init(); CustomBlockLayers.ReloadListener.init(); diff --git a/src/main/java/me/pepperbell/continuity/client/mixin/ChunkRendererRegionMixin.java b/src/main/java/me/pepperbell/continuity/client/mixin/ChunkRendererRegionMixin.java index 007ae2d..6f17581 100644 --- a/src/main/java/me/pepperbell/continuity/client/mixin/ChunkRendererRegionMixin.java +++ b/src/main/java/me/pepperbell/continuity/client/mixin/ChunkRendererRegionMixin.java @@ -4,7 +4,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import me.pepperbell.continuity.client.util.biome.BiomeView; +import me.pepperbell.continuity.client.mixinterface.ChunkRendererRegionExtension; import net.minecraft.client.render.chunk.ChunkRendererRegion; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryEntry; @@ -12,7 +12,7 @@ import net.minecraft.world.biome.Biome; @Mixin(ChunkRendererRegion.class) -public class ChunkRendererRegionMixin implements BiomeView { +public class ChunkRendererRegionMixin implements ChunkRendererRegionExtension { @Shadow @Final protected World world; diff --git a/src/main/java/me/pepperbell/continuity/client/mixin/SpriteAtlasTextureMixin.java b/src/main/java/me/pepperbell/continuity/client/mixin/SpriteAtlasTextureMixin.java index bfb8f1a..6806e53 100644 --- a/src/main/java/me/pepperbell/continuity/client/mixin/SpriteAtlasTextureMixin.java +++ b/src/main/java/me/pepperbell/continuity/client/mixin/SpriteAtlasTextureMixin.java @@ -18,6 +18,7 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import me.pepperbell.continuity.client.mixinterface.SpriteAtlasTextureDataExtension; import me.pepperbell.continuity.client.mixinterface.SpriteExtension; +import me.pepperbell.continuity.client.resource.EmissiveIdProvider; import me.pepperbell.continuity.client.resource.EmissiveSuffixLoader; import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.SpriteAtlasTexture; @@ -57,8 +58,8 @@ private Identifier getTexturePath(Identifier id) { continuity$emissiveIdMap = new Object2ObjectOpenHashMap<>(); for (Sprite.Info spriteInfo : spriteInfos) { Identifier id = spriteInfo.getId(); - if (!id.getPath().endsWith(emissiveSuffix)) { - Identifier emissiveId = new Identifier(id.getNamespace(), id.getPath() + emissiveSuffix); + Identifier emissiveId = EmissiveIdProvider.toEmissiveId(id, emissiveSuffix); + if (emissiveId != null) { Identifier emissiveLocation = getTexturePath(emissiveId); if (resourceManager.getResource(emissiveLocation).isPresent()) { emissiveIds.add(emissiveId); diff --git a/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeView.java b/src/main/java/me/pepperbell/continuity/client/mixinterface/ChunkRendererRegionExtension.java similarity index 65% rename from src/main/java/me/pepperbell/continuity/client/util/biome/BiomeView.java rename to src/main/java/me/pepperbell/continuity/client/mixinterface/ChunkRendererRegionExtension.java index 7888bcb..b71d228 100644 --- a/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeView.java +++ b/src/main/java/me/pepperbell/continuity/client/mixinterface/ChunkRendererRegionExtension.java @@ -1,9 +1,9 @@ -package me.pepperbell.continuity.client.util.biome; +package me.pepperbell.continuity.client.mixinterface; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryEntry; import net.minecraft.world.biome.Biome; -public interface BiomeView { +public interface ChunkRendererRegionExtension { RegistryEntry continuity$getBiome(BlockPos pos); } diff --git a/src/main/java/me/pepperbell/continuity/client/resource/EmissiveIdProvider.java b/src/main/java/me/pepperbell/continuity/client/resource/EmissiveIdProvider.java new file mode 100644 index 0000000..ab3d647 --- /dev/null +++ b/src/main/java/me/pepperbell/continuity/client/resource/EmissiveIdProvider.java @@ -0,0 +1,64 @@ +package me.pepperbell.continuity.client.resource; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.util.Identifier; + +public final class EmissiveIdProvider { + private static final Provider PROVIDER = createProvider(); + + private static Provider createProvider() { + if (FabricLoader.getInstance().isModLoaded("citresewn-defaults")) { + return EmissiveIdProvider::toEmissiveIdCITR; + } + + return EmissiveIdProvider::toEmissiveIdStandard; + } + + @Nullable + public static Identifier toEmissiveId(Identifier spriteId, String emissiveSuffix) { + return PROVIDER.toEmissiveId(spriteId, emissiveSuffix); + } + + @ApiStatus.Internal + public static void init() { + } + + @Nullable + private static Identifier toEmissiveIdStandard(Identifier spriteId, String emissiveSuffix) { + String path = spriteId.getPath(); + if (!path.endsWith(emissiveSuffix)) { + return new Identifier(spriteId.getNamespace(), path + emissiveSuffix); + } + return null; + } + + /** + * Sprite identifiers never have an extension in vanilla. CIT Resewn adds a png extension to some identifiers and + * changes SpriteAtlasTexture#getTexturePath to interpret those identifiers as absolute texture locations. This code + * accounts for the possibility of the identifier having a png extension and appends the emissive suffix before it. + */ + @Nullable + private static Identifier toEmissiveIdCITR(Identifier spriteId, String emissiveSuffix) { + String path = spriteId.getPath(); + boolean hasExtension = path.endsWith(".png"); + if (hasExtension) { + path = path.substring(0, path.length() - 4); + } + if (!path.endsWith(emissiveSuffix)) { + String emissivePath = path + emissiveSuffix; + if (hasExtension) { + emissivePath += ".png"; + } + return new Identifier(spriteId.getNamespace(), emissivePath); + } + return null; + } + + private interface Provider { + @Nullable + Identifier toEmissiveId(Identifier spriteId, String emissiveSuffix); + } +} diff --git a/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeRetriever.java b/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeRetriever.java index 97b8f1f..ff645ed 100644 --- a/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeRetriever.java +++ b/src/main/java/me/pepperbell/continuity/client/util/biome/BiomeRetriever.java @@ -6,6 +6,7 @@ import grondag.canvas.terrain.region.input.InputRegion; import me.jellysquid.mods.sodium.client.world.WorldSlice; +import me.pepperbell.continuity.client.mixinterface.ChunkRendererRegionExtension; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.render.chunk.ChunkRendererRegion; import net.minecraft.util.math.BlockPos; @@ -41,7 +42,7 @@ private static Provider createProvider() { return BiomeRetriever::getBiomeByWorldView; } - if (ArrayUtils.contains(ChunkRendererRegion.class.getInterfaces(), BiomeView.class)) { + if (ArrayUtils.contains(ChunkRendererRegion.class.getInterfaces(), ChunkRendererRegionExtension.class)) { return BiomeRetriever::getBiomeByExtension; } return BiomeRetriever::getBiomeByWorldView; @@ -56,6 +57,7 @@ public static Biome getBiome(BlockRenderView blockView, BlockPos pos) { public static void init() { } + @Nullable private static Biome getBiomeByWorldView(BlockRenderView blockView, BlockPos pos) { if (blockView instanceof WorldView worldView) { return worldView.getBiome(pos).value(); @@ -63,14 +65,16 @@ private static Biome getBiomeByWorldView(BlockRenderView blockView, BlockPos pos return null; } + @Nullable private static Biome getBiomeByExtension(BlockRenderView blockView, BlockPos pos) { - if (blockView instanceof BiomeView biomeView) { - return biomeView.continuity$getBiome(pos).value(); + if (blockView instanceof ChunkRendererRegionExtension extension) { + return extension.continuity$getBiome(pos).value(); } return getBiomeByWorldView(blockView, pos); } // Sodium + @Nullable private static Biome getBiomeByWorldSlice(BlockRenderView blockView, BlockPos pos) { if (blockView instanceof WorldSlice worldSlice) { return worldSlice.getBiomeAccess().getBiome(pos).value(); @@ -79,6 +83,7 @@ private static Biome getBiomeByWorldSlice(BlockRenderView blockView, BlockPos po } // Canvas + @Nullable private static Biome getBiomeByInputRegion(BlockRenderView blockView, BlockPos pos) { if (blockView instanceof InputRegion inputRegion) { return inputRegion.getBiome(pos); @@ -87,6 +92,7 @@ private static Biome getBiomeByInputRegion(BlockRenderView blockView, BlockPos p } private interface Provider { + @Nullable Biome getBiome(BlockRenderView blockView, BlockPos pos); } }