Skip to content

Commit

Permalink
Migrate to Epsilon for config files. Implement a few unused/broken co…
Browse files Browse the repository at this point in the history
…nfig options which were regressions from previous editions.
  • Loading branch information
alcatrazEscapee committed Oct 18, 2022
1 parent ddc67c8 commit f375668
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 305 deletions.
7 changes: 7 additions & 0 deletions Common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ plugins {
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}

repositories {
maven {
url = 'https://alcatrazescapee.jfrog.io/artifactory/mods'
}
}

minecraft {
version(minecraft_version)
}

dependencies {
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
compileOnly group: 'com.alcatrazescapee', name: 'epsilon', version: epsilon_version
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public static void earlySetup()
{
LOGGER.info("Early XPlatform Setup");

Config.INSTANCE.earlySetup();

PrimalWinterBlocks.BLOCKS.earlySetup();
PrimalWinterBlocks.ITEMS.earlySetup();
PrimalWinterWorldGen.Features.FEATURES.earlySetup();
Expand All @@ -41,5 +39,7 @@ public static void lateSetup()
PrimalWinterAmbience.SOUND_EVENTS.lateSetup();

PrimalWinterBlocks.registerAxeStrippables();

Config.INSTANCE.load();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static void renderFogColors(Camera camera, float partialTick, FogColorCal
final float height = Mth.cos(angle);
final float delta = Mth.clamp((height + 0.4f) / 0.8f, 0, 1);

final int colorDay = Config.INSTANCE.fogColorDay.get();
final int colorNight = Config.INSTANCE.fogColorNight.get();
final int colorDay = Config.INSTANCE.fogColorDay.getAsInt();
final int colorNight = Config.INSTANCE.fogColorNight.getAsInt();
final float red = ((colorDay >> 16) & 0xFF) * delta + ((colorNight >> 16) & 0xFF) * (1 - delta);
final float green = ((colorDay >> 8) & 0xFF) * delta + ((colorNight >> 8) & 0xFF) * (1 - delta);
final float blue = (colorDay & 0xFF) * delta + (colorNight & 0xFF) * (1 - delta);
Expand Down Expand Up @@ -123,7 +123,7 @@ else if (expectedFogDensity < prevFogDensity)
if (prevFogDensity > 0)
{
final float scaledDelta = 1 - (1 - prevFogDensity) * (1 - prevFogDensity);
final float fogDensity = Config.INSTANCE.fogDensity.get().floatValue();
final float fogDensity = Config.INSTANCE.fogDensity.getAsFloat();
final float farPlaneScale = Mth.lerp(scaledDelta, 1f, fogDensity);
final float nearPlaneScale = Mth.lerp(scaledDelta, 1f, 0.3f * fogDensity);
callback.accept(nearPlaneScale, farPlaneScale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private void noSunriseColor(float skyAngle, float tickDelta, CallbackInfoReturna
{
final float[] original = cir.getReturnValue();
final Level level = Minecraft.getInstance().level;
if (original != null && Config.INSTANCE.weatherRenderChanges.get() && level != null)
if (original != null && Config.INSTANCE.skyRenderChanges.getAsBoolean() && level != null)
{
final BlockPos pos = Minecraft.getInstance().gameRenderer.getMainCamera().getBlockPosition();
final Holder<Biome> biome = level.getBiome(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
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.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

Expand All @@ -55,7 +57,7 @@ public abstract class LevelRendererMixin
@Redirect(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;warmEnoughToRain(Lnet/minecraft/core/BlockPos;)Z"))
private boolean alwaysUseRainRendering(Biome biome, BlockPos pos)
{
if (Config.INSTANCE.weatherRenderChanges.get())
if (Config.INSTANCE.weatherRenderChanges.getAsBoolean())
{
return true;
}
Expand All @@ -66,7 +68,7 @@ private boolean alwaysUseRainRendering(Biome biome, BlockPos pos)
private int getAdjustedLightColorForSnow(BlockAndTintGetter level, BlockPos pos)
{
final int packedLight = LevelRenderer.getLightColor(level, pos);
if (Config.INSTANCE.weatherRenderChanges.get())
if (Config.INSTANCE.weatherRenderChanges.getAsBoolean())
{
// Adjusts the light color via a heuristic that mojang uses to make snow appear more white
// This targets both paths, but since we always use the rain rendering, it's fine.
Expand All @@ -82,15 +84,28 @@ private int getAdjustedLightColorForSnow(BlockAndTintGetter level, BlockPos pos)
@Inject(method = "renderSnowAndRain", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/BufferBuilder;begin(Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;Lcom/mojang/blaze3d/vertex/VertexFormat;)V"))
private void overrideWithSnowTextures(LightTexture lightTexture, float partialTick, double x, double y, double z, CallbackInfo ci)
{
if (Config.INSTANCE.weatherRenderChanges.get())
if (Config.INSTANCE.weatherRenderChanges.getAsBoolean())
{
RenderSystem.setShaderTexture(0, SNOW_LOCATION);
}
}

@ModifyConstant(method = "renderSnowAndRain", constant = {@Constant(intValue = 5), @Constant(intValue = 10)})
private int modifySnowAmount(int constant)
{
// This constant is used to control how much snow is rendered - 5 with default, 10 with fancy graphics. By default, we bump this all the way to 15.
return Config.INSTANCE.snowDensity.getAsInt();
}

@Inject(method = "tickRain", at = @At("HEAD"))
private void addExtraSnowParticlesAndSounds(Camera camera, CallbackInfo ci)
{
if (!Config.INSTANCE.snowSounds.getAsBoolean())
{
// Prevent default rain/snow sounds by setting rainSoundTime to -1, which means the if() checking it will never pass
rainSoundTime = -1;
}

final float rain = level.getRainLevel(1f) / (Minecraft.useFancyGraphics() ? 1f : 2f);
if (rain > 0f)
{
Expand Down Expand Up @@ -136,7 +151,7 @@ private void addExtraSnowParticlesAndSounds(Camera camera, CallbackInfo ci)
}

// Added
if (windSoundTime-- < 0 && Config.INSTANCE.windSounds.get())
if (windSoundTime-- < 0 && Config.INSTANCE.windSounds.getAsBoolean())
{
final BlockPos playerPos = camera.getBlockPosition();
final Entity entity = camera.getEntity();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alcatrazescapee.primalwinter.platform;

import java.nio.file.Path;
import java.util.ServiceLoader;
import java.util.function.Supplier;
import net.minecraft.core.Registry;
Expand All @@ -22,9 +23,11 @@ static <T> T find(Class<T> clazz)

<T> RegistryInterface<T> registryInterface(Registry<T> registry);

Config createConfig();

CreativeModeTab creativeTab(ResourceLocation id, Supplier<ItemStack> icon);

// Platform APIs

boolean isDedicatedClient();

Path configDir();
}
Loading

0 comments on commit f375668

Please sign in to comment.