118 lines
6.7 KiB
Diff
118 lines
6.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
Date: Fri, 13 Dec 2024 21:10:27 +0900
|
|
Subject: [PATCH] Port minor SparklyPaper patches
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 2bec5ed591e658765602379f9065b8089f5df6ea..ddcf301f098bbe55dbef7751180110a22bccc68d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -58,6 +58,7 @@ import org.bukkit.event.player.PlayerVelocityEvent;
|
|
|
|
public class ServerEntity {
|
|
|
|
+ public static boolean PLAZMA_DISTANCE_SQR = false; // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private static final int TOLERANCE_LEVEL_ROTATION = 1;
|
|
private static final double TOLERANCE_LEVEL_POSITION = 7.62939453125E-6D;
|
|
@@ -232,6 +233,7 @@ public class ServerEntity {
|
|
|
|
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) {
|
|
Vec3 vec3d1 = this.entity.getDeltaMovement();
|
|
+ if (PLAZMA_DISTANCE_SQR || vec3d1 != this.lastSentMovement) { // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
|
double d0 = vec3d1.distanceToSqr(this.lastSentMovement);
|
|
|
|
if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) {
|
|
@@ -246,6 +248,7 @@ public class ServerEntity {
|
|
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
|
}
|
|
}
|
|
+ } // Plazma - Port Minor SparklyPaper patches; Skip distanceToSqr if the delta is the same
|
|
}
|
|
|
|
if (packet1 != null) {
|
|
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
index da7e1a69ecb4e6b3be2d8544ac406aa519bd196e..ce56fdd0bbe1c95146c88594c68a6a399f01218e 100644
|
|
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
|
|
@@ -90,12 +90,14 @@ public class ServerStatsCounter extends StatsCounter {
|
|
this.dirty.add(stat);
|
|
}
|
|
|
|
+ /* // Plazma - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
private Set<Stat<?>> getDirty() {
|
|
Set<Stat<?>> set = Sets.newHashSet(this.dirty);
|
|
|
|
this.dirty.clear();
|
|
return set;
|
|
}
|
|
+ */ // Plazma - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
|
|
public void parseLocal(DataFixer dataFixer, String json) {
|
|
try {
|
|
@@ -242,14 +244,12 @@ public class ServerStatsCounter extends StatsCounter {
|
|
}
|
|
|
|
public void sendStats(ServerPlayer player) {
|
|
- Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap();
|
|
- Iterator iterator = this.getDirty().iterator();
|
|
+ // Plazma start - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
+ Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap<>();
|
|
+ for (final Stat<?> stat : this.dirty) object2intmap.put(stat, this.getValue(stat));
|
|
|
|
- while (iterator.hasNext()) {
|
|
- Stat<?> statistic = (Stat) iterator.next();
|
|
-
|
|
- object2intmap.put(statistic, this.getValue(statistic));
|
|
- }
|
|
+ this.dirty.clear();
|
|
+ // Plazma end - Port Minor SparklyPaper patches; Skip dirty stats copy when requesting player stats
|
|
|
|
player.connection.send(new ClientboundAwardStatsPacket(object2intmap));
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
|
index 68a0aa6545c8aba3ecc31086a8d2bc3e1aada64e..4b9fbb4b1ad434ea06a44e30e66c394b07be7b7f 100644
|
|
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
|
@@ -276,7 +276,12 @@ public class MapItem extends Item {
|
|
mapItemSavedData.tickCarriedBy(player, stack);
|
|
}
|
|
|
|
- if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
|
+ // Plazma start - Port Minor SparklyPaper patches; Skip map update if the craft renderer is null
|
|
+ if (!mapItemSavedData.locked
|
|
+ && (!world.plazmaConfig().item.skipMapUpdateIfCraftRenderIsNull || mapItemSavedData.mapView.getRenderers().stream().anyMatch(renderer -> renderer instanceof org.bukkit.craftbukkit.map.CraftMapRenderer))
|
|
+ && (selected || entity instanceof Player player && player.getOffhandItem() == stack)
|
|
+ ) {
|
|
+ // Plazma end - Port Minor SparklyPaper patches; Skip map update if the craft renderer is null
|
|
this.update(world, entity, mapItemSavedData);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
index 8149b9c51b78eb5c689b7218a2ca3aab60e73bcf..125a4f13dbe98976c4cf94bb523463a51bd4f8dd 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapColorCache.java
|
|
@@ -145,7 +145,7 @@ public class CraftMapColorCache implements MapPalette.MapColorCache {
|
|
}
|
|
|
|
@Override
|
|
- public boolean isCached() {
|
|
+ public synchronized boolean isCached() { // Plazma - Port Minor SparklyPaper patches; Fix concurrency issues when using "imageToBytes" in multiple threads
|
|
return this.cached || (!this.running.get() && this.initCache().isDone());
|
|
}
|
|
|
|
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
index bbb51ccf2016987202811ee893f855da2612dd17..f6f372644bca9111aa3f45bf7ae8e66e53d11505 100644
|
|
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
|
@@ -86,6 +86,8 @@ public class WorldConfigurations extends ConfigurationPart {
|
|
public Item item;
|
|
public class Item extends ConfigurationPart {
|
|
|
|
+ public boolean skipMapUpdateIfCraftRenderIsNull = true;
|
|
+
|
|
public ShootableFireCharge shootableFireCharge;
|
|
public class ShootableFireCharge extends ConfigurationPart {
|
|
|