Skip to content

Commit

Permalink
dependency fix
Browse files Browse the repository at this point in the history
formatting
  • Loading branch information
lever1209 committed Feb 5, 2024
1 parent db62f51 commit 3ac3fad
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 64 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ dependencies {
// annotationProcessor "com.github.LlamaLad7:MixinExtras:0.1.0-rc5"

// implementation 'me.nullicorn:Nedit:2.2.0' // temporary unless proven useful
include modApi("org.snakeyaml:snakeyaml-engine:${snakeyaml_engine_version}")
// not sure why the old lib suddenly stopped working but this works for now
include modApi("org.yaml:snakeyaml:${snakeyaml_version}")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ archives_base_name = pandora
modmenu_version=4.0.4
# will crash if updated
#slf4j_simple_version=1.7.9
snakeyaml_engine_version=2.4
snakeyaml_version=2.2
# 8.2.88
#cloth_config_version=8.3.103
# https://maven.gegy.dev/dev/lambdaurora/spruceui/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public void init() {

this.addDrawableChild(
new ButtonWidget(buttonPosX * buttonWidth - buttonWidthPadding + centerOffsetHorizontalPosition,
Math.min(buttonPosY++ * buttonHeight - buttonHeightPadding + centerOffsetVerticalPosition, height-buttonHeight),
Math.min(buttonPosY++ * buttonHeight - buttonHeightPadding + centerOffsetVerticalPosition,
height - buttonHeight),
buttonWidth - (buttonWidthPadding * 2), buttonHeight - (buttonHeightPadding * 2),
Text.translatable("pandora.menu.return"), (ButtonWidget var1) -> {
this.client.setScreen(this.parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public class NativeImageBackedTextureMixin implements TextureAccess {

@Inject(method = "upload", at = @At(value = "HEAD"))
private void onUpload(CallbackInfo ci) {

// log.info("ON{}",enableHook && DarknessTools.ENABLE_WORKSPACE_DARKNESS && image != null);

if (enableHook && DarknessTools.ENABLE_WORKSPACE_DARKNESS && image != null) {
// final NativeImage img = image;

for (int b = 0; b < 16; b++) {
for (int s = 0; s < 16; s++) {
int color = DarknessTools.darken(image.getColor(b, s), b, s);

image.setColor(b, s, color);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pkg/deepCurse/pandora/common/Pandora.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void registerCallbacks() {
RegistryEntryAddedCallback.event(Registry.BLOCK).register(BlockRegisterCallback::onEntryAdded);

callbacksRegistered = true;

log.info("[Pandora] Finished registering callbacks.");
}

Expand Down
61 changes: 30 additions & 31 deletions src/main/java/pkg/deepCurse/pandora/common/PandoraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PandoraConfig {

public static class Enabled {
public static PandoraConfig.Enabled ENABLED;

public boolean EnablePandora = true;
public boolean EnableCustomFog = true;
public boolean EnableCustomAI = true;
Expand All @@ -42,7 +42,7 @@ public static class Enabled {
@Environment(EnvType.CLIENT)
public static class Client {
public static PandoraConfig.Client CLIENT;

// TODO re implement?
public boolean ResetGamma;
public float GammaValue;
Expand All @@ -68,7 +68,7 @@ public String toString() {

// @Environment(EnvType.SERVER)
public static class Server {

public static PandoraConfig.Server SERVER;

public boolean GruesEatItems = true;
Expand Down Expand Up @@ -154,8 +154,8 @@ public static class DimensionSetting {
public int minimumFadeLightLevel;
public boolean gruesAttackInWater;

public DimensionSetting(boolean infested, boolean ignoreSkyLight,
boolean lockMoonPhase, int targetMoonPhase, int minimumSafeLightLevel, int minimumFadeLightLevel,
public DimensionSetting(boolean infested, boolean ignoreSkyLight, boolean lockMoonPhase,
int targetMoonPhase, int minimumSafeLightLevel, int minimumFadeLightLevel,
boolean gruesAttackInWater) {
this.infested = infested;
this.minimumSafeLightLevel = minimumSafeLightLevel;
Expand Down Expand Up @@ -216,7 +216,7 @@ public String toString() {

public static class Debug {
public static PandoraConfig.Debug DEBUG;

public float flameLightSourceDecayRate = 1.0f;
public boolean forceGruesAlwaysAttack = false;

Expand Down Expand Up @@ -473,8 +473,8 @@ public static void loadServerConfigFromInputStream(InputStream is) {
var gruesAttackInWater = Boolean.parseBoolean(dim.get("grues attack in water").toString());

server.DimensionSettings.put(id,
new Server.DimensionSetting(infested, ignoreSkyLight, lockMoonPhase,
targetMoonPhase, minimumSafeLightLevel, minimumFadeLightLevel, gruesAttackInWater));
new Server.DimensionSetting(infested, ignoreSkyLight, lockMoonPhase, targetMoonPhase,
minimumSafeLightLevel, minimumFadeLightLevel, gruesAttackInWater));
}
}
}
Expand Down Expand Up @@ -549,37 +549,37 @@ public static void loadClientConfigFromInputStream(InputStream is) {
LinkedHashMap<String, Object> rootMap = yaml.load(is);

Client client = new Client();

client.DimensionSettings = new LinkedHashMap<>();

client.ResetGamma = Boolean.parseBoolean(rootMap.getOrDefault("reset gamma", client.ResetGamma).toString());
client.GammaValue = Float.parseFloat(rootMap.getOrDefault("gamma value", client.GammaValue).toString());

// dimension settings
{
@SuppressWarnings("unchecked") // if i could do this without casting i would
ArrayList<HashMap<String, Object>> dimensionSettings = (ArrayList<HashMap<String, Object>>) rootMap
.get("dimension settings");
{
@SuppressWarnings("unchecked") // if i could do this without casting i would
ArrayList<HashMap<String, Object>> dimensionSettings = (ArrayList<HashMap<String, Object>>) rootMap
.get("dimension settings");

for (HashMap<String, ?> dim : dimensionSettings) {
for (HashMap<String, ?> dim : dimensionSettings) {

@SuppressWarnings("unchecked") // if i could do this without casting i would
ArrayList<String> identifiers = (ArrayList<String>) dim.get("ids");
@SuppressWarnings("unchecked") // if i could do this without casting i would
ArrayList<String> identifiers = (ArrayList<String>) dim.get("ids");

if (identifiers == null) {
throw new IllegalArgumentException(
"Element does not contain required key \"ids\", please add it to the element. (" + dim
+ ")");
}
if (identifiers == null) {
throw new IllegalArgumentException(
"Element does not contain required key \"ids\", please add it to the element. (" + dim
+ ")");
}

for (var cid : identifiers) {
for (var cid : identifiers) {

// TODO replace clamps with errors?
// TODO replace clamps with errors?

var id = new Identifier(cid);
var fogFactor = MathHelper.clamp(Float.parseFloat(dim.get("fog factor").toString()), 0f, 1f);
var id = new Identifier(cid);
var fogFactor = MathHelper.clamp(Float.parseFloat(dim.get("fog factor").toString()), 0f, 1f);
// var infested = Boolean.parseBoolean(dim.get("infested").toString());
var isDark = Boolean.parseBoolean(dim.get("is dark").toString());
var isDark = Boolean.parseBoolean(dim.get("is dark").toString());
// var ignoreSkyLight = Boolean.parseBoolean(dim.get("ignore sky light").toString());
// var lockMoonPhase = Boolean.parseBoolean(dim.get("lock moon phase").toString());
// var targetMoonPhase = MathHelper.clamp(Integer.parseInt(dim.get("target moon phase").toString()), 0,
Expand All @@ -590,12 +590,11 @@ public static void loadClientConfigFromInputStream(InputStream is) {
// .clamp(Integer.parseInt(dim.get("minimum fade light level").toString()), 0, 15);
// var gruesAttackInWater = Boolean.parseBoolean(dim.get("grues attack in water").toString());

client.DimensionSettings.put(id,
new Client.DimensionSetting(fogFactor, isDark));
}
}
client.DimensionSettings.put(id, new Client.DimensionSetting(fogFactor, isDark));
}

}
}

Client.CLIENT = client;
log.info("[Pandora] Client config loaded.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static void onEndTick(ServerWorld world) {
log.info("on fire");
continue;
}

// if uses fully submerged it can get annoying while swimming
if (livingEntity.isTouchingWater() && !dimensionSettings.gruesAttackInWater) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import pkg.deepCurse.pandora.common.PandoraConfig.Client;

/**
* I dont know how or why, but whenever i touch anything in this entire class it breaks silently
* I dont know how or why, but whenever i touch anything in this entire class it
* breaks silently
*
* so far ive wasted 12 hours debugging it and trying to fix it
*/
Expand All @@ -31,29 +32,29 @@ public class DarknessTools {
// }

private static float skyFactor(World world) {
var dimSettings = PandoraConfig.Server.SERVER.DimensionSettings.get(world.getRegistryKey().getValue());
var dimSettings = PandoraConfig.Server.SERVER.DimensionSettings.get(world.getRegistryKey().getValue());

if (!world.getDimension().hasSkyLight()) {
return 0;
}
if (!world.getDimension().hasSkyLight()) {
return 0;
}

if (world.getDimension().hasSkyLight() && dimSettings.ignoreSkyLight) {
return 1;
}
if (world.getDimension().hasSkyLight() && dimSettings.ignoreSkyLight) {
return 1;
}

final float angle = world.getSkyAngle(0);
final float angle = world.getSkyAngle(0);

if (angle > 0.25f && angle < 0.75f) { // TODO fine tune these angles
final float oldWeight = Math.max(0, (Math.abs(angle - 0.5f) - 0.2f)) * 20;
// {1.0f, 0.75f, 0.5f, 0.25f, 0.0f, 0.25f, 0.5f, 0.75f}
final float moon = DimensionType.MOON_SIZES[dimSettings.lockMoonPhase ? dimSettings.targetMoonPhase
: world.getDimension().getMoonPhase(world.getLunarTime())];

return MathHelper.lerp(oldWeight * oldWeight * oldWeight, moon * moon, 1f);
}
if (angle > 0.25f && angle < 0.75f) { // TODO fine tune these angles
final float oldWeight = Math.max(0, (Math.abs(angle - 0.5f) - 0.2f)) * 20;
// {1.0f, 0.75f, 0.5f, 0.25f, 0.0f, 0.25f, 0.5f, 0.75f}
final float moon = DimensionType.MOON_SIZES[dimSettings.lockMoonPhase ? dimSettings.targetMoonPhase
: world.getDimension().getMoonPhase(world.getLunarTime())];

return 1;
}
return MathHelper.lerp(oldWeight * oldWeight * oldWeight, moon * moon, 1f);
}

return 1;
}

private static final float[][] LUMINANCE = new float[16][16];

Expand All @@ -73,17 +74,17 @@ public static int darken(int c, int blockIndex, int skyIndex) {
public static float luminance(float r, float g, float b) {
return r * 0.2126f + g * 0.7152f + b * 0.0722f;
}

public static boolean ENABLE_WORKSPACE_DARKNESS = true;
public static void updateLuminance(float tickDelta, MinecraftClient client,
GameRenderer worldRenderer, float prevFlicker) { // TODO fix this up

public static void updateLuminance(float tickDelta, MinecraftClient client, GameRenderer worldRenderer,
float prevFlicker) { // TODO fix this up
final ClientWorld world = client.world;

final boolean isDark = Client.CLIENT.DimensionSettings.get(world.getRegistryKey().getValue()).isDark;

// Pandora.log.info("{}", isDark);

if (world != null) {
if (!isDark || client.player.hasStatusEffect(StatusEffects.NIGHT_VISION)
|| (client.player.hasStatusEffect(StatusEffects.CONDUIT_POWER)
Expand Down

0 comments on commit 3ac3fad

Please sign in to comment.