9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2026-01-03 22:26:14 +00:00

Patch changes

This commit is contained in:
MrPowerGamerBR
2023-11-19 19:08:41 -03:00
parent 27b4f21dfc
commit 8bd484c287
3 changed files with 40 additions and 17 deletions

View File

@@ -11,10 +11,10 @@ now is just updating dirty map/decoration data.
When no bukkit renderers are added to the map, we also re-use the same packet for all players who are tracking it which avoids a lot of work.
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 196280f54e397c69d32bd4d1f6ae666efdd93773..8ef1c11969310f64d06c8421969d171b6c399ab6 100644
index 35674f92a67f93382103c2766df4b678ba5c862f..bfdd0ce9acfae75a403d3689b391dd8fff7416a0 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -108,29 +108,42 @@ public class ServerEntity {
@@ -111,29 +111,42 @@ public class ServerEntity {
Entity entity = this.entity;
@@ -62,7 +62,7 @@ index 196280f54e397c69d32bd4d1f6ae666efdd93773..8ef1c11969310f64d06c8421969d171b
}
}
@@ -373,6 +386,19 @@ public class ServerEntity {
@@ -366,6 +379,19 @@ public class ServerEntity {
}
}
@@ -104,10 +104,10 @@ index 759ecd79534a7706f7d4a63eb9dacbefcfe54674..0780dd4abf035cdd4001fb9702494c54
if (!player.getAbilities().instabuild) {
itemstack.shrink(1);
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727c5d652ee 100644
index e4c4948e076cd64686dfd16ae0568fafc1437140..0e7c7593eec47bc266f53ee8b2053917a84ae61e 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -66,6 +66,16 @@ public class MapItemSavedData extends SavedData {
@@ -67,6 +67,16 @@ public class MapItemSavedData extends SavedData {
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
private int trackedDecorationCount;
private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
@@ -124,7 +124,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
// CraftBukkit start
public final CraftMapView mapView;
@@ -325,6 +335,7 @@ public class MapItemSavedData extends SavedData {
@@ -332,6 +342,7 @@ public class MapItemSavedData extends SavedData {
}
this.setDecorationsDirty();
@@ -132,7 +132,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
}
public static void addTargetDecoration(ItemStack stack, BlockPos pos, String id, MapDecoration.Type type) {
@@ -420,6 +431,7 @@ public class MapItemSavedData extends SavedData {
@@ -427,6 +438,7 @@ public class MapItemSavedData extends SavedData {
}
this.setDecorationsDirty();
@@ -140,7 +140,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
}
}
@@ -433,6 +445,20 @@ public class MapItemSavedData extends SavedData {
@@ -440,6 +452,20 @@ public class MapItemSavedData extends SavedData {
public void setColorsDirty(int x, int z) {
this.setDirty();
@@ -161,7 +161,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
Iterator iterator = this.carriedBy.iterator();
while (iterator.hasNext()) {
@@ -515,6 +541,7 @@ public class MapItemSavedData extends SavedData {
@@ -522,6 +548,7 @@ public class MapItemSavedData extends SavedData {
public void removedFromFrame(BlockPos pos, int id) {
this.removeDecoration("frame-" + id);
this.frameMarkers.remove(MapFrame.frameId(pos));
@@ -169,7 +169,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
}
public boolean updateColor(int x, int z, byte color) {
@@ -572,6 +599,93 @@ public class MapItemSavedData extends SavedData {
@@ -579,6 +606,93 @@ public class MapItemSavedData extends SavedData {
return this.trackedDecorationCount >= iconCount;
}
@@ -264,7 +264,7 @@ index 50713f03c783c63f93710d986d94af544be0615a..5a0978c2342647d6293cd370e489a727
// Paper start
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
index 115ac54d13a8ca189a69526b1b3baf48be8a64e9..f878bed0503b183e636c15a16b766e15844f4a3f 100644
index c3266c43a073cb7d7eff10d1a1b15f0a2265b859..4d69e345117556bac2126edc5169ab01eed97377 100644
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java
@@ -108,6 +108,10 @@ public final class CraftMapView implements MapView {

View File

@@ -9,10 +9,10 @@ The "distanceToSqr" call is a bit expensive, so avoiding it is pretty nice, arou
We could also check if the x,y,z coordinates are equal, but for now, let's just keep the identity check, which also helps us since Minecraft's code does reuse the original delta movement Vec3 object
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 35674f92a67f93382103c2766df4b678ba5c862f..aedf24ba0d64de855a59869052cbc2704e7dc134 100644
index bfdd0ce9acfae75a403d3689b391dd8fff7416a0..71d6f63feb8548181882c481f53c810baf8c1e07 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -202,12 +202,14 @@ public class ServerEntity {
@@ -215,12 +215,14 @@ public class ServerEntity {
if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) {
Vec3 vec3d1 = this.entity.getDeltaMovement();

View File

@@ -11,16 +11,39 @@ To avoid the hefty ArrayDeque's size() call, we check if we *really* need to exe
Most entities won't have any scheduled tasks, so this is a nice performance bonus. These optimizations, however, wouldn't work in a Folia environment, but because in SparklyPaper executeTick is always executed on the main thread, it ain't an issue for us (yay).
diff --git a/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java b/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
index 62484ebf4550b05182f693a3180bbac5d5fd906d..1ee31db28d3a4b9b841efeb37f7df7932dfad2dc 100644
index 62484ebf4550b05182f693a3180bbac5d5fd906d..9e15a2a9e47a5b50c3c9e2afce2eb0f48ed0fdaf 100644
--- a/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
+++ b/src/main/java/io/papermc/paper/threadedregions/EntityScheduler.java
@@ -138,15 +138,27 @@ public final class EntityScheduler {
@@ -45,6 +45,7 @@ public final class EntityScheduler {
private final Long2ObjectOpenHashMap<List<ScheduledTask>> oneTimeDelayed = new Long2ObjectOpenHashMap<>();
private final ArrayDeque<ScheduledTask> currentlyExecuting = new ArrayDeque<>();
+ private boolean hasScheduledAtLeastOneTask = false; // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
public EntityScheduler(final CraftEntity entity) {
this.entity = Validate.notNull(entity);
@@ -124,6 +125,7 @@ public final class EntityScheduler {
if (this.tickCount == RETIRED_TICK_COUNT) {
return false;
}
+ hasScheduledAtLeastOneTask = true; // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
this.oneTimeDelayed.computeIfAbsent(this.tickCount + Math.max(1L, delay), (final long keyInMap) -> {
return new ArrayList<>();
}).add(task);
@@ -138,15 +140,34 @@ public final class EntityScheduler {
* @throws IllegalStateException If the scheduler is retired.
*/
public void executeTick() {
+ // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
+ // SparklyPaper start - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
+ // This wouldn't work on a multithreaded environment like Folia!!! But because the executeTick is always executed on the
+ // main thread, we don't need to care about concurrency
+ // First, we use a simple boolean check here
+ // Yeah, this sounds dumb but, after benchmarking, it seems like a simple boolean check like this is actually more performant than calling both is empty checks
+ // So first we check if the EntityScheduler has been used at least ONCE
+ // If it wasn't, then we skip all checks entirely
+ // We don't even need to update the tick count because the tick count is actually relative to this scheduler, not bound to the global current tick, so it isn't a big deal if we don't update the tick count
+ if (!this.hasScheduledAtLeastOneTask)
+ return;
+ if (this.tickCount == RETIRED_TICK_COUNT) {
+ throw new IllegalStateException("Ticking retired scheduler");
+ }
@@ -37,7 +60,7 @@ index 62484ebf4550b05182f693a3180bbac5d5fd906d..1ee31db28d3a4b9b841efeb37f7df793
- throw new IllegalStateException("Ticking retired scheduler");
- }
- ++this.tickCount;
+ // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
+ // SparklyPaper start - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
+ // if (this.tickCount == RETIRED_TICK_COUNT) {
+ // throw new IllegalStateException("Ticking retired scheduler");
+ // }