mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly Paper Changes: 9a129fa99 Add #getEligibleHumans to SkeletonHorseTrapEvent b5e23c7a6 Fix merging spawning values a932e8ad7 Turn off spigot verbose world by default 8ced89f65 Fix Delegation to vanilla chunk gen
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: jmp <jasonpenilla2@me.com>
|
||||
Date: Wed, 18 Nov 2020 20:52:25 -0800
|
||||
Subject: [PATCH] PaperPR - Projectile load/save limit per chunk
|
||||
|
||||
Adds a config option to limit the number of projectiles saved and loaded
|
||||
to a chunk. Limits are counted per entity type, i.e. a limit of 5 means
|
||||
that 5 arrows, 5 snowballs, 5 tridents, etc. will be allowed to be
|
||||
saved/loaded per chunk. The default value of -1 disables the limit.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 5596d9f425..5ffc5af1de 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -704,4 +704,9 @@ public class PaperWorldConfig {
|
||||
private void fixClimbingBypassingCrammingRule() {
|
||||
fixClimbingBypassingCrammingRule = getBoolean("fix-climbing-bypassing-cramming-rule", fixClimbingBypassingCrammingRule);
|
||||
}
|
||||
+
|
||||
+ public int projectileSaveLimit = -1;
|
||||
+ private void projectileSaveLimit() {
|
||||
+ projectileSaveLimit = getInt("projectile-load-save-per-chunk-limit", projectileSaveLimit);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 64dd95292f..3628b04fc4 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -525,11 +525,21 @@ public class ChunkRegionLoader {
|
||||
|
||||
chunk.d(false);
|
||||
|
||||
+ // Paper start
|
||||
+ final Map<EntityTypes<?>, Integer> savedProjectileCounts = Maps.newHashMap();
|
||||
for (int j = 0; j < chunk.getEntitySlices().length; ++j) {
|
||||
Iterator iterator1 = chunk.getEntitySlices()[j].iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
Entity entity = (Entity) iterator1.next();
|
||||
+ if (worldserver.paperConfig.projectileSaveLimit > -1 && (entity instanceof IProjectile || entity instanceof EntityEnderSignal)) {
|
||||
+ final EntityTypes<?> projectileType = entity.getEntityType();
|
||||
+ if (savedProjectileCounts.getOrDefault(projectileType, 0) >= worldserver.paperConfig.projectileSaveLimit) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ savedProjectileCounts.merge(projectileType, 1, Integer::sum);
|
||||
+ }
|
||||
+ // Paper end
|
||||
NBTTagCompound nbttagcompound4 = new NBTTagCompound();
|
||||
// Paper start
|
||||
if (asyncsavedata == null && !entity.dead && (int) Math.floor(entity.locX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.locZ()) >> 4 != chunk.getPos().z) {
|
||||
@@ -660,10 +670,20 @@ public class ChunkRegionLoader {
|
||||
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
|
||||
World world = chunk.getWorld();
|
||||
|
||||
+ // Paper start
|
||||
+ final Map<EntityTypes<?>, Integer> loadedProjectileCounts = Maps.newHashMap();
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
|
||||
|
||||
EntityTypes.a(nbttagcompound1, world, (entity) -> {
|
||||
+ if (world.paperConfig.projectileSaveLimit > -1 && (entity instanceof IProjectile || entity instanceof EntityEnderSignal)) {
|
||||
+ final EntityTypes<?> projectileType = entity.getEntityType();
|
||||
+ if (loadedProjectileCounts.getOrDefault(projectileType, 0) >= world.paperConfig.projectileSaveLimit) {
|
||||
+ return entity;
|
||||
+ }
|
||||
+ loadedProjectileCounts.merge(projectileType, 1, Integer::sum);
|
||||
+ }
|
||||
+ // Paper end
|
||||
chunk.a(entity);
|
||||
return entity;
|
||||
});
|
||||
Reference in New Issue
Block a user