9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-21 15:59:28 +00:00

Add back Optimize random calls in chunk ticking

This commit is contained in:
Dreeam
2024-08-06 21:01:51 +08:00
parent ac42d6b697
commit 6ce6bd06d8
20 changed files with 17 additions and 47 deletions

View File

@@ -3,8 +3,6 @@ From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 16:45:45 +0100
Subject: [PATCH] Optimize random calls in chunk ticking
Removed since 1.21
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
@@ -53,31 +51,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index ccd6a21e502bfd25a0a84fdf1b6d6f2606cf7156..4c4f4d862b898837e498486ae9e710891158702e 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -430,6 +430,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
}
}
+ this.level.resetIceAndSnowTick(); // Gale - Airplane - optimize random calls in chunk ticking - reset ice & snow tick random
if (this.level.tickRateManager().runsNormally()) {
this.level.timings.countNaturalMobs.startTiming(); // Paper - timings
int k = this.distanceManager.getNaturalSpawnChunkCount();
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index f027997cb227bbadf6000ddb236fa6622304216d..c7c83e99d0683ef6d057e56d1adc6d68424329a2 100644
index 7aa13de4b3778e6708ed46ddcedde100f585a40f..2df8f9f7c631f7c4a67cfcaf218de1d29448d489 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -858,13 +858,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
}
// Paper end - optimise random ticking
+ private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.random.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking
+
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
ChunkPos chunkcoordintpair = chunk.getPos();
boolean flag = this.isRaining();
@@ -840,7 +840,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
int j = chunkcoordintpair.getMinBlockX();
int k = chunkcoordintpair.getMinBlockZ();
@@ -86,17 +64,8 @@ index f027997cb227bbadf6000ddb236fa6622304216d..c7c83e99d0683ef6d057e56d1adc6d68
BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15));
if (this.isRainingAt(blockposition)) {
@@ -892,7 +894,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
}
}
- if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow
+ if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Option to disable ice and snow // Gale - Airplane - optimize random calls in chunk ticking - optimize further random ticking
for (int l = 0; l < randomTickSpeed; ++l) {
if (this.random.nextInt(48) == 0) {
this.tickPrecipitation(this.getBlockRandomPos(j, 0, k, 15));
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index b07763aa7b3b92e24891b4ba346334ba8984ed67..4d04efcc4c902c1c108d142b9486d080aff7cd44 100644
index 36540053590c30a902b9986dcf2e74375157822d..f23ed06a943646f45e1291f35ab3025e1dfa6b49 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -85,6 +85,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -118,11 +87,12 @@ index b07763aa7b3b92e24891b4ba346334ba8984ed67..4d04efcc4c902c1c108d142b9486d080
public LevelChunk(Level world, ChunkPos pos) {
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
}
@@ -108,6 +120,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
this.postLoad = entityLoader;
this.blockTicks = blockTickScheduler;
this.fluidTicks = fluidTickScheduler;
+ this.lightningTick = this.level.random.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick
// Paper start - get block chunk optimisation
this.minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(level);
this.maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(level);
@@ -116,6 +128,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
this.debug = !empty && this.level.isDebug();
this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE;
// Paper end - get block chunk optimisation
+
+ this.lightningTick = new java.util.Random().nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick
}
// CraftBukkit start

View File

@@ -31,7 +31,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 7aa13de4b3778e6708ed46ddcedde100f585a40f..1f2af396b7cddbbbb9a200bc6272309941f10e5b 100644
index 2df8f9f7c631f7c4a67cfcaf218de1d29448d489..bfefe93b1ab4facd4874210609ecbe244a4cff0d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -717,7 +717,20 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.

View File

@@ -31,7 +31,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a0ed1ffbf07edeb4d7f08316855376488b99940b..dfc1f3b3097430f1553b0a0b03d7be3863d14c11 100644
index 2d3552ed0772d7bd7777b85879c10ca83c4baf37..7349dee46483632cffa88d11694e2cd3a6fad911 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4434,16 +4434,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

View File

@@ -22,7 +22,7 @@ you to easily disable books, should you want to preemptively remove this
functionality before additional exploits are found.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 7796e191747be545e744564a2b0b65790f69114d..13adcb90134f03cf951c3e7eaa3123e033224df6 100644
index 624b80c796e9c95040d71d1595d11f98e2899cf3..0563a4273f8cbb4ca9af52f6f708d43967575252 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -193,6 +193,8 @@ import net.minecraft.world.phys.Vec3;

View File

@@ -13,7 +13,7 @@ As part of: JettPack (https://gitlab.com/Titaniumtown/JettPack)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8e79c569eb6b49382d1335ab8a247506db6afe95..8fe992f191819f828ebc5c1986572569a09d52a9 100644
index 7349dee46483632cffa88d11694e2cd3a6fad911..93c48dd6b87d5bb7ba5a83b7c0f6c64544416bfc 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -314,7 +314,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -22,7 +22,7 @@ index 8e79c569eb6b49382d1335ab8a247506db6afe95..8fe992f191819f828ebc5c1986572569
public double zo;
- private Vec3 position;
+ public Vec3 position; // Gale - JettPack - optimize sun burn tick - private -> public
public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public
private BlockPos blockPosition;
private ChunkPos chunkPosition;
private Vec3 deltaMovement;
@@ -2061,9 +2061,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess