Skip to content

Commit 68832fc

Browse files
committed
Add comment
1 parent 3d7010c commit 68832fc

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/main/java/org/visuals/legacy/animatium/util/Utils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import net.minecraft.world.entity.player.Player;
4848
import net.minecraft.world.inventory.InventoryMenu;
4949
import net.minecraft.world.level.GameType;
50+
import net.minecraft.world.level.LevelReader;
5051
import net.minecraft.world.phys.BlockHitResult;
5152
import net.minecraft.world.phys.HitResult;
5253
import net.minecraft.world.phys.Vec3;
@@ -180,4 +181,13 @@ public static boolean isSingleplayer() {
180181
final IntegratedServer server = Minecraft.getInstance().getSingleplayerServer();
181182
return server != null && server.isSingleplayer();
182183
}
184+
185+
public static float getBrightness(final LevelReader reader, final BlockPos blockPos) {
186+
final float amount = reader.getMaxLocalRawBrightness(blockPos) / 15.0F;
187+
return Mth.lerp(reader.dimensionType().ambientLight(), amount / (4.0F - 3.0F * amount), 1.0F);
188+
}
189+
190+
public static float getBrightness(final Entity entity) {
191+
return getBrightness(entity.level(), entity.blockPosition()); // Older versions inspected from the foot position, not eye position
192+
}
183193
}

src/main/java/org/visuals/legacy/animatium/util/rendering/LegacyFogDarkness.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525

2626
package org.visuals.legacy.animatium.util.rendering;
2727

28-
import net.minecraft.core.BlockPos;
2928
import net.minecraft.util.Mth;
3029
import net.minecraft.world.entity.Entity;
31-
import net.minecraft.world.level.LevelReader;
30+
import org.visuals.legacy.animatium.util.Utils;
3231

3332
public final class LegacyFogDarkness {
3433
public static final LegacyFogDarkness INSTANCE = new LegacyFogDarkness();
@@ -41,17 +40,10 @@ public final class LegacyFogDarkness {
4140

4241
public void tick(final Entity entity, final int viewDistance) {
4342
this.prevDarkness = this.darkness;
44-
this.darkness = Mth.lerp(0.1F, this.darkness, Mth.lerp(this.getBrightness(entity), viewDistance / 32.0F, 1.0F));
43+
this.darkness = Mth.lerp(0.1F, this.darkness, Mth.lerp(Utils.getBrightness(entity), viewDistance / 32.0F, 1.0F));
4544
}
4645

4746
public float getDarkness(final float tickDelta) {
4847
return Mth.lerp(tickDelta, this.prevDarkness, this.darkness);
4948
}
50-
51-
private float getBrightness(final Entity entity) {
52-
final LevelReader reader = entity.level();
53-
final BlockPos blockPos = entity.blockPosition();
54-
final float amount = reader.getMaxLocalRawBrightness(blockPos) / 15.0F;
55-
return Mth.lerp(reader.dimensionType().ambientLight(), amount / (4.0F - 3.0F * amount), 1.0F);
56-
}
5749
}

0 commit comments

Comments
 (0)