9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-21 07:49:18 +00:00

ai raid and gen.cached_generator_settings

This commit is contained in:
NONPLAYT
2023-04-09 00:11:13 +03:00
parent 45ce8f1645
commit 6416f59f0e
2 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 8 Apr 2023 23:45:11 +0300
Subject: [PATCH] lithium: ai.raid
This patch is based on the following mixin:
"me/jellysquid/mods/lithium/mixin/ai/raid/RaidMixin.java"
By: Angeline <jellysquid3@users.noreply.github.com>
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
index 879c3bb661e24b9682b654def57c2800f4f8ca92..99f0b75ac2b1a8ac5fe8c525c72235847e6aa27f 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
@@ -107,6 +107,7 @@ public class Raid {
private Raid.RaidStatus status;
private int celebrationTicks;
private Optional<BlockPos> waveSpawnPos;
+ private boolean isBarDirty; // DivineMC - lithium: ai.raid
public Raid(int id, ServerLevel world, BlockPos pos) {
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
@@ -271,6 +272,12 @@ public class Raid {
public void tick() {
if (!this.isStopped()) {
+ // DivineMC start - lithium: ai.raid
+ if (this.isBarDirty) {
+ this.updateBossbarInternal();
+ this.isBarDirty = false;
+ }
+ // DivineMC end
if (this.status == Raid.RaidStatus.ONGOING) {
boolean flag = this.active;
@@ -637,9 +644,15 @@ public class Raid {
}
+ // DivineMC start - lithium: ai.raid
public void updateBossbar() {
+ this.isBarDirty = true;
+ }
+
+ private void updateBossbarInternal() {
this.raidEvent.setProgress(Mth.clamp(this.getHealthOfLivingRaiders() / this.totalHealth, 0.0F, 1.0F));
}
+ // DivineMC end
public float getHealthOfLivingRaiders() {
float f = 0.0F;

View File

@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 8 Apr 2023 23:55:01 +0300
Subject: [PATCH] lithium: gen.cached_generator_settings
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
index 0d8fd4eaf912eb4d40bb9f600dd2a8d5c21ab572..cf4db1a610a2bfb8f6ce4ed0d502d180b5b67f3b 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -62,12 +62,17 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
private static final BlockState AIR = Blocks.AIR.defaultBlockState();
public final Holder<NoiseGeneratorSettings> settings;
private final Supplier<Aquifer.FluidPicker> globalFluidPicker;
+ private int cachedSeaLevel; // DivineMC - lithium: gen.cached_generator_settings
public NoiseBasedChunkGenerator(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> settings) {
super(biomeSource);
this.settings = settings;
this.globalFluidPicker = Suppliers.memoize(() -> {
- return NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value());
+ // DivineMC start - lithium: gen.cached_generator_settings
+ var fluidPicker = NoiseBasedChunkGenerator.createFluidPicker((NoiseGeneratorSettings) settings.value());
+ this.cachedSeaLevel = settings.value().seaLevel();
+ return fluidPicker;
+ // DivineMC end
});
}
@@ -397,7 +402,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
@Override
public int getSeaLevel() {
- return ((NoiseGeneratorSettings) this.settings.value()).seaLevel();
+ return this.cachedSeaLevel; // DivineMC - lithium: gen.cached_generator_settings
}
@Override