Compare commits
4 Commits
1.20.6-bd2
...
1.20.6-b20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b208bcc81f | ||
|
|
43eda55b88 | ||
|
|
e6ee20986b | ||
|
|
46aec00348 |
@@ -0,0 +1,45 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrHua269 <novau233@163.com>
|
||||||
|
Date: Mon, 10 Jun 2024 10:51:08 +0000
|
||||||
|
Subject: [PATCH] Try fixing folia off region POI accessing issue
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..343c85ded7e7abc22fac0aaeb7be786e9bd7b39a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPOIAccessOffRegionFixConfig.java
|
||||||
|
@@ -0,0 +1,20 @@
|
||||||
|
+package me.earthme.luminol.config.modules.fixes;
|
||||||
|
+
|
||||||
|
+import me.earthme.luminol.config.ConfigInfo;
|
||||||
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||||
|
+import me.earthme.luminol.config.IConfigModule;
|
||||||
|
+
|
||||||
|
+public class FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
|
||||||
|
+ @ConfigInfo(baseName = "enabled")
|
||||||
|
+ public static boolean enabled = false;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public EnumConfigCategory getCategory() {
|
||||||
|
+ return EnumConfigCategory.FIXES;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getBaseName() {
|
||||||
|
+ return "folia.fix_poi_access_off_region";
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
|
index cf69b4ed4a40015a23d053230c3f326a700788ef..5fdcad0038aad61d68cd329e72c8db309c5e3926 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java
|
||||||
|
@@ -96,7 +96,7 @@ public class PoiManager extends SectionStorage<PoiSection> {
|
||||||
|
|
||||||
|
public Stream<PoiRecord> getInSquare(Predicate<Holder<PoiType>> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) {
|
||||||
|
int i = Math.floorDiv(radius, 16) + 1;
|
||||||
|
- return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> {
|
||||||
|
+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? io.papermc.paper.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access
|
||||||
|
BlockPos blockPos2 = poi.getPos();
|
||||||
|
return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius;
|
||||||
|
});
|
||||||
@@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..b8aceab54bb60000e7c5681014027102
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
index 90f4cc0bd3722400411e6b1aa2d03205a350ee8a..f87c7a77b8d5748c08488470bf60ea84ab95a819 100644
|
index 20f8c9bfdde62f1572e22319ebb752d12d9d5bac..24f4370b35d2cc50340de36d81b6c6d9aa250e4c 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
@@ -347,6 +347,10 @@ public class ServerPlayer extends Player {
|
@@ -347,6 +347,10 @@ public class ServerPlayer extends Player {
|
||||||
@@ -48,7 +48,7 @@ index 90f4cc0bd3722400411e6b1aa2d03205a350ee8a..f87c7a77b8d5748c08488470bf60ea84
|
|||||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
|
||||||
this.chatVisibility = ChatVisiblity.FULL;
|
this.chatVisibility = ChatVisiblity.FULL;
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 2c65527fa7bc2fce769e15f35a45ebae381c6bac..c13e3da32415607b3f0f88b6c34630a28af75128 100644
|
index b4c4e72ddd09231747f82962a9d2883c6415ce30..bd666d03324291ec847136bab905f0aec726a211 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -695,7 +695,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
@@ -695,7 +695,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Pufferfish Optimize entity coordinate key
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
index 08d282400644be5949f28eb879b333cc221da2cc..49ccb27a17bec1d4ff31bc8d72e4724d65adc20c 100644
|
index bb915f30997059f22c9002b1ddc1c3aecbf4e979..2034c67f5702b7b8d093ef2dd7601901c5fef363 100644
|
||||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
@@ -215,7 +215,7 @@ public final class MCUtil {
|
@@ -215,7 +215,7 @@ public final class MCUtil {
|
||||||
@@ -18,18 +18,10 @@ index 643631e11c88285f33d050bf7b4b1e2f63b5c992..94c9f407f526b2d43cf61725b414b113
|
|||||||
private Vec3 deltaMovement;
|
private Vec3 deltaMovement;
|
||||||
private float yRot;
|
private float yRot;
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index a1e90547816ebf0811e7b22af793f40015d6c4f3..00589ca4361482cdd852d699c4bc632ae85b5dd3 100644
|
index a7c0527dd7a8cc30bb42e7ce1342b3f11862ee81..89ff6f509a59b484977ffbdb4e4132a46ca4bbaa 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -150,7 +150,6 @@ import org.bukkit.event.entity.EntityTeleportEvent;
|
@@ -2069,6 +2069,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
-import co.aikar.timings.MinecraftTimings; // Paper
|
|
||||||
|
|
||||||
public abstract class LivingEntity extends Entity implements Attackable {
|
|
||||||
|
|
||||||
@@ -2069,6 +2068,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
||||||
return this.lastClimbablePos;
|
return this.lastClimbablePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
index 6d8ff6c06af5545634f255ed17dc1e489ece2548..6411aa4ff6bd4cabb25c426fa8f4a7eedb969c03 100644
|
index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3d8d6f96f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||||
@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid {
|
@@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||||
@@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..3e48cd297b4869e5c89b6abc43c726d3
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 00589ca4361482cdd852d699c4bc632ae85b5dd3..e49d18132e63ba7486c59fbb5cd236a872812e5c 100644
|
index 89ff6f509a59b484977ffbdb4e4132a46ca4bbaa..2a7172c987812347e308ae1ed86b3fd430ef04e9 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -441,7 +441,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -442,7 +442,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
@@ -43,7 +43,7 @@ index 00589ca4361482cdd852d699c4bc632ae85b5dd3..e49d18132e63ba7486c59fbb5cd236a8
|
|||||||
this.hurt(this.damageSources().inWall(), 1.0F);
|
this.hurt(this.damageSources().inWall(), 1.0F);
|
||||||
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
} else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
||||||
double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone();
|
||||||
@@ -1449,6 +1449,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -1450,6 +1450,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
return this.getHealth() <= 0.0F;
|
return this.getHealth() <= 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ index b88aa184cd06a0485146f58a5b61a56a50911209..7b64c57795fe27d8397500bfa41f71f9
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
index f24a50b39393e5cdbb3b995d4a90faea142068f8..c2b40b0676a557c789ff3ce0ac1cb07345dee4b9 100644
|
index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b18d87102 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
@@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
@@ -52,10 +52,10 @@ index 18c6fe66fa944f5e5b7892df4d8fef4c7346d3bc..a9e32fba699c718011abc52d91ec7158
|
|||||||
return this.chunkPosition;
|
return this.chunkPosition;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index e49d18132e63ba7486c59fbb5cd236a872812e5c..d4ab1b3253e4eeb72dd2e197757b446273bcc10e 100644
|
index 2a7172c987812347e308ae1ed86b3fd430ef04e9..0eb73b666fe161fc148e0c0dc2da3362f8452187 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -2088,19 +2088,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -2089,19 +2089,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
public boolean onClimableCached() {
|
public boolean onClimableCached() {
|
||||||
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
||||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Gale Check frozen ticks before landing block
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 30ee36f31069a11f87b7bd619020e25a342bae00..fffe8413eec4ae3eda2d21d958aa2534661a0558 100644
|
index 0eb73b666fe161fc148e0c0dc2da3362f8452187..bae654c209fc423cafe66f10ba35971af7579710 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -608,11 +608,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -609,11 +609,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tryAddFrost() {
|
protected void tryAddFrost() {
|
||||||
@@ -21,7 +21,7 @@ index 30ee36f31069a11f87b7bd619020e25a342bae00..fffe8413eec4ae3eda2d21d958aa2534
|
|||||||
|
|
||||||
if (attributemodifiable == null) {
|
if (attributemodifiable == null) {
|
||||||
return;
|
return;
|
||||||
@@ -622,7 +621,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -623,7 +622,6 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADD_VALUE));
|
attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADD_VALUE));
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca194
|
|||||||
int onResize(int newBits, T object);
|
int onResize(int newBits, T object);
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
index adfbdca12fbdee2602feb0158674166d5256e49e..9990e60f61d678e20cfffe22848eb5cc7c554b8a 100644
|
index 81368bf186365878db2e1ed305bb7bf36c26f61f..ee7ce575a80b47da752f1cc722b7f4dc3b1b1314 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector;
|
@@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector;
|
||||||
@@ -402,18 +402,10 @@ index e679b40b9628b0eb7152978ef641f9c918c4c8b2..bf9ae765242bb61d3e279893b0355d12
|
|||||||
} catch (StackOverflowError ex) {
|
} catch (StackOverflowError ex) {
|
||||||
world.lastPhysicsProblem = new BlockPos(pos);
|
world.lastPhysicsProblem = new BlockPos(pos);
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||||
index 82b4bd669c57b18fb0b443bcd94495023cd5a528..abd845a124dbe0b9a1868ce378a0b7c7b9b3b818 100644
|
index 82b4bd669c57b18fb0b443bcd94495023cd5a528..061f7ef0138d4b8d528c7aa71ec5660c1d7e3b27 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||||
@@ -25,6 +25,7 @@ import net.minecraft.world.level.block.Blocks;
|
@@ -428,4 +428,12 @@ public class CraftChunk implements Chunk {
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
||||||
import net.minecraft.world.level.chunk.DataLayer;
|
|
||||||
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
|
||||||
+import net.minecraft.world.level.chunk.LevelChunk;
|
|
||||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
|
||||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
|
||||||
import net.minecraft.world.level.chunk.PalettedContainerRO;
|
|
||||||
@@ -428,4 +429,12 @@ public class CraftChunk implements Chunk {
|
|
||||||
static {
|
static {
|
||||||
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
|
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
|
||||||
}
|
}
|
||||||
@@ -421,7 +413,7 @@ index 82b4bd669c57b18fb0b443bcd94495023cd5a528..abd845a124dbe0b9a1868ce378a0b7c7
|
|||||||
+ // KioCG start - ChunkHot
|
+ // KioCG start - ChunkHot
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public long getChunkHotAvg() {
|
+ public long getChunkHotAvg() {
|
||||||
+ final LevelChunk target = this.worldServer.getChunkIfLoaded(this.x,this.z);
|
+ final net.minecraft.world.level.chunk.LevelChunk target = this.worldServer.getChunkIfLoaded(this.x,this.z);
|
||||||
+ return target == null ? -1 : target.getChunkHot().getAverage();
|
+ return target == null ? -1 : target.getChunkHot().getAverage();
|
||||||
+ }
|
+ }
|
||||||
+ // KioCG end
|
+ // KioCG end
|
||||||
331
patches/unapplied/server/0054-Added-a-simple-membar.patch
Normal file
331
patches/unapplied/server/0054-Added-a-simple-membar.patch
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrHua269 <novau233@163.com>
|
||||||
|
Date: Sun, 2 Jun 2024 12:18:05 +0000
|
||||||
|
Subject: [PATCH] Added a simple membar
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/commands/MembarCommand.java b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a5cbad6b947b1c3e1499bc6d311e17a5eb570c2f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/commands/MembarCommand.java
|
||||||
|
@@ -0,0 +1,47 @@
|
||||||
|
+package me.earthme.luminol.commands;
|
||||||
|
+
|
||||||
|
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||||
|
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||||
|
+import net.kyori.adventure.text.Component;
|
||||||
|
+import net.kyori.adventure.text.format.TextColor;
|
||||||
|
+import org.bukkit.command.Command;
|
||||||
|
+import org.bukkit.command.CommandSender;
|
||||||
|
+import org.bukkit.entity.Player;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public class MembarCommand extends Command {
|
||||||
|
+ public MembarCommand(@NotNull String name) {
|
||||||
|
+ super(name);
|
||||||
|
+ this.setPermission("luminol.commands.membar");
|
||||||
|
+ this.setDescription("Show the memory usage through a bossbar");
|
||||||
|
+ this.setUsage("/membar");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||||
|
+ if (!testPermission(sender)){
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!MembarConfig.memoryBarEnabled){
|
||||||
|
+ sender.sendMessage(Component.text("Membar was already disabled!").color(TextColor.color(255,0,0)));
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!(sender instanceof Player player)){
|
||||||
|
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (GlobalServerMemoryBar.isPlayerVisible(player)) {
|
||||||
|
+ player.sendMessage(Component.text("Disabled mem bar").color(TextColor.color(0,255,0)));
|
||||||
|
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,false);
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ player.sendMessage(Component.text("Enabled mem bar").color(TextColor.color(0,255,0)));
|
||||||
|
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,true);
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..b632c4a636974535bf001f010de1dcb6b25868c0
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/MembarConfig.java
|
||||||
|
@@ -0,0 +1,50 @@
|
||||||
|
+package me.earthme.luminol.config.modules.misc;
|
||||||
|
+
|
||||||
|
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
+import me.earthme.luminol.commands.MembarCommand;
|
||||||
|
+import me.earthme.luminol.config.ConfigInfo;
|
||||||
|
+import me.earthme.luminol.config.DoNotLoad;
|
||||||
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||||
|
+import me.earthme.luminol.config.IConfigModule;
|
||||||
|
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+
|
||||||
|
+import java.util.List;
|
||||||
|
+
|
||||||
|
+public class MembarConfig implements IConfigModule {
|
||||||
|
+ @ConfigInfo(baseName = "enabled")
|
||||||
|
+ public static boolean memoryBarEnabled = false;
|
||||||
|
+ @ConfigInfo(baseName = "format")
|
||||||
|
+ public static String memBarFormat = "<gray>Memory usage <yellow>:</yellow> <used>MB<yellow>/</yellow><available>MB";
|
||||||
|
+ @ConfigInfo(baseName = "memory_color_list")
|
||||||
|
+ public static List<String> memColors = List.of("GREEN","YELLOW","RED","PURPLE");
|
||||||
|
+ @ConfigInfo(baseName = "update_interval_ticks")
|
||||||
|
+ public static int updateInterval = 15;
|
||||||
|
+
|
||||||
|
+ @DoNotLoad
|
||||||
|
+ private static boolean inited = false;
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public EnumConfigCategory getCategory() {
|
||||||
|
+ return EnumConfigCategory.MISC;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getBaseName() {
|
||||||
|
+ return "membar";
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void onLoaded(CommentedFileConfig configInstance){
|
||||||
|
+ if (memoryBarEnabled){
|
||||||
|
+ GlobalServerMemoryBar.init();
|
||||||
|
+ }else{
|
||||||
|
+ GlobalServerMemoryBar.cancelBarUpdateTask();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!inited){
|
||||||
|
+ Bukkit.getCommandMap().register("membar","luminol",new MembarCommand("membar"));
|
||||||
|
+ inited = true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..1c1278976fd13c1616973c70fe5db2652fcbad95
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
|
||||||
|
@@ -0,0 +1,186 @@
|
||||||
|
+package me.earthme.luminol.functions;
|
||||||
|
+
|
||||||
|
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||||
|
+import io.papermc.paper.threadedregions.TickRegions;
|
||||||
|
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||||
|
+import me.earthme.luminol.config.modules.misc.MembarConfig;
|
||||||
|
+import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
+import net.kyori.adventure.text.Component;
|
||||||
|
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
|
+import net.minecraft.server.level.ServerPlayer;
|
||||||
|
+import org.apache.logging.log4j.LogManager;
|
||||||
|
+import org.apache.logging.log4j.Logger;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin;
|
||||||
|
+import org.bukkit.entity.Player;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+import java.lang.management.ManagementFactory;
|
||||||
|
+import java.lang.management.MemoryUsage;
|
||||||
|
+import java.util.*;
|
||||||
|
+
|
||||||
|
+public class GlobalServerMemoryBar {
|
||||||
|
+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin();
|
||||||
|
+ protected static final Map<UUID, BossBar> uuid2Bossbars = new HashMap<>();
|
||||||
|
+ protected static volatile ScheduledTask membarTask = null;
|
||||||
|
+ private static final Logger logger = LogManager.getLogger();
|
||||||
|
+
|
||||||
|
+ public static void init(){
|
||||||
|
+ cancelBarUpdateTask();
|
||||||
|
+
|
||||||
|
+ Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, c -> {
|
||||||
|
+ membarTask = c;
|
||||||
|
+ try {
|
||||||
|
+ update();
|
||||||
|
+ }catch (Exception e){
|
||||||
|
+ logger.error(e);
|
||||||
|
+ }
|
||||||
|
+ },1, MembarConfig.updateInterval);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void removeAllBars(){
|
||||||
|
+ for (Map.Entry<UUID,BossBar> barEntry : uuid2Bossbars.entrySet()){
|
||||||
|
+ final UUID playerUUID = barEntry.getKey();
|
||||||
|
+ final BossBar memBar = barEntry.getValue();
|
||||||
|
+
|
||||||
|
+ final Player targetPlayer = Bukkit.getPlayer(playerUUID);{
|
||||||
|
+ if (targetPlayer != null){
|
||||||
|
+ targetPlayer.hideBossBar(memBar);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ uuid2Bossbars.clear();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void cancelBarUpdateTask(){
|
||||||
|
+ removeAllBars();
|
||||||
|
+
|
||||||
|
+ if (membarTask == null || membarTask.isCancelled()){
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ membarTask.cancel();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean isPlayerVisible(Player player){
|
||||||
|
+ return ((CraftPlayer) player).getHandle().isMemBarVisible;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
|
||||||
|
+ ((CraftPlayer) target).getHandle().isMemBarVisible = canSee;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void update(){
|
||||||
|
+ updateBarValues();
|
||||||
|
+ cleanUpPlayers();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void cleanUpPlayers(){
|
||||||
|
+ final List<UUID> toRemove = new ArrayList<>();
|
||||||
|
+
|
||||||
|
+ for (Map.Entry<UUID,BossBar> bossBarEntry : uuid2Bossbars.entrySet()){
|
||||||
|
+ final UUID uuid = bossBarEntry.getKey();
|
||||||
|
+ boolean shouldRemove = true;
|
||||||
|
+
|
||||||
|
+ final Player target = Bukkit.getPlayer(uuid);
|
||||||
|
+ if (target != null){
|
||||||
|
+ shouldRemove = !isPlayerVisible(target);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (shouldRemove){
|
||||||
|
+ toRemove.add(uuid);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (UUID uuid : toRemove){
|
||||||
|
+ final BossBar removed = uuid2Bossbars.remove(uuid);
|
||||||
|
+ if (removed != null){
|
||||||
|
+ final Player targetPlayer = Bukkit.getPlayer(uuid);
|
||||||
|
+ if (targetPlayer != null){
|
||||||
|
+ targetPlayer.hideBossBar(removed);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateBarValues(){
|
||||||
|
+ MemoryUsage heap = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||||
|
+
|
||||||
|
+ long used = heap.getUsed();
|
||||||
|
+ long xmx = heap.getMax();
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ for (Player apiPlayer : Bukkit.getOnlinePlayers()){
|
||||||
|
+ final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle();
|
||||||
|
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.sectionX,nmsPlayer.sectionZ);
|
||||||
|
+
|
||||||
|
+ if (region == null){
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ BossBar targetBossbar = uuid2Bossbars.get(nmsPlayer.getUUID());
|
||||||
|
+
|
||||||
|
+ if (targetBossbar == null && isPlayerVisible(apiPlayer)){
|
||||||
|
+ targetBossbar = BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(MembarConfig.memColors.get(3)), BossBar.Overlay.NOTCHED_20);
|
||||||
|
+ uuid2Bossbars.put(nmsPlayer.getUUID(),targetBossbar);
|
||||||
|
+ apiPlayer.showBossBar(targetBossbar);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (targetBossbar != null){
|
||||||
|
+ updateMembar(targetBossbar,used,xmx);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void updateMembar(@NotNull BossBar bar, long used, long xmx){
|
||||||
|
+ double percent = Math.max(Math.min((float) used / xmx, 1.0F), 0.0F);
|
||||||
|
+ bar.name(MiniMessage.miniMessage().deserialize(
|
||||||
|
+ MembarConfig.memBarFormat,
|
||||||
|
+ Placeholder.component("used", getMemoryComponent(used,xmx)),
|
||||||
|
+ Placeholder.component("available",getMaxMemComponent(xmx))
|
||||||
|
+ ));
|
||||||
|
+ bar.color(barColorFromMemory(percent));
|
||||||
|
+ bar.progress((float) percent);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static @NotNull Component getMaxMemComponent(double max){
|
||||||
|
+ final BossBar.Color colorBukkit = BossBar.Color.GREEN;
|
||||||
|
+ final String colorString = colorBukkit.name();
|
||||||
|
+
|
||||||
|
+ final String content = "<%s><text></%s>";
|
||||||
|
+ final String replaced = String.format(content,colorString,colorString);
|
||||||
|
+
|
||||||
|
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(max)));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static @NotNull Component getMemoryComponent(long used,long max){
|
||||||
|
+ final BossBar.Color colorBukkit = barColorFromMemory(Math.max(Math.min((float) used / max, 1.0F), 0.0F));
|
||||||
|
+ final String colorString = colorBukkit.name();
|
||||||
|
+
|
||||||
|
+ final String content = "<%s><text></%s>";
|
||||||
|
+ final String replaced = String.format(content,colorString,colorString);
|
||||||
|
+
|
||||||
|
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(used / 1024 * 1024)));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static BossBar.Color barColorFromMemory(double memPercent){
|
||||||
|
+ if (memPercent == -1){
|
||||||
|
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(3));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (memPercent <= 50){
|
||||||
|
+ return BossBar.Color.valueOf(MembarConfig.memColors.getFirst());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (memPercent <= 70){
|
||||||
|
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(1));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(2));
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
index 6f86f25efbd4e6e79476c1563dc8f4c114c10695..67f1205ec362bbb191b642641c45c7bcc53c7625 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
@@ -851,6 +851,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
|
@Override
|
||||||
|
public void stopServer() {
|
||||||
|
me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar
|
||||||
|
+ me.earthme.luminol.functions.GlobalServerMemoryBar.cancelBarUpdateTask(); //Luminol - Memory bar
|
||||||
|
super.stopServer();
|
||||||
|
//Util.shutdownExecutors(); // Paper - moved into super
|
||||||
|
SkullBlockEntity.clear();
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
index c04058a95dc4990cd8034b381f95affcdc77dd93..71bc115203933f3992315caf4e10ec8dc44955ba 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
|
@@ -303,6 +303,7 @@ public class ServerPlayer extends Player {
|
||||||
|
private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1));
|
||||||
|
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
|
||||||
|
public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar
|
||||||
|
+ public volatile boolean isMemBarVisible = false; //Luminol - Memory bar
|
||||||
|
|
||||||
|
public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() {
|
||||||
|
return this.viewDistances.get();
|
||||||
Reference in New Issue
Block a user