Skip to content

Commit

Permalink
Update to 1.19, and add new 1.19 biome and lighting effect compat.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvverti committed Jun 8, 2022
1 parent 9e6ef28 commit d095d00
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ dependencies {
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"

// runtime only setups
// modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// modRuntimeOnly("com.terraformersmc:modmenu:${project.mod_menu_version}") { transitive = false }
modRuntimeOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modRuntimeOnly("com.terraformersmc:modmenu:${project.mod_menu_version}") { transitive = false }
// modRuntimeOnly fabricApi.module("fabric-rendering-data-attachment-v1", project.fabric_version)
// modRuntimeOnly fabricApi.module("fabric-rendering-fluids-v1", project.fabric_version)
// modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}"
modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}"

// because Loom doesn't load Sodium's included non-mod dependency
// runtimeOnly "org.joml:joml:1.10.2"
runtimeOnly "org.joml:joml:1.10.2"
}

processResources {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19-pre1
yarn_mappings=1.19-pre1+build.7
minecraft_version=1.19
yarn_mappings=1.19+build.1
loader_version=0.14.6
# Mod Properties
mod_version = 3.1.2-snapshot
Expand All @@ -13,6 +13,6 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api
fabric_version=0.53.1+1.19
mod_menu_version=3.1.0
sodium_version=mc1.18.2-0.4.1
fabric_version=0.55.2+1.19
mod_menu_version=4.0.0
sodium_version=mc1.19-0.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
Expand All @@ -65,6 +66,12 @@ public abstract class LightmapTextureManagerMixin {
@Final
private MinecraftClient client;

@Shadow
protected abstract float getDarknessFactor(float delta);

@Shadow
protected abstract float getDarkness(LivingEntity entity, float factor, float delta);

// Vanilla block light flicker calculation is no longer compatible
// with Colormatic (as of 1.15)

Expand Down Expand Up @@ -177,6 +184,10 @@ private void onUpdate(float partialTicks, CallbackInfo info) {
} else {
nightVision = 0.0f;
}
float brightness = this.client.options.getGamma().getValue().floatValue();
float darknessScale = this.client.options.getDarknessEffectScale().getValue().floatValue();
float darknessFactor = darknessScale * this.getDarknessFactor(partialTicks);
darknessFactor = darknessScale * this.getDarkness(player, darknessFactor, partialTicks);
for(int i = 0; i < 16; i++) {
SKY_LIGHT_COLORS[i] = map.getSkyLight(i, ambience, nightVision);
BLOCK_LIGHT_COLORS[i] = map.getBlockLight(i, flickerPos, nightVision);
Expand All @@ -191,6 +202,9 @@ private void onUpdate(float partialTicks, CallbackInfo info) {
float r = Math.min(255.0f, ((skyColor & 0xff0000) >> 16) + scale * ((blockColor & 0xff0000) >> 16)) / 255.0f;
float g = Math.min(255.0f, ((skyColor & 0xff00) >> 8) + scale * ((blockColor & 0xff00) >> 8)) / 255.0f;
float b = Math.min(255.0f, (skyColor & 0xff) + scale * (blockColor & 0xff)) / 255.0f;
r = Math.max(0.0f, r - darknessFactor);
g = Math.max(0.0f, g - darknessFactor);
b = Math.max(0.0f, b - darknessFactor);
float rbright = 1.0f - r;
float gbright = 1.0f - g;
float bbright = 1.0f - b;
Expand All @@ -203,7 +217,6 @@ private void onUpdate(float partialTicks, CallbackInfo info) {
rbright = 1.0f - rbright;
gbright = 1.0f - gbright;
bbright = 1.0f - bbright;
float brightness = this.client.options.getGamma().getValue().floatValue();
r = r * (1.0f - brightness) + rbright * brightness;
g = g * (1.0f - brightness) + gbright * brightness;
b = b * (1.0f - brightness) + bbright * brightness;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.units.qual.C;

import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
Expand Down Expand Up @@ -295,6 +296,11 @@ private static Map<Identifier, ColormapProperties.ColumnBounds> createLegacyColu
// non-snow peaks -> windswept hills
map.put(BiomeKeys.JAGGED_PEAKS.getValue(), new ColormapProperties.ColumnBounds(3, 1));
map.put(BiomeKeys.STONY_PEAKS.getValue(), new ColormapProperties.ColumnBounds(3, 1));
// 1.19 wild biomes
// mangrove swamp -> swamp
map.put(BiomeKeys.MANGROVE_SWAMP.getValue(), new ColormapProperties.ColumnBounds(6, 1));
// deep dark -> ocean ¯\_(ツ)_/¯
map.put(BiomeKeys.DEEP_DARK.getValue(), new ColormapProperties.ColumnBounds(0, 1));
return map;
}

Expand Down Expand Up @@ -364,6 +370,9 @@ private static Map<Identifier, ColormapProperties.ColumnBounds> createStableColu
map.put(BiomeKeys.END_MIDLANDS.getValue(), new ColormapProperties.ColumnBounds(58, 1));
map.put(BiomeKeys.SMALL_END_ISLANDS.getValue(), new ColormapProperties.ColumnBounds(59, 1));
map.put(BiomeKeys.END_BARRENS.getValue(), new ColormapProperties.ColumnBounds(60, 1));
// 1.19
map.put(BiomeKeys.MANGROVE_SWAMP.getValue(), new ColormapProperties.ColumnBounds(61, 1));
map.put(BiomeKeys.DEEP_DARK.getValue(), new ColormapProperties.ColumnBounds(62, 1));
return map;
}
}

0 comments on commit d095d00

Please sign in to comment.