Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit 85035a2

Browse files
committed
More smaller optimizations
1 parent eef22db commit 85035a2

4 files changed

+198
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From 625cf2d9d9579441474dd94f7a3fc19a5c9cc2c0 Mon Sep 17 00:00:00 2001
2+
From: Peridot <[email protected]>
3+
Date: Fri, 23 Sep 2022 21:56:36 +0200
4+
Subject: [PATCH] Option to disable chunk ticking
5+
6+
7+
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
8+
index 02c90ea85..566b46b56 100644
9+
--- a/src/main/java/net/minecraft/server/WorldServer.java
10+
+++ b/src/main/java/net/minecraft/server/WorldServer.java
11+
@@ -405,6 +405,9 @@ public class WorldServer extends World implements IAsyncTaskHandler {
12+
}
13+
14+
protected void h() {
15+
+ if (this.server.server.titaniumServer.getServerConfig().gameMechanics.disableChunkTicking) {
16+
+ return;
17+
+ }
18+
super.h();
19+
if (this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
20+
// Spigot start
21+
diff --git a/src/main/java/net/titanium/config/TitaniumConfig.java b/src/main/java/net/titanium/config/TitaniumConfig.java
22+
index f343e4e7a..9918f22d3 100644
23+
--- a/src/main/java/net/titanium/config/TitaniumConfig.java
24+
+++ b/src/main/java/net/titanium/config/TitaniumConfig.java
25+
@@ -107,6 +107,11 @@ public class TitaniumConfig extends TitaniumConfigSection {
26+
@Comment("Of course it's not vanilla mechanic.")
27+
public boolean disableStatistics = false;
28+
29+
+ @Comment("Whether to disable chunk ticking.")
30+
+ @Comment("It could be huge performance improvement, but also could cause a lot of issues.")
31+
+ @Comment("Be careful with this option and use it only if you know what are you doing.")
32+
+ public boolean disableChunkTicking = false;
33+
+
34+
}
35+
36+
@Comment("The max NBT size in bytes. The default value is 2097152 which is ~2Mb - it's insane big.")
37+
--
38+
2.36.0.windows.1
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 7ea876d024b336a8fdaaf45702d4dfd1719d368f Mon Sep 17 00:00:00 2001
2+
From: Peridot <[email protected]>
3+
Date: Fri, 23 Sep 2022 22:00:56 +0200
4+
Subject: [PATCH] Don't look for chunk twice
5+
6+
7+
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
8+
index 8b5b679d6..3cf264f72 100644
9+
--- a/src/main/java/org/spigotmc/ActivationRange.java
10+
+++ b/src/main/java/org/spigotmc/ActivationRange.java
11+
@@ -128,9 +128,12 @@ public class ActivationRange
12+
{
13+
for ( int j1 = k; j1 <= l; ++j1 )
14+
{
15+
- if ( world.getWorld().isChunkLoaded( i1, j1 ) )
16+
+ // Titanium start - don't look for chunk twice
17+
+ Chunk chunk = world.getChunkIfLoaded(i1, j1);
18+
+ if (chunk != null)
19+
{
20+
- activateChunkEntities( world.getChunkAt( i1, j1 ) );
21+
+ activateChunkEntities(chunk);
22+
+ // Titanium end
23+
}
24+
}
25+
}
26+
--
27+
2.36.0.windows.1
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From af4b6799eef25f07d4f08687d09fb058fa64d2a2 Mon Sep 17 00:00:00 2001
2+
From: Peridot <[email protected]>
3+
Date: Fri, 23 Sep 2022 22:12:12 +0200
4+
Subject: [PATCH] Option to disable explosion particles
5+
6+
7+
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
8+
index e3f989481..f99cd3a61 100644
9+
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
10+
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
11+
@@ -1,5 +1,6 @@
12+
package net.minecraft.server;
13+
14+
+import net.titanium.config.TitaniumConfig;
15+
import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
16+
17+
public class EntityTNTPrimed extends Entity {
18+
@@ -90,6 +91,7 @@ public class EntityTNTPrimed extends Entity {
19+
// CraftBukkit end
20+
} else {
21+
this.W();
22+
+ if (TitaniumConfig.get().gameMechanics.disableExplosionParticles) return; // Titanium - Option to disable explosion particles
23+
this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
24+
}
25+
26+
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
27+
index ee4cd2c6e..e6a8cbfb9 100644
28+
--- a/src/main/java/net/minecraft/server/Explosion.java
29+
+++ b/src/main/java/net/minecraft/server/Explosion.java
30+
@@ -239,11 +239,13 @@ public class Explosion {
31+
float volume = source instanceof EntityTNTPrimed ? world.paperConfigTitanium.tntExplosionVolume : 4.0F;
32+
this.world.makeSound(this.posX, this.posY, this.posZ, "random.explode", volume, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F);
33+
// PaperSpigot end
34+
+ if (!TitaniumConfig.get().gameMechanics.disableExplosionParticles) { // Titanium - Option to disable explosion particles
35+
if (this.size >= 2.0F && this.b) {
36+
this.world.addParticle(EnumParticle.EXPLOSION_HUGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]);
37+
} else {
38+
this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D, new int[0]);
39+
}
40+
+ }
41+
42+
Iterator iterator;
43+
BlockPosition blockposition;
44+
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
45+
index 566b46b56..0ca4bb063 100644
46+
--- a/src/main/java/net/minecraft/server/WorldServer.java
47+
+++ b/src/main/java/net/minecraft/server/WorldServer.java
48+
@@ -1103,6 +1103,11 @@ public class WorldServer extends World implements IAsyncTaskHandler {
49+
explosion.clearBlocks();
50+
}
51+
52+
+ // Titanium start - Option to disable explosion particles
53+
+ if (this.server.server.titaniumServer.getServerConfig().gameMechanics.disableExplosionParticles) {
54+
+ return explosion;
55+
+ }
56+
+ // Titanium end
57+
Iterator iterator = this.players.iterator();
58+
59+
while (iterator.hasNext()) {
60+
diff --git a/src/main/java/net/titanium/config/TitaniumConfig.java b/src/main/java/net/titanium/config/TitaniumConfig.java
61+
index 9918f22d3..e88bf134e 100644
62+
--- a/src/main/java/net/titanium/config/TitaniumConfig.java
63+
+++ b/src/main/java/net/titanium/config/TitaniumConfig.java
64+
@@ -112,6 +112,10 @@ public class TitaniumConfig extends TitaniumConfigSection {
65+
@Comment("Be careful with this option and use it only if you know what are you doing.")
66+
public boolean disableChunkTicking = false;
67+
68+
+ @Comment("Whether to disable explosion particles.")
69+
+ @Comment("Mostly optimization for clients.")
70+
+ public boolean disableExplosionParticles = false;
71+
+
72+
}
73+
74+
@Comment("The max NBT size in bytes. The default value is 2097152 which is ~2Mb - it's insane big.")
75+
--
76+
2.36.0.windows.1
77+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From 8301fba7435c7cf101de6750f42db662a80b3894 Mon Sep 17 00:00:00 2001
2+
From: Peridot <[email protected]>
3+
Date: Fri, 23 Sep 2022 22:17:59 +0200
4+
Subject: [PATCH] Option to disable TNT in water sync
5+
6+
7+
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
8+
index f99cd3a61..c0b2742cd 100644
9+
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
10+
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
11+
@@ -193,7 +193,7 @@ public class EntityTNTPrimed extends Entity {
12+
this.motY = oldMotY;
13+
this.motZ = oldMotZ;
14+
15+
- if (this.inWater) {
16+
+ if (this.inWater && !TitaniumConfig.get().gameMechanics.disableTntInWaterSync) { // Titanium - Option to disable TNT in water sync
17+
// Send position and velocity updates to nearby players on every tick while the TNT is in water.
18+
// This does pretty well at keeping their clients in sync with the server.
19+
EntityTrackerEntry ete = ((WorldServer) this.getWorld()).getTracker().trackedEntities.get(this.getId());
20+
diff --git a/src/main/java/net/titanium/config/TitaniumConfig.java b/src/main/java/net/titanium/config/TitaniumConfig.java
21+
index e88bf134e..84f8ccd9d 100644
22+
--- a/src/main/java/net/titanium/config/TitaniumConfig.java
23+
+++ b/src/main/java/net/titanium/config/TitaniumConfig.java
24+
@@ -96,15 +96,16 @@ public class TitaniumConfig extends TitaniumConfigSection {
25+
@Comment("It can have impact on performance (probably small, but still) since it have a little calculations (to fix Nocom exploit).")
26+
public boolean fixBlockBreakDesync = false;
27+
28+
+ @Comment("All things in that section could break vanilla mechanics, so keep that in mind.")
29+
public GameMechanics gameMechanics = new GameMechanics();
30+
31+
public static class GameMechanics extends TitaniumConfigSection {
32+
33+
+ @Comment("Whether to disable fluids ticking (for eg. water won't flow).")
34+
public boolean tickFluids = true;
35+
36+
@Comment("Whether to disable statistics (ESC -> Statistics) and achievements.")
37+
@Comment("This option could improve performance a little especially on large servers.")
38+
- @Comment("Of course it's not vanilla mechanic.")
39+
public boolean disableStatistics = false;
40+
41+
@Comment("Whether to disable chunk ticking.")
42+
@@ -116,6 +117,9 @@ public class TitaniumConfig extends TitaniumConfigSection {
43+
@Comment("Mostly optimization for clients.")
44+
public boolean disableExplosionParticles = false;
45+
46+
+ @Comment("Whether to disable sync of position and velocity of TNT in water to client.")
47+
+ public boolean disableTntInWaterSync = false;
48+
+
49+
}
50+
51+
@Comment("The max NBT size in bytes. The default value is 2097152 which is ~2Mb - it's insane big.")
52+
--
53+
2.36.0.windows.1
54+

0 commit comments

Comments
 (0)