feat: rewrite MC-274911 revert (tick-mode)

This commit is contained in:
Helvetica Volubi
2025-04-20 15:53:44 +08:00
committed by MrHua269
parent ac008463d3
commit cce7e23ae1
2 changed files with 61 additions and 21 deletions

View File

@@ -21,44 +21,83 @@ index 80f17f33f670018240c854df589cf90cdeab6e70..8672757a4d5fb5c247599782fece6b8d
if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) { if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) {
serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier)); serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier));
diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java
index 2f45befbb50645f1bfb5961ad725f3670ff0d592..59cdf1e5166ae67a0dc8c7cb4028db7f1e450d46 100644 index 2f45befbb50645f1bfb5961ad725f3670ff0d592..4e2ec7f7946a70b676393f090c5ce6219314c3da 100644
--- a/net/minecraft/world/entity/raid/Raid.java --- a/net/minecraft/world/entity/raid/Raid.java
+++ b/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java
@@ -288,6 +288,24 @@ public class Raid { @@ -109,6 +109,12 @@ public class Raid {
private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY);
// Paper end
+ // Luminol Start - Raid revert
+ private boolean flagForceWin = false;
+ private boolean flag274911 = false;
+ private int freshTick = 0;
+ private int retryTimes = 0;
+ // Luminol End - Raid revert
// Folia start - make raids thread-safe
public boolean ownsRaid() {
@@ -270,7 +276,36 @@ public class Raid {
}
public void tick() {
- if (!this.isStopped()) {
+ // Luminol Start - Raid revert
+ if (this.flag274911) {
+ if (this.freshTick == 20) {
+ if (this.waveSpawnPos.isPresent() && !this.level.isPositionEntityTicking(this.waveSpawnPos.get())) {
+ this.waveSpawnPos = this.getValidSpawnPos();
+ }
+
+ BlockPos blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(20));
+ if (blockPos != null && retryTimes < 3) {
+ this.started = true;
+ this.spawnGroup(blockPos);
+ this.retryTimes = 0;
+ } else if (retryTimes == 3) {
+ this.waveSpawnPos = Optional.empty();
+ this.groupsSpawned++;
+ this.retryTimes = 0;
+ } else {
+ this.retryTimes++;
+ }
+ if (!this.hasMoreWaves()) {
+ this.flag274911 = false;
+ this.flagForceWin = true;
+ }
+ this.freshTick = 0;
+ } else {
+ this.freshTick++;
+ }
+ return;
+ }
+ if (!this.isStopped() || this.flagForceWin) { // Luminol End - Raid revert
if (this.status == Raid.RaidStatus.ONGOING) {
boolean flag = this.active;
this.active = this.level.hasChunkAt(this.center);
@@ -288,6 +323,12 @@ public class Raid {
return; return;
} }
+ // Luminol Start - Raid revert + // Luminol Start - Raid revert
+ boolean flagForceWin = false; + if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.revert_274911 && this.waveSpawnPos.isPresent() && this.center.distSqr(this.waveSpawnPos.get()) >= 12544) {
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.revert_274911) { + this.flag274911 = true;
+ if (this.waveSpawnPos.isPresent() && this.center.distSqr(this.waveSpawnPos.get()) >= 12544) {
+ while (this.hasMoreWaves()) {
+ BlockPos blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(20));
+ if (blockPos != null) {
+ this.started = true;
+ this.spawnGroup(blockPos);
+ } else {
+ break;
+ }
+ }
+ flagForceWin = true;
+ }
+ } + }
+ // Luminol End - Raid revert + // Luminol End - Raid revert
+ +
if (!this.level.isVillage(this.center)) { if (!this.level.isVillage(this.center)) {
this.moveRaidCenterToNearbyVillageSection(); this.moveRaidCenterToNearbyVillageSection();
} }
@@ -379,7 +397,7 @@ public class Raid { @@ -379,7 +420,7 @@ public class Raid {
} }
} }
- if (this.isStarted() && !this.hasMoreWaves() && totalRaidersAlive == 0) { - if (this.isStarted() && !this.hasMoreWaves() && totalRaidersAlive == 0) {
+ if (flagForceWin || (this.isStarted() && !this.hasMoreWaves() && totalRaidersAlive == 0)) { + if (this.flagForceWin || (this.isStarted() && !this.hasMoreWaves() && totalRaidersAlive == 0)) { // Luminol - Raid revert
if (this.postRaidTicks < 40) { if (this.postRaidTicks < 40) {
this.postRaidTicks++; this.postRaidTicks++;
} else { } else {
@@ -674,7 +692,7 @@ public class Raid { @@ -674,7 +715,7 @@ public class Raid {
int i2 = this.center.getX() + Mth.floor(Mth.cos(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f); int i2 = this.center.getX() + Mth.floor(Mth.cos(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f);
int i3 = this.center.getZ() + Mth.floor(Mth.sin(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f); int i3 = this.center.getZ() + Mth.floor(Mth.sin(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f);
int height = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, i2, i3); int height = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, i2, i3);

View File

@@ -1,6 +1,6 @@
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RaidChangesConfig.java +++ b/src/main/java/me/earthme/luminol/config/modules/misc/RaidChangesConfig.java
@@ -1,0 +_,51 @@ @@ -1,0 +_,52 @@
+package me.earthme.luminol.config.modules.misc; +package me.earthme.luminol.config.modules.misc;
+ +
+import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.ConfigInfo;
@@ -22,7 +22,8 @@
+ +
+ @ConfigInfo(baseName = "bad-omen-infinite", comments = + @ConfigInfo(baseName = "bad-omen-infinite", comments =
+ """ + """
+ Enable bad omen effect infinite time""") + Enable bad omen effect infinite time
+ --- this config is not old version's function""")
+ public static boolean infinite = false; + public static boolean infinite = false;
+ +
+ @ConfigInfo(baseName = "skip-height-check", comments = + @ConfigInfo(baseName = "skip-height-check", comments =