Skip to content

Commit

Permalink
more more more work
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaKR93 committed Nov 7, 2023
1 parent c1349b3 commit cc61709
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 133 deletions.
4 changes: 2 additions & 2 deletions patches/server/0024-Ignore-useless-entity-packets.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Subject: [PATCH] Ignore useless entity packets


diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index c6ef510d335b8baea58c4491853414a52a06b66b..ccc2f5f71181c1d5c36dcb85de3e48982db0aa8f 100644
index c6ef510d335b8baea58c4491853414a52a06b66b..e2dcdc9f317a4ab1a9b30e482607dc041abb7035 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -200,6 +200,8 @@ public class ServerEntity {
flag4 = true;
flag5 = true;
}
+
+ if (this.entity.level().plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma
+ if (this.level.plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma
}

if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <[email protected]>
Date: Sat, 30 Sep 2023 22:02:58 +0900
Date: Tue, 7 Nov 2023 15:47:45 +0900
Subject: [PATCH] Optimise state lookup more


diff --git a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..0832e4fa92b6464a6206475fbceb3b36462757b3 100644
index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..50d97c5ab33f33b81dbafd7cf42da5afd9856eeb 100644
--- a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
+++ b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
@@ -17,6 +17,7 @@ public final class ZeroCollidingReferenceStateTable {
protected final StateHolder<?, ?> this_state;

protected long[] index_table;
+ public long[] index_table() { return this.index_table; } // Plazma - getter
+ public long[] index_table() { return this.index_table; } // Plazma - Getter
protected StateHolder<?, ?>[][] value_table;

public ZeroCollidingReferenceStateTable(final StateHolder<?, ?> state, final Map<Property<?>, Comparable<?>> this_map) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
index 5f285d190186a2ff5a61d05070593e1d633dd79a..7b61a956892e90c7556db46d9277da8d252547cd 100644
index 5f285d190186a2ff5a61d05070593e1d633dd79a..25a2d70ce34fe57dc3838d4351ac88794acb7109 100644
--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
@@ -114,21 +114,15 @@ public abstract class StateHolder<O, S> {
@@ -114,6 +114,13 @@ public abstract class StateHolder<O, S> {
}

public <T extends Comparable<T>, V extends T> S trySetValue(Property<T> property, V value) {
- Comparable<?> comparable = this.values.get(property);
- if (comparable != null && !comparable.equals(value)) {
- S object = this.neighbours.get(property, value);
- if (object == null) {
- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
- } else {
- return object;
- }
- } else {
- return (S)this;
- }
+ // Plazma start - optimise state lookup more
+ final S ret = (S) this.optimisedTable.get(property, value);
+ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
+ return ret;
+ // Plazma start - Optimise state lookup more
+ if (true) {
+ final S ret = (S) this.optimisedTable.get(property, value);
+ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
+ return ret;
+ }
+ // Plazma end
Comparable<?> comparable = this.values.get(property);
if (comparable != null && !comparable.equals(value)) {
S object = this.neighbours.get(property, value);
@@ -128,7 +135,7 @@ public abstract class StateHolder<O, S> {
}

public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> states) {
- if (this.neighbours != null) {
+ if (this.optimisedTable.index_table() != null) { // Plazma - optimise state lookup more
+ if (this.optimisedTable.index_table() != null) { // Plazma - Optimise state holder more
throw new IllegalStateException();
} else {
Table<Property<?>, Comparable<?>, S> table = HashBasedTable.create();
@@ -143,7 +137,7 @@ public abstract class StateHolder<O, S> {
@@ -143,7 +150,7 @@ public abstract class StateHolder<O, S> {
}
}

- this.neighbours = (Table<Property<?>, Comparable<?>, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup
+ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Paper - optimise state lookup // Plazma - more
+ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Plazma - Optimize state lookup more
}
}

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <[email protected]>
Date: Sat, 30 Sep 2023 22:06:00 +0900
Subject: [PATCH] Suppress error from dirty attributes
Date: Tue, 7 Nov 2023 15:52:24 +0900
Subject: [PATCH] Suppress errors from dirty attributes


diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9049bb697 100644
index e2dcdc9f317a4ab1a9b30e482607dc041abb7035..46e489dd059bc3bf8f1c5efa073fbcd892bc389d 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -395,7 +395,8 @@ public class ServerEntity {
Expand All @@ -14,7 +14,7 @@ index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9
if (this.entity instanceof LivingEntity) {
- Set<AttributeInstance> set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes();
+ Set<AttributeInstance> attributes = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); // Plazma - Suppress error from dirty attributes
+ final Set<AttributeInstance> set = this.entity.level().plazmaLevelConfiguration().entity.suppressErrorFromDirtyAttributes ? java.util.Collections.synchronizedSet(attributes) : attributes; // Plazma - Suppress error from dirty attributes
+ final Set<AttributeInstance> set = this.level.plazmaConfig().entity.suppressErrorsFromDirtyAttributes ? Collections.synchronizedSet(attributes) : attributes; // Plazma - Suppress error from dirty attributes

if (!set.isEmpty()) {
// CraftBukkit start - Send scaled max health
Expand All @@ -27,15 +27,15 @@ index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9
}

}
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
index cb21da3cff4dbb08c7786c09b39e381abdf45c33..dfd408dc42a6000eb5fa56bbdb64f2329e545078 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
@@ -36,6 +36,7 @@ public class LevelConfigurations extends ConfigurationPart {
public int sensorTick = DO_OPTIMIZE ? 10 : 1;
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
index fae1913ec6b3689388f14f4b9c925dd53954cf62..ee84ac47adc29c54d668fc9e1729444e51649659 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
@@ -30,6 +30,7 @@ public class WorldConfigurations extends ConfigurationPart {

public boolean ignoreUselessPackets = DO_OPTIMIZE;
+ public boolean suppressErrorFromDirtyAttributes = false;
public boolean ignoreUselessPackets = OPTIMIZE;
public int sensorTick = 1;
+ public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE;

public Player player;
public class Player extends ConfigurationPart {
public Phantom phantom;
public class Phantom extends ConfigurationPart {
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <[email protected]>
Date: Sat, 30 Sep 2023 22:10:59 +0900
Date: Tue, 7 Nov 2023 15:56:21 +0900
Subject: [PATCH] Skip event if no listeners


diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fcb6371e80 100644
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..fb4135cb5d9e4162336c43d3b61c9d9a175a4dd5 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Level;

-class PaperEventManager {
+public class PaperEventManager { // Plazma - package -> public

private final Server server;

@@ -36,15 +36,17 @@ class PaperEventManager {
@@ -36,15 +36,18 @@ class PaperEventManager {

// SimplePluginManager
public void callEvent(@NotNull Event event) {
Expand All @@ -26,6 +17,7 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fc
+ RegisteredListener[] listeners = handlers.getRegisteredListeners();
+ if (listeners.length == 0) return;
+ // Plazma end
+
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
Expand All @@ -38,15 +30,3 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fc
for (RegisteredListener registration : listeners) {
if (!registration.getPlugin().isEnabled()) {
continue;
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
index d17df5621717b1c8d1d9a5549feb73c3600ecf3d..ddbc37857bd2706844074925bc27b7a84efa5832 100644
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
@@ -31,7 +31,6 @@ public class GlobalConfiguration extends ConfigurationPart {
@Override
public void postProcess() {

-
}

public boolean reduceCreateRandomInstance = DO_OPTIMIZE;
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaKR93 <[email protected]>
Date: Sat, 30 Sep 2023 22:17:02 +0900
Subject: [PATCH] Optimize Spigot event bus
Date: Tue, 7 Nov 2023 15:59:07 +0900
Subject: [PATCH] Optimize spigot event bus


diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
index 6016c304ddbeb6ffbd591f30914c85fcb6371e80..482e2cdbd4f76f2a56c62bec12bfc39d7193b6ce 100644
index fb4135cb5d9e4162336c43d3b61c9d9a175a4dd5..b0ea2013433429cb0ae0314d8c483e4536a8d04f 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
@@ -41,11 +41,14 @@ public class PaperEventManager { // Plazma - package -> public
@@ -40,13 +40,15 @@ class PaperEventManager {
HandlerList handlers = event.getHandlers();
RegisteredListener[] listeners = handlers.getRegisteredListeners();
if (listeners.length == 0) return;
// Plazma end
- // Plazma end

- if (event.isAsynchronous() && this.server.isPrimaryThread()) {
- throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
- } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
- throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
+ // Plazma start - Optimize Spigot event bus
+ if (event.asynchronous() != net.kyori.adventure.util.TriState.NOT_SET) {
+ // Optimize Spigot event bus
+ if (event.asynchronous() == net.kyori.adventure.util.TriState.NOT_SET) {
+ final boolean async = event.isAsynchronous();
+ final boolean primary = this.server.isPrimaryThread();
+ if (async && primary) throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
Expand Down

This file was deleted.

35 changes: 0 additions & 35 deletions patches/unapplied/server/0026-Configurable-sensor-tick.patch

This file was deleted.

0 comments on commit cc61709

Please sign in to comment.