Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.cominixo.betterf3.modules;

import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import me.cominixo.betterf3.utils.DebugLine;
import me.cominixo.betterf3.utils.Utils;
Expand All @@ -16,13 +17,16 @@
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.attribute.EnvironmentAttributes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.MoonPhase;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.lighting.LevelLightEngine;
Expand Down Expand Up @@ -147,17 +151,21 @@ public void update(final Minecraft client) {
if (blockY > -1) {
highestBlockServer.append(" ").append(typeString).append(": ").append(blockY);
}
}
}

if (serverWorld instanceof ServerLevel serverLevel && serverLevel.isInsideBuildHeight(blockPos.getY())) {
final float moonSize = serverLevel.getMoonBrightness(blockPos);
final long inhabitedTime;
// Local Difficulty
if (blockPos.getY() >= 0 && blockPos.getY() < 256) {
final float moonSize;
final long inhabitedTime;

inhabitedTime = serverChunk.getInhabitedTime();
final MoonPhase moonPhase = serverWorld.environmentAttributes().getDimensionValue(EnvironmentAttributes.MOON_PHASE);
moonSize = DimensionType.MOON_BRIGHTNESS_PER_PHASE[moonPhase.index()];

final DifficultyInstance localDifficulty = new DifficultyInstance(serverWorld.getDifficulty(), serverWorld.getDayTime(), inhabitedTime, moonSize);
localDifficultyString = String.format("%.2f " + I18n.get("text.betterf3.line.clamped") + ": %.2f", localDifficulty.getEffectiveDifficulty(), localDifficulty.getSpecialMultiplier());
}
}
inhabitedTime = Objects.requireNonNullElse(serverChunk, clientChunk).getInhabitedTime();

final DifficultyInstance localDifficulty = new DifficultyInstance(serverWorld.getDifficulty(), serverWorld.getDayTime(), inhabitedTime, moonSize);
localDifficultyString = String.format("%.2f " + I18n.get("text.betterf3.line.clamped") + ": %.2f", localDifficulty.getEffectiveDifficulty(), localDifficulty.getSpecialMultiplier());
}

if (integratedServer != null) {
Expand Down
2 changes: 1 addition & 1 deletion docs/changelogs/17.0.0.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! last_version=16.0.3
!
### Added
- 1.21.11 support
- 1.21.11 support