Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d74a32cb7 | |||
| 7da2307f4c | |||
| cdc69ecc09 | |||
| 7f0c8a2706 | |||
| 47bc8042d2 | |||
| 03849ba73c | |||
| ef3d1625b8 | |||
| c4acc049d8 | |||
| 3dc7b1edb7 | |||
| ab2992a2ef | |||
| 5622d49d49 | |||
| 7fdce6aedd |
@@ -74,11 +74,11 @@ body:
|
|||||||
All config files on your server.
|
All config files on your server.
|
||||||
例如以下文件(或者文件夹):
|
例如以下文件(或者文件夹):
|
||||||
Example files (or folders):
|
Example files (or folders):
|
||||||
- \spigot.yml
|
- \spigot.yml
|
||||||
- \bukkit.yml
|
- \bukkit.yml
|
||||||
- \config\\\*
|
- \config\\\*
|
||||||
- \lophine_config\\\*
|
- \lophine_config\\\*
|
||||||
- \luminol_config\\\*
|
- \luminol_config\\\*
|
||||||
- type: textarea
|
- type: textarea
|
||||||
id: other
|
id: other
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
||||||
fetch-depth: 0 # a full history is required for pull request analysis
|
fetch-depth: 0 # a full history is required for pull request analysis
|
||||||
- name: 'Qodana Scan'
|
- name: 'Qodana Scan'
|
||||||
uses: JetBrains/qodana-action@v2025.2
|
uses: JetBrains/qodana-action@latest
|
||||||
with:
|
with:
|
||||||
pr-mode: false
|
pr-mode: false
|
||||||
env:
|
env:
|
||||||
|
|||||||
+3
-5
@@ -6,12 +6,10 @@ build
|
|||||||
|
|
||||||
/run
|
/run
|
||||||
|
|
||||||
/lightingluminol-server/build.gradle.kts
|
/lophine-server/build.gradle.kts
|
||||||
/lightingluminol-api/build.gradle.kts
|
/lophine-api/build.gradle.kts
|
||||||
/luminol-server/build.gradle.kts
|
/lophine-server/src/minecraft
|
||||||
/luminol-server/src/minecraft
|
|
||||||
/paper-server
|
/paper-server
|
||||||
/luminol-api/build.gradle.kts
|
|
||||||
/paper-api
|
/paper-api
|
||||||
/paper-api-generator
|
/paper-api-generator
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java // TODO java launcher tasks
|
java // TODO java launcher tasks
|
||||||
id("moe.luminolmc.hyacinthusweight.patcher") version "+" // Automatically pulls the latest
|
id("moe.luminolmc.hyacinthusweight.patcher")
|
||||||
}
|
}
|
||||||
|
|
||||||
paperweight {
|
paperweight {
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
### Carpet 原版
|
||||||
|
|
||||||
|
| 规则 | 状态 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `language` | 已映射 | 转发到 `lophine.function.language.lang` |
|
||||||
|
| `commandTick` | 已映射 | 转发到现有的 tick 指令补丁 |
|
||||||
|
| `creativeNoClip` | 已映射 | 转发到 Lophine 的创造飞行穿墙实现 |
|
||||||
|
| `ctrlQCraftingFix` | 结构等价 | 当前的合成与切石机菜单已经自带修复后的 Ctrl+Q 结果槽丢弃行为 |
|
||||||
|
| `placementRotationFix` | 已移植 | 放置朝向判断可使用玩家身体朝向而不是头部旋转 |
|
||||||
|
| `tntDoNotUpdate` | 已移植 | 新放置的 TNT 不会再因放置时更新而自动点燃 |
|
||||||
|
| `explosionNoBlockDamage` | 已移植 | 爆炸仍会伤害实体,但不会破坏方块 |
|
||||||
|
| `interactionUpdates` | 已移植 | 玩家交互和破坏方块时可以在不触发邻居更新与形状更新的情况下运行 |
|
||||||
|
| `xpNoCooldown` | 已移植 | 经验球可以在同一 tick 内被连续吸收,不再有拾取冷却 |
|
||||||
|
| `viewDistance` | 已移植 | 专用服务器启动视距会被兼容配置覆盖 |
|
||||||
|
| `fastRedstoneDust` | 已移植 | 规则启用时,红石粉更新会统一走 Alternate Current 快速更新后端 |
|
||||||
|
| `lagFreeSpawning` | 已移植 | 自然生成会使用轻量碰撞检查与预构造实体路径 |
|
||||||
|
| `defaultLoggers` | 已移植 | 按 Carpet 默认订阅语义为玩家启用 HUD logger,当前支持 `tps`、`mobcaps`、`counter` |
|
||||||
|
| `commandPlayer` | 已映射 | 当前由同一套 `/bot` 假人能力承接 |
|
||||||
|
| `hopperCounters` | 已映射 | 转发到 Lophine 的羊毛漏斗计数器 |
|
||||||
|
|
||||||
|
### Carpet TIS Addition
|
||||||
|
|
||||||
|
| 规则 | 状态 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `yeetUpdateSuppressionCrash` | 已映射 | 转发到同一套 Lophine 崩溃修复逻辑 |
|
||||||
|
| `dustTrapdoorReintroduced` | 已映射 | 转发到 `lophine.experiment.redstone.redstone-ignore-upwards-update` |
|
||||||
|
| `shulkerBoxCCEReintroduced` | 已映射 | 转发到 `lophine.experiment.redstone.cce-update-suppression` |
|
||||||
|
| `instantBlockUpdaterReintroduced` | 已映射 | 转发到 `lophine.experiment.redstone.instant-block-updater` |
|
||||||
|
| `optimizedDragonRespawn` | 已映射 | 转发到 Luminol 的末影龙重生优化 |
|
||||||
|
| `antiSpamDisabled` | 已移植 | 在 `ServerGamePacketListenerImpl` 中关闭聊天和创造丢物防刷屏限制 |
|
||||||
|
| `blockPlacementIgnoreEntity` | 已移植 | 创造模式放置方块时忽略实体碰撞检查 |
|
||||||
|
| `creativeOpenContainerForcibly` | 已移植 | 创造玩家可以强制打开被阻挡的箱子、末影箱和潜影盒 |
|
||||||
|
| `observerNoDetection` | 已移植 | 观察者的检测触发会在发出脉冲前被取消 |
|
||||||
|
| `creativeNoItemCooldown` | 已移植 | 创造玩家不会应用物品冷却 |
|
||||||
|
| `totallyNoBlockUpdate` | 已移植 | 邻居更新和形状更新会在 `NeighborUpdater` 中被统一短路 |
|
||||||
|
| `tiscmNetworkProtocol` | 已移植 | 原生 `tiscm:network/v1` 握手与数据包协商已经通过专用 Leaves 协议接入 |
|
||||||
|
| `optimizedTNTHighPriority` | 结构等价 | 当前 `ServerExplosion` 路径已经运行在优化过的服务端爆炸实现上 |
|
||||||
|
| `tntIgnoreRedstoneSignal` | 已移植 | TNT 在自动点燃判断时忽略红石信号 |
|
||||||
|
| `tntDupingFix` | 已移植 | 活塞复制 TNT 的路径现在由 `PistonBaseBlock` 中的兼容规则直接控制 |
|
||||||
|
| `clientSettingsLostOnRespawnFix` | 已移植 | 玩家上一次的客户端设置会在 `ServerPlayer.restoreFrom` 中恢复 |
|
||||||
|
| `entityInstantDeathRemoval` | 已移植 | 已死亡生物不会再保留原版的 20gt 延迟,而是立即移除 |
|
||||||
|
| `farmlandTrampledDisabled` | 已移植 | 耕地不会再因实体踩踏而变回泥土 |
|
||||||
|
| `yeetOutOfOrderChatKick` | 已移植 | 乱序的签名聊天不会再破坏安全聊天链 |
|
||||||
|
| `tickCommandPermission` | 已移植 | `/tick` 的权限等级可通过兼容配置调整 |
|
||||||
|
| `tickFreezeCommandToggleable` | 已移植 | 已冻结时再次执行 `/tick freeze` 会切换回运行状态 |
|
||||||
|
| `syncServerMsptMetricsData` | 已移植 | 实时 MSPT 样本会通过原生 TISCM 协议通道广播 |
|
||||||
|
| `microTiming` | 结构等价 | 当前 Folia 的区块级性能分析与计时钩子已经提供对应的服务端观测能力 |
|
||||||
|
| `optimizedFastEntityMovement` | 结构等价 | Moonrise/Paper 的快速实体移动碰撞优化已经是基础运行时的一部分 |
|
||||||
|
| `optimizedHardHitBoxEntityCollision` | 结构等价 | Moonrise/Paper 的硬碰撞箱实体碰撞优化已经是基础运行时的一部分 |
|
||||||
|
| `tntFuseDuration` | 已移植 | 可配置的 TNT 引信时长已接入 NMS TNT 逻辑 |
|
||||||
|
| `fakePlayerTicksLikeRealPlayer` | 已映射 | 转发到 Leaves 的假人网络阶段 tick 行为 |
|
||||||
|
| `hopperCountersUnlimitedSpeed` | 已映射 | 转发到不限速计数器模式 |
|
||||||
|
|
||||||
|
### Carpet Org Addition
|
||||||
|
|
||||||
|
| 规则 | 状态 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `hopperNoItemCost` | 已移植 | 漏斗上方放置羊毛时,可在传输后恢复被推出的物品堆,实现零消耗供给线 |
|
||||||
|
| `simpleInGameCalculator` | 已移植 | 以 `=` 开头的聊天内容会作为简单计算表达式私聊回复 |
|
||||||
|
|
||||||
|
### Carpet AMS Addition
|
||||||
|
|
||||||
|
| 规则 | 状态 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `amsUpdateSuppressionCrashFix` | 已映射 | 转发到 Lophine 现有的更新抑制崩溃修复 |
|
||||||
|
| `creativeOneHitKill` | 已移植 | 创造玩家可通过 `Player.attack` 瞬间击杀附近符合条件的目标 |
|
||||||
|
| `bambooModelNoOffset` | 已移植 | 竹子和竹笋始终返回零模型偏移 |
|
||||||
|
| `carpetAlwaysSetDefault` | 结构等价 | 兼容配置默认值已经会在 `ConfigsInstance.preLoadConfig` 中被写入 |
|
||||||
|
| `powerfulExpMending` | 已移植 | 经验拾取会修复玩家整个背包内所有受损的经验修补物品 |
|
||||||
|
| `sensibleEnderman` | 已移植 | 末影人仅会在规则开启时拾取南瓜和西瓜 |
|
||||||
|
| `shulkerGolem` | 已移植 | 潜影盒上方放置雕刻南瓜时可以召唤潜影贝 |
|
||||||
|
| `preventEndSpikeRespawn` | 已移植 | 末影龙重生时会跳过黑曜石柱重建和柱顶水晶重建 |
|
||||||
|
| `betterCraftableBoneBlock` | 已移植 | 向配方管理器注入 AMS 的替代骨块配方 |
|
||||||
|
| `betterCraftableDispenser` | 已移植 | 向配方管理器注入 AMS 的替代发射器配方 |
|
||||||
|
| `fakePlayerDefaultSurvivalMode` | 已移植 | 新创建的假人可以被强制设为生存模式,而不是沿用服务器默认游戏模式 |
|
||||||
|
| `fakePlayerInteractLikeClient` | 已移植 | 假人与盔甲架交互时会先按真实客户端方式回退,再进入普通实体交互 |
|
||||||
|
| `fakePlayerAutoReplenishmentFormShulkerBox` | 已移植 | 假人自动补货现在可以从背包里的潜影盒中抽取匹配物品 |
|
||||||
|
|
||||||
|
### Lophine 扩展承接
|
||||||
|
|
||||||
|
| 规则 | 状态 | 说明 |
|
||||||
|
| --- | --- |----------------------------------|
|
||||||
|
| `commandBot` | 已映射 | 启用 Lophine `/bot` |
|
||||||
|
| `fakePlayerResident` | 已映射 | 转发到 Lophine 的假人常驻模式 |
|
||||||
|
| `openFakePlayerInventory` | 已映射 | 转发到 Lophine 的假人背包打开功能 |
|
||||||
|
| `fakePlayerAutoReplaceTool` | 已映射 | 为现有自动换工具逻辑增加了新开关 |
|
||||||
|
| `fakePlayerAutoReplenishment` | 已映射 | 为现有自动补货逻辑增加了新开关 |
|
||||||
|
| `fakePlayerReloadAction` | 已映射 | 为假人动作持久化增加了新开关 |
|
||||||
|
| `fakePlayerAutoFish` | 已移植 | 手持鱼竿的假人会自动抛竿和收杆,除非显式执行 `fish` 动作 |
|
||||||
+3
-1
@@ -1,10 +1,12 @@
|
|||||||
group=fun.bm.lophine
|
group=fun.bm.lophine
|
||||||
version=1.21.8-R0.1-SNAPSHOT
|
version=1.21.8-R0.1-SNAPSHOT
|
||||||
mcVersion=1.21.8
|
mcVersion=1.21.8
|
||||||
|
clipVersion=3.0.15-20260413.051550-1
|
||||||
|
weightVersion=2.0.7
|
||||||
release=2
|
release=2
|
||||||
# 0 for skip release, 1 for pre-release, 2 for release
|
# 0 for skip release, 1 for pre-release, 2 for release
|
||||||
|
|
||||||
luminolRef=e324edacf6651633674a0abce91ffbd290943dd5
|
luminolRef=170d047a69f8e4711651f475d6a795878651b1eb
|
||||||
|
|
||||||
org.gradle.configuration-cache=true
|
org.gradle.configuration-cache=true
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
|
|||||||
@@ -42,12 +42,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val log4jPlugins = sourceSets.create("log4jPlugins") {
|
val log4jPlugins = sourceSets.create("log4jPlugins") {
|
||||||
@@ -174,7 +_,7 @@
|
@@ -174,7 +_,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
- implementation(project(":luminol-api")) // Luminol
|
- implementation(project(":luminol-api")) // Luminol
|
||||||
+ implementation(project(":lophine-api")) // Lophine
|
+ implementation(project(":lophine-api")) // Lophine
|
||||||
|
+ implementation("net.objecthunter:exp4j:0.4.8") // Lophine
|
||||||
// Luminol start - Dependenices insert
|
// Luminol start - Dependenices insert
|
||||||
implementation("com.electronwill.night-config:toml:3.8.2") // Night config
|
implementation("com.electronwill.night-config:toml:3.8.2") // Night config
|
||||||
implementation("com.github.luben:zstd-jni:1.5.4-1")
|
implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||||
|
Date: Wed, 22 Apr 2026 00:51:19 +0800
|
||||||
|
Subject: [PATCH] Carpet features
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/ConfigManager.java b/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
index cb1657939b86c039fcfe6403d3f202c2c5879e88..3ba4faad544d2cf05b129a8d6142fc99a284299b 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
@@ -24,6 +24,13 @@ public class ConfigManager {
|
||||||
|
public static void initConfigs() {
|
||||||
|
configfiles.put("luminol", ConfigsInstance.of("luminol", "me.earthme.luminol.config.modules"));
|
||||||
|
configfiles.put("lophine", ConfigsInstance.of("lophine", "fun.bm.lophine.config.modules")); // add lophine config to global config
|
||||||
|
+ configfiles.put("lophine_carpet", ConfigsInstance.of(
|
||||||
|
+ new java.io.File("lophine_config"),
|
||||||
|
+ "lophine_carpet",
|
||||||
|
+ "lophine_carpet_config.toml",
|
||||||
|
+ "lophinecarpetconfig",
|
||||||
|
+ "fun.bm.lophine.carpet.config.modules"
|
||||||
|
+ )); // add lophine carpet config
|
||||||
|
preLoad();
|
||||||
|
}
|
||||||
|
|
||||||
+133
@@ -0,0 +1,133 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||||
|
Date: Wed, 22 Apr 2026 01:30:16 +0800
|
||||||
|
Subject: [PATCH] Luminol - 1.21.11: config system update
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/commands/bar/sub/ConfigEditCommand.java b/src/main/java/me/earthme/luminol/commands/bar/sub/ConfigEditCommand.java
|
||||||
|
index aad55088cb1ea2066f7f609b7d600e5ec0e68b8a..865f2ee6e4e63034a240c06b517c084a854141ed 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/commands/bar/sub/ConfigEditCommand.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/commands/bar/sub/ConfigEditCommand.java
|
||||||
|
@@ -57,7 +57,7 @@ public class ConfigEditCommand extends LiteralNode {
|
||||||
|
.text("Bar type with " + bar_name + " was already " + (value ? "enabled" : "disabled") + "!")
|
||||||
|
.color(TextColor.color(255, 0, 0)));
|
||||||
|
} else {
|
||||||
|
- ConfigsInstance config = ConfigManager.configfiles.get("luminol");
|
||||||
|
+ ConfigsInstance config = ConfigManager.getConfigs("luminol");
|
||||||
|
if (config.setConfig(configPath, value)) {
|
||||||
|
config.reloadAsync(true).thenAccept(nullValue -> context.getSender().sendMessage(
|
||||||
|
Component
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/ConfigManager.java b/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
index 3ba4faad544d2cf05b129a8d6142fc99a284299b..60a73a29ed2a4e0587a7c90186f990189c7da872 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/ConfigManager.java
|
||||||
|
@@ -6,15 +6,16 @@ import me.earthme.luminol.config.flags.TransformedConfig;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
-import java.util.HashSet;
|
||||||
|
-import java.util.Map;
|
||||||
|
-import java.util.Set;
|
||||||
|
+import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
+import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
|
public class ConfigManager {
|
||||||
|
- public static final Map<String, ConfigsInstance> configfiles = new ConcurrentHashMap<>();
|
||||||
|
- public static final Map<TransformedConfig, String[]> needTransformedConfigs = new ConcurrentHashMap<>();
|
||||||
|
+ private static boolean initialized = false;
|
||||||
|
+ private static final Map<String, ConfigsInstance> configfiles = new HashMap<>();
|
||||||
|
+ private static final Collection<Runnable> runnableBeforeFinalLoad = new ConcurrentLinkedQueue<>();
|
||||||
|
+ private static final Map<TransformedConfig, String[]> needTransformedConfigs = new ConcurrentHashMap<>();
|
||||||
|
// String[]:
|
||||||
|
// 0 -> origin key
|
||||||
|
// 1 -> target key
|
||||||
|
@@ -49,21 +50,34 @@ public class ConfigManager {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadConfigFiles() {
|
||||||
|
+ runTaskBeforeFinalLoad();
|
||||||
|
CompletableFuture<?>[] futures = configfiles.values().stream()
|
||||||
|
.map(config -> CompletableFuture.runAsync(config::finalizeLoadConfig))
|
||||||
|
.toArray(CompletableFuture[]::new);
|
||||||
|
CompletableFuture.allOf(futures).join();
|
||||||
|
CommandRegister.register(); // register command after config loaded to enable some command didn't depend on config files
|
||||||
|
+ initialized = true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void registerRunnableBeforeFinalLoad(Runnable runnable) {
|
||||||
|
+ if (initialized) return;
|
||||||
|
+ runnableBeforeFinalLoad.add(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerTransformedConfig(@NotNull String origin, @NotNull String target, @NotNull String originKey, @NotNull String targetKey, TransformedConfig transformedConfig) {
|
||||||
|
+ if (initialized) return;
|
||||||
|
needTransformedConfigs.put(transformedConfig, new String[]{origin, target, originKey, targetKey});
|
||||||
|
}
|
||||||
|
|
||||||
|
- private static ConfigsInstance getConfigs(String name) {
|
||||||
|
+ public static ConfigsInstance getConfigs(String name) {
|
||||||
|
return configfiles.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private static void runTaskBeforeFinalLoad() {
|
||||||
|
+ runnableBeforeFinalLoad.forEach(Runnable::run);
|
||||||
|
+ runnableBeforeFinalLoad.clear();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private static void acceptTransformedConfigs() {
|
||||||
|
Set<ConfigsInstance> toReload = new HashSet<>();
|
||||||
|
for (Map.Entry<TransformedConfig, String[]> entry : needTransformedConfigs.entrySet()) {
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/ConfigsInstance.java b/src/main/java/me/earthme/luminol/config/ConfigsInstance.java
|
||||||
|
index bd9ff74e482906701077f801c3f97bf5bd8f195b..55b01a36f45cf3534ee0b30ba27c9682b078ac1b 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/config/ConfigsInstance.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/ConfigsInstance.java
|
||||||
|
@@ -248,7 +248,8 @@ public class ConfigsInstance {
|
||||||
|
*/
|
||||||
|
private List<String> buildConfigCategoryPath(ConfigClassInfo configClassInfo) {
|
||||||
|
final List<String> category = new ArrayList<>();
|
||||||
|
- category.add(configClassInfo.category().getBaseKeyName());
|
||||||
|
+ String category0 = configClassInfo.category().getBaseKeyName();
|
||||||
|
+ if (category0 != null) category.add(category0);
|
||||||
|
category.addAll(List.of(configClassInfo.directory()));
|
||||||
|
category.add(configClassInfo.name());
|
||||||
|
return category;
|
||||||
|
@@ -311,6 +312,9 @@ public class ConfigsInstance {
|
||||||
|
// Handle existing configurations
|
||||||
|
handleExistingConfig(field, fullConfigKeyName, configInfo, doNotReload, keepComments);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // handle tasks need processed before config finalized
|
||||||
|
+ ConfigManager.registerRunnableBeforeFinalLoad(singleConfigModule::beforeFinalLoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/config/IConfigModule.java b/src/main/java/me/earthme/luminol/config/IConfigModule.java
|
||||||
|
index c5fee207479c331575d49cf625164ac2f5362d4a..dc880ce0f1fcec0acc9706324eef9a4a6e16ee17 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/config/IConfigModule.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/config/IConfigModule.java
|
||||||
|
@@ -7,6 +7,9 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface IConfigModule {
|
||||||
|
+ default void beforeFinalLoad() {
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
default void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/earthme/luminol/enums/EnumConfigCategory.java b/src/main/java/me/earthme/luminol/enums/EnumConfigCategory.java
|
||||||
|
index f79bf3dd37519c61ed0aa87b9b51c7ab7bc02d11..07e33c5e1f2dc9ce3fc18f48580b13f9aef6244a 100644
|
||||||
|
--- a/src/main/java/me/earthme/luminol/enums/EnumConfigCategory.java
|
||||||
|
+++ b/src/main/java/me/earthme/luminol/enums/EnumConfigCategory.java
|
||||||
|
@@ -7,7 +7,8 @@ public enum EnumConfigCategory {
|
||||||
|
FUNCTION("function"), // new functions
|
||||||
|
EXPERIMENT("experiment"), // experimental features
|
||||||
|
UNSUPPORTED("unsupported"), // features we do not want anyone to use
|
||||||
|
- REMOVED("removed"); // removed config
|
||||||
|
+ REMOVED("removed"), // removed config
|
||||||
|
+ ROOT(null);
|
||||||
|
|
||||||
|
private final String baseKeyName;
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
+94
@@ -0,0 +1,94 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||||
|
Date: Fri, 16 Jan 2026 02:34:43 +0800
|
||||||
|
Subject: [PATCH] Add config to enable save-all command
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
|
index e1842ab8f20271a8b20ab8462b09a4745a612a9a..6deaeaf95a43e217f65d3e0764b844ff4573d4ca 100644
|
||||||
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
|
@@ -317,6 +317,8 @@ public final class RegionizedServer {
|
||||||
|
// tick player ping sample
|
||||||
|
this.tickPlayerSample();
|
||||||
|
|
||||||
|
+ fun.bm.lophine.utils.SaveAllUtil.checkTimeout(); // Lophine - save-all fix
|
||||||
|
+
|
||||||
|
// tick worlds
|
||||||
|
for (final ServerLevel world : this.worlds) {
|
||||||
|
this.globalTick(world, tickCount);
|
||||||
|
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
|
index bfb39cbf1ba58d02da7e35300eb95872747506e8..25e8f26f708b68bd90f57863e7833e6502d981e2 100644
|
||||||
|
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
|
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
||||||
|
@@ -168,6 +168,8 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||||
|
public final ThreadedRegionizer.ThreadedRegion<TickRegionData, TickRegionSectionData> region;
|
||||||
|
public final ServerLevel world;
|
||||||
|
|
||||||
|
+ public long lastSavedTime = 0; // Lophine - save-all fix
|
||||||
|
+
|
||||||
|
// generic regionised data
|
||||||
|
private final Reference2ReferenceOpenHashMap<RegionizedData<?>, Object> regionizedData = new Reference2ReferenceOpenHashMap<>();
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||||
|
index 25ccbfa12d57d540195ecc16aa54a144f8ecc0e8..c00e0e74cb4c820a5c8b3722ebc1ff56318dae02 100644
|
||||||
|
--- a/net/minecraft/commands/Commands.java
|
||||||
|
+++ b/net/minecraft/commands/Commands.java
|
||||||
|
@@ -277,7 +277,11 @@ public class Commands {
|
||||||
|
PardonCommand.register(this.dispatcher);
|
||||||
|
PardonIpCommand.register(this.dispatcher);
|
||||||
|
//PerfCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
|
- //SaveAllCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
|
+ // Lophine start - Add a config to enable save all command
|
||||||
|
+ if (fun.bm.lophine.config.modules.experiment.CommandConfig.saveAll) {
|
||||||
|
+ SaveAllCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
|
+ }
|
||||||
|
+ // Lophine end - Add a config to enable save all command
|
||||||
|
SaveOffCommand.register(this.dispatcher);
|
||||||
|
SaveOnCommand.register(this.dispatcher);
|
||||||
|
SetPlayerIdleTimeoutCommand.register(this.dispatcher);
|
||||||
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
|
index 75027e73859c955a54034640f905cb5d91a6a2f4..1fa4110b61e49ee9527b65ecafb96b0dcd2c8ce2 100644
|
||||||
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -1581,6 +1581,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
// Folia start - region threading
|
||||||
|
public void tickServer(long startTime, long scheduledEnd, long targetBuffer,
|
||||||
|
io.papermc.paper.threadedregions.TickRegions.TickRegionData region) {
|
||||||
|
+ // Lophine start - save-all fix
|
||||||
|
+ if (fun.bm.lophine.utils.SaveAllUtil.isSaving()) {
|
||||||
|
+ fun.bm.lophine.utils.SaveAllUtil.postRegionSave(region);
|
||||||
|
+ }
|
||||||
|
+ // Lophine end - save-all fix
|
||||||
|
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
|
||||||
|
// Folia end - region threading
|
||||||
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
||||||
|
diff --git a/net/minecraft/server/commands/SaveAllCommand.java b/net/minecraft/server/commands/SaveAllCommand.java
|
||||||
|
index 15e0fce7500dc2dc2a712bf61d1d5506fd8f317a..71f53f057527192f8f830c7d21bd72233479fe55 100644
|
||||||
|
--- a/net/minecraft/server/commands/SaveAllCommand.java
|
||||||
|
+++ b/net/minecraft/server/commands/SaveAllCommand.java
|
||||||
|
@@ -21,7 +21,9 @@ public class SaveAllCommand {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int saveAll(CommandSourceStack source, boolean flush) throws CommandSyntaxException {
|
||||||
|
- source.sendSuccess(() -> Component.translatable("commands.save.saving"), false);
|
||||||
|
+ // Lophine start - save all
|
||||||
|
+ fun.bm.lophine.utils.SaveAllUtil.preSaveAll(source, flush);
|
||||||
|
+/* source.sendSuccess(() -> Component.translatable("commands.save.saving"), false);
|
||||||
|
MinecraftServer server = source.getServer();
|
||||||
|
boolean flag = server.saveEverything(true, flush, true);
|
||||||
|
if (!flag) {
|
||||||
|
@@ -29,6 +31,12 @@ public class SaveAllCommand {
|
||||||
|
} else {
|
||||||
|
source.sendSuccess(() -> Component.translatable("commands.save.success"), true);
|
||||||
|
return 1;
|
||||||
|
- }
|
||||||
|
+ }*/
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ public static SimpleCommandExceptionType getErrorFailed() {
|
||||||
|
+ return ERROR_FAILED;
|
||||||
|
+ }
|
||||||
|
+ // Lophine end - save all
|
||||||
|
}
|
||||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable scoreboard command
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||||
index 25ccbfa12d57d540195ecc16aa54a144f8ecc0e8..22d211bee83e3ef34d6ac81dd89c0e73924bee90 100644
|
index c00e0e74cb4c820a5c8b3722ebc1ff56318dae02..2be7e5de57f474a3600ea4990899c1955faa512e 100644
|
||||||
--- a/net/minecraft/commands/Commands.java
|
--- a/net/minecraft/commands/Commands.java
|
||||||
+++ b/net/minecraft/commands/Commands.java
|
+++ b/net/minecraft/commands/Commands.java
|
||||||
@@ -229,7 +229,11 @@ public class Commands {
|
@@ -229,7 +229,11 @@ public class Commands {
|
||||||
+5
-5
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config to enable tick command
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839621d73d7 100644
|
index 6deaeaf95a43e217f65d3e0764b844ff4573d4ca..1cefe9d83788dafc293aeb6d1b5e635211094b2a 100644
|
||||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
@@ -299,6 +299,11 @@ public final class RegionizedServer {
|
@@ -299,6 +299,11 @@ public final class RegionizedServer {
|
||||||
@@ -20,7 +20,7 @@ index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839
|
|||||||
// expire invalid click command callbacks
|
// expire invalid click command callbacks
|
||||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
|
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
|
||||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
|
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick
|
||||||
@@ -322,6 +327,13 @@ public final class RegionizedServer {
|
@@ -324,6 +329,13 @@ public final class RegionizedServer {
|
||||||
this.globalTick(world, tickCount);
|
this.globalTick(world, tickCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839
|
|||||||
// tick connections
|
// tick connections
|
||||||
this.tickConnections();
|
this.tickConnections();
|
||||||
|
|
||||||
@@ -455,7 +467,7 @@ public final class RegionizedServer {
|
@@ -457,7 +469,7 @@ public final class RegionizedServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tickTime(final ServerLevel world, final int tickCount) {
|
private void tickTime(final ServerLevel world, final int tickCount) {
|
||||||
@@ -97,7 +97,7 @@ index c485d5b3ba95f2a969bdf0dab9654ac284976f8d..b957585cf7cf7f845e20f59c7b355722
|
|||||||
this.scheduler.regionFailed(this, false, thr);
|
this.scheduler.regionFailed(this, false, thr);
|
||||||
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
||||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||||
index 22d211bee83e3ef34d6ac81dd89c0e73924bee90..1fb359073342a657e9e493403263b56be5b3393f 100644
|
index 2be7e5de57f474a3600ea4990899c1955faa512e..8d332f8e99ceb5a20b3b54bc327b024968719017 100644
|
||||||
--- a/net/minecraft/commands/Commands.java
|
--- a/net/minecraft/commands/Commands.java
|
||||||
+++ b/net/minecraft/commands/Commands.java
|
+++ b/net/minecraft/commands/Commands.java
|
||||||
@@ -249,7 +249,11 @@ public class Commands {
|
@@ -249,7 +249,11 @@ public class Commands {
|
||||||
@@ -114,7 +114,7 @@ index 22d211bee83e3ef34d6ac81dd89c0e73924bee90..1fb359073342a657e9e493403263b56b
|
|||||||
TitleCommand.register(this.dispatcher, context);
|
TitleCommand.register(this.dispatcher, context);
|
||||||
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index 75027e73859c955a54034640f905cb5d91a6a2f4..2f4970242c754cfba8ff5656a63af07d9d0a723c 100644
|
index 1fa4110b61e49ee9527b65ecafb96b0dcd2c8ce2..df5ff1cc7b289c3f52723d4e7b418e79ae6c3082 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -267,7 +267,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -267,7 +267,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
+29
-14
@@ -6,7 +6,7 @@ Subject: [PATCH] Add config to enable waypoint command & bar
|
|||||||
use concurrent method to fix it (now, they are thread safe)
|
use concurrent method to fix it (now, they are thread safe)
|
||||||
|
|
||||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||||
index 1fb359073342a657e9e493403263b56be5b3393f..451a685782da46f5683ea6707289bbaf3193771f 100644
|
index 8d332f8e99ceb5a20b3b54bc327b024968719017..d4357499cbfd0474dae3c66b4473b81367f284d1 100644
|
||||||
--- a/net/minecraft/commands/Commands.java
|
--- a/net/minecraft/commands/Commands.java
|
||||||
+++ b/net/minecraft/commands/Commands.java
|
+++ b/net/minecraft/commands/Commands.java
|
||||||
@@ -257,7 +257,11 @@ public class Commands {
|
@@ -257,7 +257,11 @@ public class Commands {
|
||||||
@@ -23,7 +23,7 @@ index 1fb359073342a657e9e493403263b56be5b3393f..451a685782da46f5683ea6707289bbaf
|
|||||||
WorldBorderCommand.register(this.dispatcher);
|
WorldBorderCommand.register(this.dispatcher);
|
||||||
if (JvmProfiler.INSTANCE.isAvailable()) {
|
if (JvmProfiler.INSTANCE.isAvailable()) {
|
||||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d188ad0489 100644
|
index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..65a4956ba2f0e38da7ae4f8cd7ed6e4b02c015a9 100644
|
||||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
@@ -16,22 +16,31 @@ import net.minecraft.world.waypoints.WaypointManager;
|
@@ -16,22 +16,31 @@ import net.minecraft.world.waypoints.WaypointManager;
|
||||||
@@ -57,7 +57,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
- SetView<ServerPlayer> set = Sets.difference(this.players, map.keySet());
|
- SetView<ServerPlayer> set = Sets.difference(this.players, map.keySet());
|
||||||
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> map = this.connections.getXZ(waypoint); // Lophine - concurrent
|
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> map = this.connections.getXZ(waypoint); // Lophine - concurrent
|
||||||
+ Set<ServerPlayer> players1 = new HashSet<>(); // Lophine - concurrent
|
+ Set<ServerPlayer> players1 = new HashSet<>(); // Lophine - concurrent
|
||||||
+ map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent
|
+ if (!map.isEmpty()) map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent
|
||||||
+ SetView<ServerPlayer> set = Sets.difference(this.players, players1); // Lophine - concurrent
|
+ SetView<ServerPlayer> set = Sets.difference(this.players, players1); // Lophine - concurrent
|
||||||
|
|
||||||
- for (Entry<ServerPlayer, WaypointTransmitter.Connection> entry : ImmutableSet.copyOf(map.entrySet())) {
|
- for (Entry<ServerPlayer, WaypointTransmitter.Connection> entry : ImmutableSet.copyOf(map.entrySet())) {
|
||||||
@@ -65,14 +65,16 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
this.updateConnection(entry.getKey(), waypoint, entry.getValue());
|
this.updateConnection(entry.getKey(), waypoint, entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,26 +52,60 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -43,26 +52,65 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void untrackWaypoint(WaypointTransmitter waypoint) {
|
public void untrackWaypoint(WaypointTransmitter waypoint) {
|
||||||
- this.connections.column(waypoint).forEach((serverPlayer, connection) -> connection.disconnect());
|
- this.connections.column(waypoint).forEach((serverPlayer, connection) -> connection.disconnect());
|
||||||
- Tables.transpose(this.connections).row(waypoint).clear();
|
- Tables.transpose(this.connections).row(waypoint).clear();
|
||||||
+ this.connections.getXZ(waypoint).forEach((entry) -> entry.getKey().disconnect()); // Lophine - concurrent
|
+ this.connections.getXZ(waypoint).forEach((entry) -> {
|
||||||
+ this.connections.clearXZ(waypoint); // Lophine - concurrent
|
+ entry.getValue().disconnect();
|
||||||
|
+ this.connections.remove(entry.getKey(), waypoint, entry.getValue());
|
||||||
|
+ }); // Lophine - concurrent
|
||||||
this.waypoints.remove(waypoint);
|
this.waypoints.remove(waypoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
+ java.util.List<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> map = this.connections.getYZ(player); // Lophine - concurrent
|
+ java.util.List<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> map = this.connections.getYZ(player); // Lophine - concurrent
|
||||||
+ Set<WaypointTransmitter> waypoints1 = new HashSet<>();// Lophine - concurrent
|
+ Set<WaypointTransmitter> waypoints1 = new HashSet<>();// Lophine - concurrent
|
||||||
+ map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent
|
+ if (!map.isEmpty()) map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent
|
||||||
+ SetView<WaypointTransmitter> set = Sets.difference(this.waypoints, waypoints1); // Lophine - concurrent
|
+ SetView<WaypointTransmitter> set = Sets.difference(this.waypoints, waypoints1); // Lophine - concurrent
|
||||||
+
|
+
|
||||||
+ for (Entry<WaypointTransmitter, WaypointTransmitter.Connection> entry : map) { // Lophine - concurrent
|
+ for (Entry<WaypointTransmitter, WaypointTransmitter.Connection> entry : map) { // Lophine - concurrent
|
||||||
@@ -115,8 +117,10 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
// Folia - region threading
|
// Folia - region threading
|
||||||
+ // Lophine start - unsafe waypoint bar
|
+ // Lophine start - unsafe waypoint bar
|
||||||
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
+ this.connections.getYZ(player).forEach((entry) -> entry.getValue().disconnect()); // Lophine - concurrent
|
+ this.connections.getYZ(player).forEach((entry) -> {
|
||||||
+ this.connections.clearYZ(player); // Lophine - concurrent
|
+ entry.getValue().disconnect();
|
||||||
|
+ this.connections.remove(player, entry.getKey(), entry.getValue());
|
||||||
|
+ }); // Lophine - concurrent
|
||||||
+ this.untrackWaypoint((WaypointTransmitter)player);
|
+ this.untrackWaypoint((WaypointTransmitter)player);
|
||||||
+ this.players.remove(player);
|
+ this.players.remove(player);
|
||||||
+ // Lophine end - unsafe waypoint bar
|
+ // Lophine end - unsafe waypoint bar
|
||||||
@@ -125,13 +129,18 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
public void breakAllConnections() {
|
public void breakAllConnections() {
|
||||||
- this.connections.values().forEach(WaypointTransmitter.Connection::disconnect);
|
- this.connections.values().forEach(WaypointTransmitter.Connection::disconnect);
|
||||||
- this.connections.clear();
|
- this.connections.clear();
|
||||||
+ this.connections.getAllZ().forEach(WaypointTransmitter.Connection::disconnect); // Lophine - concurrent
|
+ java.util.List<WaypointTransmitter.Connection> map = this.connections.getAllZ(); // Lophine - concurrent
|
||||||
|
+ if (!map.isEmpty()) map.forEach(WaypointTransmitter.Connection::disconnect); // Lophine - concurrent
|
||||||
+ this.connections.clearAll(); // Lophine - concurrent
|
+ this.connections.clearAll(); // Lophine - concurrent
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remakeConnections(WaypointTransmitter waypoint) {
|
public void remakeConnections(WaypointTransmitter waypoint) {
|
||||||
@@ -86,10 +129,15 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -83,13 +131,19 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
this.connections.put(player, waypoint, connection);
|
if (player != waypoint) {
|
||||||
|
if (isLocatorBarEnabledFor(player)) {
|
||||||
|
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection -> {
|
||||||
|
- this.connections.put(player, waypoint, connection);
|
||||||
|
+ this.connections.putOrUpdate(player, waypoint, connection);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
}, () -> {
|
}, () -> {
|
||||||
- WaypointTransmitter.Connection connection = this.connections.remove(player, waypoint);
|
- WaypointTransmitter.Connection connection = this.connections.remove(player, waypoint);
|
||||||
@@ -140,6 +149,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
- }
|
- }
|
||||||
+ // Lophine start - concurrent
|
+ // Lophine start - concurrent
|
||||||
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint);
|
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint);
|
||||||
|
+ if (c.isEmpty()) return; // Lophine - concurrent
|
||||||
+ c.forEach((connection) -> {
|
+ c.forEach((connection) -> {
|
||||||
+ this.connections.remove(player, waypoint, connection);
|
+ this.connections.remove(player, waypoint, connection);
|
||||||
+ if (connection != null) {
|
+ if (connection != null) {
|
||||||
@@ -150,12 +160,17 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +154,8 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -103,10 +157,12 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
this.connections.put(player, waypoint, connection1);
|
} else {
|
||||||
|
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection1 -> {
|
||||||
|
connection1.connect();
|
||||||
|
- this.connections.put(player, waypoint, connection1);
|
||||||
|
+ this.connections.putOrUpdate(player, waypoint, connection1);
|
||||||
}, () -> {
|
}, () -> {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
- this.connections.remove(player, waypoint);
|
- this.connections.remove(player, waypoint);
|
||||||
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint); // Lophine - concurrent
|
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint); // Lophine - concurrent
|
||||||
|
+ if (c.isEmpty()) return; // Lophine - concurrent
|
||||||
+ c.forEach((connection1) -> this.connections.remove(player, waypoint, connection1)); // Lophine - concurrent
|
+ c.forEach((connection1) -> this.connections.remove(player, waypoint, connection1)); // Lophine - concurrent
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,10 +5,10 @@ Subject: [PATCH] Fix datapack command save function
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index 2f4970242c754cfba8ff5656a63af07d9d0a723c..b156b5c635f931a3d4abc0584591f90476d011a6 100644
|
index df5ff1cc7b289c3f52723d4e7b418e79ae6c3082..8f74af03cf0af0960b1016c8304ca0e440969215 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -2353,6 +2353,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -2358,6 +2358,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
return this.reloadResources(selectedIds, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
|
return this.reloadResources(selectedIds, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-2
@@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1
|
|||||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||||
|
|
||||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
index 8405157ec35a443e238fa6866772c839621d73d7..67f3454e6479abb241a7d94699d4f7bec22da56b 100644
|
index 1cefe9d83788dafc293aeb6d1b5e635211094b2a..e423d5c0614823ce9a8fbd32b672232e5758e3c1 100644
|
||||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||||
@@ -334,6 +334,8 @@ public final class RegionizedServer {
|
@@ -336,6 +336,8 @@ public final class RegionizedServer {
|
||||||
}
|
}
|
||||||
// Luminol end - Add a config to enable tick command
|
// Luminol end - Add a config to enable tick command
|
||||||
|
|
||||||
+6
-6
@@ -33,7 +33,7 @@ index 66ec0424a46dcd49cf44467357d80b1a2d84d3b2..58694e28b3ff85ef038fe2ada2672e6d
|
|||||||
private DisconnectionDetails disconnectionDetails;
|
private DisconnectionDetails disconnectionDetails;
|
||||||
private boolean encrypted;
|
private boolean encrypted;
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786e46148b1 100644
|
index 8f74af03cf0af0960b1016c8304ca0e440969215..c33757d3e53a97148c11f601cde0b6127d663f11 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -347,6 +347,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -347,6 +347,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
@@ -57,7 +57,7 @@ index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786
|
|||||||
// Folia start - region threading
|
// Folia start - region threading
|
||||||
// halt scheduler
|
// halt scheduler
|
||||||
// don't wait, we may be on a scheduler thread
|
// don't wait, we may be on a scheduler thread
|
||||||
@@ -1588,7 +1595,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1593,7 +1600,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
int i = this.pauseWhileEmptySeconds() * 20;
|
int i = this.pauseWhileEmptySeconds() * 20;
|
||||||
this.removeDisabledPluginsBlockingSleep(); // Paper - API to allow/disallow tick sleeping
|
this.removeDisabledPluginsBlockingSleep(); // Paper - API to allow/disallow tick sleeping
|
||||||
if (false && i > 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy
|
if (false && i > 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy
|
||||||
@@ -66,7 +66,7 @@ index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786
|
|||||||
this.emptyTicks++;
|
this.emptyTicks++;
|
||||||
} else {
|
} else {
|
||||||
this.emptyTicks = 0;
|
this.emptyTicks = 0;
|
||||||
@@ -1912,6 +1919,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1917,6 +1924,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|
||||||
public void tickConnection() {
|
public void tickConnection() {
|
||||||
this.getConnection().tick();
|
this.getConnection().tick();
|
||||||
@@ -74,7 +74,7 @@ index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void synchronizeTime(ServerLevel level) {
|
private void synchronizeTime(ServerLevel level) {
|
||||||
@@ -2983,6 +2991,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -2988,6 +2996,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d
|
|||||||
|
|
||||||
public boolean canBypassPlayerLimit(GameProfile profile) {
|
public boolean canBypassPlayerLimit(GameProfile profile) {
|
||||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
index 55cb2d16e22e4d8745da539177b636d188ad0489..ce0942793c4098a1274b8ef5736e824a6eec0152 100644
|
index 65a4956ba2f0e38da7ae4f8cd7ed6e4b02c015a9..044ded5ec81905e38efe8812ff6d50259d761385 100644
|
||||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
@@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
@@ -526,7 +526,7 @@ index 55cb2d16e22e4d8745da539177b636d188ad0489..ce0942793c4098a1274b8ef5736e824a
|
|||||||
this.waypoints.add(waypoint);
|
this.waypoints.add(waypoint);
|
||||||
|
|
||||||
for (ServerPlayer serverPlayer : this.players) {
|
for (ServerPlayer serverPlayer : this.players) {
|
||||||
@@ -61,6 +66,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -63,6 +68,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
// Folia - region threading
|
// Folia - region threading
|
||||||
// Lophine start - unsafe waypoint bar
|
// Lophine start - unsafe waypoint bar
|
||||||
if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
+5
-5
@@ -84,10 +84,10 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378
|
|||||||
players.add(serverPlayer1);
|
players.add(serverPlayer1);
|
||||||
if (players.size() >= resultLimit) {
|
if (players.size() >= resultLimit) {
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index 81726e5782d25ff35a2bea8820a62786e46148b1..3c94631f468f4ee1b46de9981c17171e5901d745 100644
|
index c33757d3e53a97148c11f601cde0b6127d663f11..c67fed7b35f273a2eb6809897a891988fe30558c 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -1800,7 +1800,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1805,7 +1805,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerStatus.Players buildPlayerStatus() {
|
private ServerStatus.Players buildPlayerStatus() {
|
||||||
@@ -96,7 +96,7 @@ index 81726e5782d25ff35a2bea8820a62786e46148b1..3c94631f468f4ee1b46de9981c17171e
|
|||||||
int maxPlayers = this.getMaxPlayers();
|
int maxPlayers = this.getMaxPlayers();
|
||||||
if (this.hidesOnlinePlayers()) {
|
if (this.hidesOnlinePlayers()) {
|
||||||
return new ServerStatus.Players(maxPlayers, players.size(), List.of());
|
return new ServerStatus.Players(maxPlayers, players.size(), List.of());
|
||||||
@@ -2001,7 +2001,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -2006,7 +2006,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerCount() {
|
public int getPlayerCount() {
|
||||||
@@ -105,7 +105,7 @@ index 81726e5782d25ff35a2bea8820a62786e46148b1..3c94631f468f4ee1b46de9981c17171e
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2415,7 +2415,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -2420,7 +2420,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
if (Thread.currentThread() != this.serverThread) return; // Paper
|
if (Thread.currentThread() != this.serverThread) return; // Paper
|
||||||
// Paper start - we don't need to save everything, just advancements
|
// Paper start - we don't need to save everything, just advancements
|
||||||
// this.getPlayerList().saveAll();
|
// this.getPlayerList().saveAll();
|
||||||
@@ -114,7 +114,7 @@ index 81726e5782d25ff35a2bea8820a62786e46148b1..3c94631f468f4ee1b46de9981c17171e
|
|||||||
player.getAdvancements().save();
|
player.getAdvancements().save();
|
||||||
}
|
}
|
||||||
// Paper end - we don't need to save everything, just advancements
|
// Paper end - we don't need to save everything, just advancements
|
||||||
@@ -2554,7 +2554,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -2559,7 +2559,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
if (!playerList.isUsingWhitelist()) return; // Paper - whitelist not enabled
|
if (!playerList.isUsingWhitelist()) return; // Paper - whitelist not enabled
|
||||||
UserWhiteList whiteList = playerList.getWhiteList();
|
UserWhiteList whiteList = playerList.getWhiteList();
|
||||||
|
|
||||||
+2
-2
@@ -33,10 +33,10 @@ index 7280ca2250ade4166a1a883b205bbc89f4e00d1a..06268ac3420fc03a798a20bb617ba89a
|
|||||||
throw makeReportedException(var4, packet, processor);
|
throw makeReportedException(var4, packet, processor);
|
||||||
}
|
}
|
||||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||||
index 3c94631f468f4ee1b46de9981c17171e5901d745..f7a2a19c0832ca90536d09de23f4ec9a7d4a1521 100644
|
index c67fed7b35f273a2eb6809897a891988fe30558c..1f1e23d9cd73e3ada89367a080de445a18823d7f 100644
|
||||||
--- a/net/minecraft/server/MinecraftServer.java
|
--- a/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/net/minecraft/server/MinecraftServer.java
|
+++ b/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -1878,8 +1878,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1883,8 +1883,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
try {
|
try {
|
||||||
profiler.startTimer(serverLevel.tickTimerId); try { // Folia - profiler
|
profiler.startTimer(serverLevel.tickTimerId); try { // Folia - profiler
|
||||||
serverLevel.tick(hasTimeLeft, region); // Folia - region threading
|
serverLevel.tick(hasTimeLeft, region); // Folia - region threading
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||||
|
Date: Tue, 13 Jan 2026 21:04:59 +0800
|
||||||
|
Subject: [PATCH] Add removed check before all checks start in addEffect
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index 205e2648569b7c18f488aa4d3d9ec944bb1babf4..c6ee14f14e051b30012e608b84a055ff2468850d 100644
|
||||||
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -1174,6 +1174,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||||
|
public boolean addEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
|
||||||
|
// Paper end - Don't fire sync event during generation
|
||||||
|
// org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API
|
||||||
|
+ if (this.isRemoved()) return false; // Lophine - shouldn't be possible to add effects to removed entity
|
||||||
|
if (!this.hasNullCallback()) ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this, "Cannot add effects to entities asynchronously"); // Folia - region threading
|
||||||
|
if (this.isTickingEffects) {
|
||||||
|
this.effectsToProcess.add(new ProcessableEffect(effectInstance, cause));
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: mrhua269 <mrhua269@gmail.com>
|
||||||
|
Date: Sat, 3 Jan 2026 10:42:39 +0800
|
||||||
|
Subject: [PATCH] Luminol - 1.21.11: Sync dragon part when teleportation or
|
||||||
|
firstly created
|
||||||
|
|
||||||
|
A simple fix of https://github.com/PaperMC/Folia/issues/371
|
||||||
|
|
||||||
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
|
||||||
|
index e3a49083e75116622bd95fb17533730a6fb36752..545697d9c081a270ff47b332baee68372c0dd67d 100644
|
||||||
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
|
||||||
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java
|
||||||
|
@@ -96,6 +96,7 @@ public final class ServerEntityLookup extends EntityLookup {
|
||||||
|
if (entity instanceof ThrownEnderpearl enderpearl) {
|
||||||
|
this.addEnderPearl(CoordinateUtils.getChunkKey(enderpearl.chunkPosition()), enderpearl.getId()); // Folia - region threading
|
||||||
|
}
|
||||||
|
+ if (entity instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Luminol - Sync dragon part when teleportation or firstly created
|
||||||
|
entity.registerScheduler(); // Paper - optimise Folia entity scheduler
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||||
|
index f63252c580c313ccf89304866cfc6503f4b26052..f0ddf0bf462a316f82f4babac17af6860b6ba143 100644
|
||||||
|
--- a/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4325,6 +4325,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
Entity copy = this.getType().create(destination, EntitySpawnReason.DIMENSION_TRAVEL);
|
||||||
|
copy.restoreFrom(this);
|
||||||
|
copy.transform(pos, yaw, pitch, velocity);
|
||||||
|
+ if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Luminol - Sync dragon part when teleportation or firstly created
|
||||||
|
if (toSameWorld) copy.notifyLithiumTrackerIfNeeded();// Luminol - region threading for sleeping block entity
|
||||||
|
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
|
||||||
|
// for example, clearing of inventory after switching dimensions
|
||||||
|
diff --git a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||||
|
index 84d215a498d9bf6f1232bf4af5a4a98d3ba9b131..2aa57b995d9fcfbd335655ef383314ce11d93707 100644
|
||||||
|
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||||
|
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||||
|
@@ -1003,4 +1003,12 @@ public class EnderDragon extends Mob implements Enemy {
|
||||||
|
return flag ? i : 0;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
+
|
||||||
|
+ // Luminol start - Sync dragon part when teleportation or firstly created
|
||||||
|
+ public void syncDragonPartsAfterTeleportTransform() {
|
||||||
|
+ for (EnderDragonPart part : this.subEntities) {
|
||||||
|
+ this.tickPart(part, 0.0, 0.0, 0.0); // offset -> 0.0
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Luminol end
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
|||||||
|
package fun.bm.lophine.carpet;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public final class CarpetCalculatorCompatHelper {
|
||||||
|
|
||||||
|
public static boolean handleChat(ServerPlayer player, String rawMessage) {
|
||||||
|
if (!GeneralCompatConfig.simpleInGameCalculator || !rawMessage.startsWith("=")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String expression = rawMessage.substring(1).trim();
|
||||||
|
if (expression.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component response;
|
||||||
|
try {
|
||||||
|
double result = new ExpressionBuilder(expression).build().evaluate();
|
||||||
|
response = Component.literal(expression + " = " + formatNumber(result)).withStyle(ChatFormatting.YELLOW);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
response = Component.literal("Calculator error: " + exception.getMessage()).withStyle(ChatFormatting.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component scheduledResponse = response;
|
||||||
|
player.getBukkitEntity().taskScheduler.schedule((ServerPlayer scheduledPlayer) -> scheduledPlayer.sendSystemMessage(scheduledResponse), null, 1L);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatNumber(double value) {
|
||||||
|
if (Double.isFinite(value) && Math.rint(value) == value && value >= Long.MIN_VALUE && value <= Long.MAX_VALUE) {
|
||||||
|
return Long.toString((long) value);
|
||||||
|
}
|
||||||
|
return BigDecimal.valueOf(value).stripTrailingZeros().toPlainString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package fun.bm.lophine.carpet;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.config.modules.CoreConfig;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.CounterCompatConfig;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||||
|
import fun.bm.lophine.config.modules.experiment.CommandConfig;
|
||||||
|
import fun.bm.lophine.config.modules.experiment.RedStoneConfig;
|
||||||
|
import fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig;
|
||||||
|
import fun.bm.lophine.config.modules.function.CreativeFlyNoClipConfig;
|
||||||
|
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||||
|
import fun.bm.lophine.config.modules.function.LanguageConfig;
|
||||||
|
import fun.bm.lophine.config.modules.function.WoolHopperCounterConfig;
|
||||||
|
import fun.bm.lophine.protocol.CarpetLoggerProtocol;
|
||||||
|
import me.earthme.luminol.config.modules.optimizations.OptimizedDragonRespawnConfig;
|
||||||
|
import org.leavesmc.leaves.bot.ServerBot;
|
||||||
|
import org.leavesmc.leaves.protocol.CarpetServerProtocol;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// WARNING: THIS FILE NEED TO FULLY REWRITTEN
|
||||||
|
public final class CarpetCompatSync {
|
||||||
|
private static boolean init = false;
|
||||||
|
|
||||||
|
public static void apply() {
|
||||||
|
if (init) return;
|
||||||
|
if (CoreConfig.enabled) {
|
||||||
|
applyGeneralRules();
|
||||||
|
applyFakePlayerRules();
|
||||||
|
applyCounterRules();
|
||||||
|
}
|
||||||
|
CarpetLoggerProtocol.refreshConfiguredDefaults(!init);
|
||||||
|
registerProtocolRules();
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyGeneralRules() {
|
||||||
|
LanguageConfig.lang = GeneralCompatConfig.language;
|
||||||
|
UpdateSuppressionCrashFixConfig.enabled = GeneralCompatConfig.amsUpdateSuppressionCrashFix || GeneralCompatConfig.yeetUpdateSuppressionCrash;
|
||||||
|
RedStoneConfig.redstoneIgnoreUpwardsUpdate = GeneralCompatConfig.dustTrapdoorReintroduced;
|
||||||
|
RedStoneConfig.cce = GeneralCompatConfig.shulkerBoxCCEReintroduced;
|
||||||
|
RedStoneConfig.instantBlockUpdater = GeneralCompatConfig.instantBlockUpdaterReintroduced;
|
||||||
|
CommandConfig.tick = GeneralCompatConfig.commandTick;
|
||||||
|
CreativeFlyNoClipConfig.enabled = GeneralCompatConfig.creativeNoClip;
|
||||||
|
OptimizedDragonRespawnConfig.optimizedRespawn = GeneralCompatConfig.optimizedDragonRespawn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyFakePlayerRules() {
|
||||||
|
FakeplayerConfig.enable = FakePlayerCompatConfig.commandBot || FakePlayerCompatConfig.commandPlayer;
|
||||||
|
FakeplayerConfig.canResident = FakePlayerCompatConfig.fakePlayerResident;
|
||||||
|
FakeplayerConfig.canOpenInventory = FakePlayerCompatConfig.openFakePlayerInventory;
|
||||||
|
FakeplayerConfig.tickType = FakePlayerCompatConfig.fakePlayerTicksLikeRealPlayer
|
||||||
|
? ServerBot.TickType.NETWORK
|
||||||
|
: ServerBot.TickType.ENTITY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyCounterRules() {
|
||||||
|
WoolHopperCounterConfig.enabled = CounterCompatConfig.hopperCounters;
|
||||||
|
WoolHopperCounterConfig.unlimitedSpeed = CounterCompatConfig.hopperCountersUnlimitedSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> sanitizeDefaultLoggers(List<String> configuredLoggers) {
|
||||||
|
return configuredLoggers == null ? List.of() : List.copyOf(configuredLoggers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerProtocolRules() {
|
||||||
|
CarpetServerProtocol.CarpetRules.clear();
|
||||||
|
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "language", GeneralCompatConfig.language));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "amsUpdateSuppressionCrashFix", GeneralCompatConfig.amsUpdateSuppressionCrashFix));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "yeetUpdateSuppressionCrash", GeneralCompatConfig.yeetUpdateSuppressionCrash));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "dustTrapdoorReintroduced", GeneralCompatConfig.dustTrapdoorReintroduced));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "shulkerBoxCCEReintroduced", GeneralCompatConfig.shulkerBoxCCEReintroduced));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "instantBlockUpdaterReintroduced", GeneralCompatConfig.instantBlockUpdaterReintroduced));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "commandTick", GeneralCompatConfig.commandTick));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "creativeNoClip", GeneralCompatConfig.creativeNoClip));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "optimizedDragonRespawn", GeneralCompatConfig.optimizedDragonRespawn));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "antiSpamDisabled", GeneralCompatConfig.antiSpamDisabled));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "blockPlacementIgnoreEntity", GeneralCompatConfig.blockPlacementIgnoreEntity));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "creativeOpenContainerForcibly", GeneralCompatConfig.creativeOpenContainerForcibly));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "creativeOneHitKill", GeneralCompatConfig.creativeOneHitKill));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "observerNoDetection", GeneralCompatConfig.observerNoDetection));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "bambooModelNoOffset", GeneralCompatConfig.bambooModelNoOffset));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "creativeNoItemCooldown", GeneralCompatConfig.creativeNoItemCooldown));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "ctrlQCraftingFix", GeneralCompatConfig.ctrlQCraftingFix));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "carpetAlwaysSetDefault", GeneralCompatConfig.carpetAlwaysSetDefault));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "placementRotationFix", GeneralCompatConfig.placementRotationFix));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "tntDoNotUpdate", GeneralCompatConfig.tntDoNotUpdate));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "totallyNoBlockUpdate", GeneralCompatConfig.totallyNoBlockUpdate));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tiscmNetworkProtocol", GeneralCompatConfig.tiscmNetworkProtocol));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetorgaddition", "hopperNoItemCost", GeneralCompatConfig.hopperNoItemCost));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "explosionNoBlockDamage", GeneralCompatConfig.explosionNoBlockDamage));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "optimizedTNTHighPriority", GeneralCompatConfig.optimizedTNTHighPriority));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "tntPrimerMomentumRemoved", GeneralCompatConfig.tntPrimerMomentumRemoved));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tntIgnoreRedstoneSignal", GeneralCompatConfig.tntIgnoreRedstoneSignal));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tntDupingFix", GeneralCompatConfig.tntDupingFix));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "interactionUpdates", GeneralCompatConfig.interactionUpdates));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "xpNoCooldown", GeneralCompatConfig.xpNoCooldown));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "powerfulExpMending", GeneralCompatConfig.powerfulExpMending));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "clientSettingsLostOnRespawnFix", GeneralCompatConfig.clientSettingsLostOnRespawnFix));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "sensibleEnderman", GeneralCompatConfig.sensibleEnderman));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "entityInstantDeathRemoval", GeneralCompatConfig.entityInstantDeathRemoval));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "farmlandTrampledDisabled", GeneralCompatConfig.farmlandTrampledDisabled));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "shulkerGolem", GeneralCompatConfig.shulkerGolem));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "preventEndSpikeRespawn", GeneralCompatConfig.preventEndSpikeRespawn));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "yeetOutOfOrderChatKick", GeneralCompatConfig.yeetOutOfOrderChatKick));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "betterCraftableBoneBlock", GeneralCompatConfig.betterCraftableBoneBlock));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "betterCraftableDispenser", GeneralCompatConfig.betterCraftableDispenser));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "viewDistance", GeneralCompatConfig.viewDistance));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tickCommandPermission", GeneralCompatConfig.normalizedTickCommandPermission()));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tickFreezeCommandToggleable", GeneralCompatConfig.tickFreezeCommandToggleable));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "syncServerMsptMetricsData", GeneralCompatConfig.syncServerMsptMetricsData));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetorgaddition", "simpleInGameCalculator", GeneralCompatConfig.simpleInGameCalculator));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "microTiming", GeneralCompatConfig.microTiming));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "fastRedstoneDust", GeneralCompatConfig.fastRedstoneDust));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "lagFreeSpawning", GeneralCompatConfig.lagFreeSpawning));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "optimizedFastEntityMovement", GeneralCompatConfig.optimizedFastEntityMovement));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "optimizedHardHitBoxEntityCollision", GeneralCompatConfig.optimizedHardHitBoxEntityCollision));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tntFuseDuration", GeneralCompatConfig.normalizedTntFuseDuration()));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "defaultLoggers", CarpetLoggerProtocol.serializeConfiguredDefaults(sanitizeDefaultLoggers(GeneralCompatConfig.defaultLoggers))));
|
||||||
|
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "commandBot", FakePlayerCompatConfig.commandBot));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "commandPlayer", FakePlayerCompatConfig.commandPlayer));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerResident", FakePlayerCompatConfig.fakePlayerResident));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "openFakePlayerInventory", FakePlayerCompatConfig.openFakePlayerInventory));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "fakePlayerTicksLikeRealPlayer", FakePlayerCompatConfig.fakePlayerTicksLikeRealPlayer));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "fakePlayerDefaultSurvivalMode", FakePlayerCompatConfig.fakePlayerDefaultSurvivalMode));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "fakePlayerInteractLikeClient", FakePlayerCompatConfig.fakePlayerInteractLikeClient));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerAutoReplaceTool", FakePlayerCompatConfig.fakePlayerAutoReplaceTool));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerAutoReplenishment", FakePlayerCompatConfig.fakePlayerAutoReplenishment));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpetamsaddition", "fakePlayerAutoReplenishmentFormShulkerBox", FakePlayerCompatConfig.fakePlayerAutoReplenishmentFormShulkerBox));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerAutoFish", FakePlayerCompatConfig.fakePlayerAutoFish));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerReloadAction", FakePlayerCompatConfig.fakePlayerReloadAction));
|
||||||
|
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "hopperCounters", CounterCompatConfig.hopperCounters));
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "hopperCountersUnlimitedSpeed", CounterCompatConfig.hopperCountersUnlimitedSpeed));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package fun.bm.lophine.carpet;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public final class InteractionUpdateCompatHelper {
|
||||||
|
private static final ThreadLocal<Integer> SUPPRESSED_DEPTH = ThreadLocal.withInitial(() -> 0);
|
||||||
|
|
||||||
|
public static boolean shouldSkipUpdates() {
|
||||||
|
return SUPPRESSED_DEPTH.get() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runWithSuppressedUpdates(Runnable action) {
|
||||||
|
push();
|
||||||
|
try {
|
||||||
|
action.run();
|
||||||
|
} finally {
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T supplyWithSuppressedUpdates(Supplier<T> action) {
|
||||||
|
push();
|
||||||
|
try {
|
||||||
|
return action.get();
|
||||||
|
} finally {
|
||||||
|
pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void push() {
|
||||||
|
SUPPRESSED_DEPTH.set(SUPPRESSED_DEPTH.get() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void pop() {
|
||||||
|
int depth = SUPPRESSED_DEPTH.get();
|
||||||
|
if (depth <= 1) {
|
||||||
|
SUPPRESSED_DEPTH.remove();
|
||||||
|
} else {
|
||||||
|
SUPPRESSED_DEPTH.set(depth - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package fun.bm.lophine.carpet;
|
||||||
|
|
||||||
|
import ca.spottedleaf.moonrise.common.util.TickThread;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.EntitySpawnReason;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
|
import net.minecraft.world.entity.MobCategory;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.FenceGateBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
public final class LagFreeSpawningCompatHelper {
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
private static final Map<RegionizedWorldData, Map<EntityType<?>, Mob>> PRECOOKED_MOBS = new WeakHashMap<>();
|
||||||
|
|
||||||
|
public static boolean hasNoCollision(ServerLevel world, AABB bb) {
|
||||||
|
if (!TickThread.isTickThreadFor(world, bb)) return world.noCollision(bb);
|
||||||
|
int minX = Mth.floor(bb.minX);
|
||||||
|
int minY = Mth.floor(bb.minY);
|
||||||
|
int minZ = Mth.floor(bb.minZ);
|
||||||
|
int maxY = Mth.ceil(bb.maxY) - 1;
|
||||||
|
BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
|
||||||
|
|
||||||
|
if (bb.getXsize() <= 1.0 && bb.getZsize() <= 1.0) {
|
||||||
|
for (int y = minY; y <= maxY; y++) {
|
||||||
|
blockPos.set(minX, y, minZ);
|
||||||
|
VoxelShape shape = world.getBlockState(blockPos).getCollisionShape(world, blockPos);
|
||||||
|
if (shape != Shapes.empty()) {
|
||||||
|
return shape != Shapes.block() && world.noCollision(bb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxX = Mth.ceil(bb.maxX) - 1;
|
||||||
|
int maxZ = Mth.ceil(bb.maxZ) - 1;
|
||||||
|
|
||||||
|
for (int y = minY; y <= maxY; y++) {
|
||||||
|
for (int x = minX; x <= maxX; x++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
blockPos.set(x, y, z);
|
||||||
|
VoxelShape shape = world.getBlockState(blockPos).getCollisionShape(world, blockPos);
|
||||||
|
if (shape != Shapes.empty()) {
|
||||||
|
return shape != Shapes.block() && world.noCollision(bb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int minBelow = minY - 1;
|
||||||
|
for (int x = minX; x <= maxX; x++) {
|
||||||
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
|
blockPos.set(x, minBelow, z);
|
||||||
|
BlockState state = world.getBlockState(blockPos);
|
||||||
|
Block block = state.getBlock();
|
||||||
|
if (state.is(BlockTags.FENCES)
|
||||||
|
|| state.is(BlockTags.WALLS)
|
||||||
|
|| block instanceof FenceGateBlock && !state.getValue(FenceGateBlock.OPEN)) {
|
||||||
|
if (x == minX || x == maxX || z == minZ || z == maxZ) {
|
||||||
|
return world.noCollision(bb);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double limitDistanceSq(MobCategory category, double distanceSq) {
|
||||||
|
return distanceSq > 16384.0 && category != MobCategory.CREATURE ? 0.0 : distanceSq;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable Mob getOrCreateMob(ServerLevel level, EntityType<?> entityType) {
|
||||||
|
RegionizedWorldData data = level.getCurrentWorldData();
|
||||||
|
if (data == null) return createMob(level, entityType);
|
||||||
|
Map<EntityType<?>, Mob> cache = PRECOOKED_MOBS.computeIfAbsent(level.getCurrentWorldData(), key -> new HashMap<>());
|
||||||
|
Mob mob = cache.get(entityType);
|
||||||
|
if (mob != null && !mob.isRemoved()) {
|
||||||
|
if (!TickThread.isTickThreadFor(mob)) return createMob(level, entityType);
|
||||||
|
return mob;
|
||||||
|
}
|
||||||
|
|
||||||
|
return createMob(level, entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable Mob createMob(ServerLevel level, EntityType<?> entityType) {
|
||||||
|
try {
|
||||||
|
if (entityType.create(level, EntitySpawnReason.NATURAL) instanceof Mob created) {
|
||||||
|
PRECOOKED_MOBS.get(level.getCurrentWorldData()).put(entityType, created);
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
LOGGER.warn("Can't precook non-mob entity type: {}", entityType);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
LOGGER.warn("Failed to precook mob {}", entityType, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void markSpawned(ServerLevel level, EntityType<?> entityType) {
|
||||||
|
Map<EntityType<?>, Mob> cache = PRECOOKED_MOBS.get(level.getCurrentWorldData());
|
||||||
|
if (cache != null) {
|
||||||
|
cache.remove(entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package fun.bm.lophine.carpet.config.modules;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.CarpetCompatSync;
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
|
||||||
|
@ConfigClassInfo(
|
||||||
|
category = EnumConfigCategory.ROOT,
|
||||||
|
name = "core",
|
||||||
|
directory = {"carpet"}
|
||||||
|
)
|
||||||
|
public class CoreConfig implements IConfigModule {
|
||||||
|
@ConfigInfo(name = "enabled", comments = """
|
||||||
|
Enable carpet features.
|
||||||
|
If you want to use some function from Carpet modifier,
|
||||||
|
you need to enable it.
|
||||||
|
(some function is not managed by this option)
|
||||||
|
|
||||||
|
ONLY GENERAL DIRECTORY WAS CONTROLLED BY THIS OPTION.
|
||||||
|
WARNING: IF YOU ENABLED IT, ORIGINAL CONFIG IN LOPHINE CONFIG WILL BE OVERWRITTEN.""")
|
||||||
|
public static boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeFinalLoad() {
|
||||||
|
CarpetCompatSync.apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package fun.bm.lophine.carpet.config.modules;
|
||||||
|
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
|
||||||
|
@ConfigClassInfo(
|
||||||
|
category = EnumConfigCategory.ROOT,
|
||||||
|
name = "hopper_counter",
|
||||||
|
directory = {"carpet"},
|
||||||
|
comments = """
|
||||||
|
Hopper counter compatibility mapped onto Lophine's wool hopper counter implementation."""
|
||||||
|
)
|
||||||
|
public class CounterCompatConfig implements IConfigModule {
|
||||||
|
@ConfigInfo(name = "hopperCounters", comments = """
|
||||||
|
Enable the existing wool hopper counter implementation.""")
|
||||||
|
public static boolean hopperCounters = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "hopperCountersUnlimitedSpeed", comments = """
|
||||||
|
Remove the hopper transfer speed limit for counters.
|
||||||
|
Only effective when hopperCounters is enabled.""")
|
||||||
|
public static boolean hopperCountersUnlimitedSpeed = false;
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package fun.bm.lophine.carpet.config.modules;
|
||||||
|
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
|
||||||
|
@ConfigClassInfo(
|
||||||
|
category = EnumConfigCategory.ROOT,
|
||||||
|
name = "fakeplayer",
|
||||||
|
directory = {"carpet"},
|
||||||
|
comments = """
|
||||||
|
Carpet fakeplayer compatibility mapped onto Lophine fakeplayers.
|
||||||
|
commandPlayer is currently backed by Lophine's /bot command surface."""
|
||||||
|
)
|
||||||
|
public class FakePlayerCompatConfig implements IConfigModule {
|
||||||
|
@ConfigInfo(name = "commandBot", comments = """
|
||||||
|
Enable Lophine's /bot command.""")
|
||||||
|
public static boolean commandBot = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "commandPlayer", comments = """
|
||||||
|
Map Carpet's commandPlayer rule to the same fakeplayer command surface used by /bot.""")
|
||||||
|
public static boolean commandPlayer = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerResident", comments = """
|
||||||
|
Keep fakeplayers resident across unload and restart.""")
|
||||||
|
public static boolean fakePlayerResident = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "openFakePlayerInventory", comments = """
|
||||||
|
Allow opening fakeplayer inventories.""")
|
||||||
|
public static boolean openFakePlayerInventory = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerTicksLikeRealPlayer", comments = """
|
||||||
|
Tick fakeplayers in the network phase to better match real player timing.""")
|
||||||
|
public static boolean fakePlayerTicksLikeRealPlayer = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerDefaultSurvivalMode", comments = """
|
||||||
|
Force newly created fakeplayers to start in survival instead of the server default gamemode.""")
|
||||||
|
public static boolean fakePlayerDefaultSurvivalMode = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerInteractLikeClient", comments = """
|
||||||
|
Make fakeplayer entity interaction follow client-side fallback behavior more closely.""")
|
||||||
|
public static boolean fakePlayerInteractLikeClient = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerAutoReplaceTool", comments = """
|
||||||
|
Toggle automatic tool replacement for fakeplayers.""")
|
||||||
|
public static boolean fakePlayerAutoReplaceTool = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerAutoReplenishment", comments = """
|
||||||
|
Toggle automatic stack replenishment for fakeplayers.""")
|
||||||
|
public static boolean fakePlayerAutoReplenishment = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerAutoReplenishmentFormShulkerBox", comments = """
|
||||||
|
Let fakeplayer replenishment pull matching items out of shulker boxes in the inventory.""")
|
||||||
|
public static boolean fakePlayerAutoReplenishmentFormShulkerBox = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerAutoFish", comments = """
|
||||||
|
Let fakeplayers holding a fishing rod automatically cast and reel it in.""")
|
||||||
|
public static boolean fakePlayerAutoFish = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fakePlayerReloadAction", comments = """
|
||||||
|
Persist queued fakeplayer actions across save and reload.""")
|
||||||
|
public static boolean fakePlayerReloadAction = false;
|
||||||
|
}
|
||||||
+239
@@ -0,0 +1,239 @@
|
|||||||
|
package fun.bm.lophine.carpet.config.modules;
|
||||||
|
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ConfigClassInfo(
|
||||||
|
category = EnumConfigCategory.ROOT,
|
||||||
|
name = "general",
|
||||||
|
directory = {"carpet"},
|
||||||
|
comments = """
|
||||||
|
Carpet/AMS/TIS/Org compatibility rules backed by existing Lophine features.
|
||||||
|
Only rules that already have a working server-side implementation are exposed here."""
|
||||||
|
)
|
||||||
|
public class GeneralCompatConfig implements IConfigModule {
|
||||||
|
@ConfigInfo(name = "language", comments = """
|
||||||
|
Carpet language value forwarded to lophine.function.language.lang.""")
|
||||||
|
public static String language = "en_us";
|
||||||
|
|
||||||
|
@ConfigInfo(name = "amsUpdateSuppressionCrashFix", comments = """
|
||||||
|
Map AMS update suppression crash protection to Lophine's existing crash fix.""")
|
||||||
|
public static boolean amsUpdateSuppressionCrashFix = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "yeetUpdateSuppressionCrash", comments = """
|
||||||
|
Map TIS update suppression crash yeeting to the same Lophine crash fix.""")
|
||||||
|
public static boolean yeetUpdateSuppressionCrash = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "dustTrapdoorReintroduced", comments = """
|
||||||
|
Map dust-on-open-trapdoor behavior to Lophine's redstone-ignore-upwards-update option.""")
|
||||||
|
public static boolean dustTrapdoorReintroduced = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "shulkerBoxCCEReintroduced", comments = """
|
||||||
|
Map shulker-box CCE update suppression to Lophine's cce-update-suppression option.""")
|
||||||
|
public static boolean shulkerBoxCCEReintroduced = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "instantBlockUpdaterReintroduced", comments = """
|
||||||
|
Enable the existing instant block updater patch already carried by Lophine.""")
|
||||||
|
public static boolean instantBlockUpdaterReintroduced = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "commandTick", comments = """
|
||||||
|
Enable the tick command support already patched into Lophine.""")
|
||||||
|
public static boolean commandTick = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "creativeNoClip", comments = """
|
||||||
|
Enable the existing creative fly no clip implementation.""")
|
||||||
|
public static boolean creativeNoClip = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "optimizedDragonRespawn", comments = """
|
||||||
|
Enable the existing optimized dragon respawn implementation from Luminol.""")
|
||||||
|
public static boolean optimizedDragonRespawn = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "antiSpamDisabled", comments = """
|
||||||
|
Disable the server-side chat and creative-drop spam throttles used by vanilla/Spigot.""")
|
||||||
|
public static boolean antiSpamDisabled = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "blockPlacementIgnoreEntity", comments = """
|
||||||
|
Allow creative players to place blocks without entity collision checks.""")
|
||||||
|
public static boolean blockPlacementIgnoreEntity = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "creativeOpenContainerForcibly", comments = """
|
||||||
|
Allow creative players to forcibly open blocked chests, ender chests and shulker boxes.""")
|
||||||
|
public static boolean creativeOpenContainerForcibly = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "creativeOneHitKill", comments = """
|
||||||
|
Allow creative players to instantly kill attackable non-creative, non-spectator entities.
|
||||||
|
Sneaking expands the effect into a small area attack.""")
|
||||||
|
public static boolean creativeOneHitKill = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "observerNoDetection", comments = """
|
||||||
|
Disable observer detection pulses entirely.""")
|
||||||
|
public static boolean observerNoDetection = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "bambooModelNoOffset", comments = """
|
||||||
|
Remove the random horizontal model offset from bamboo and bamboo saplings.""")
|
||||||
|
public static boolean bambooModelNoOffset = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "creativeNoItemCooldown", comments = """
|
||||||
|
Skip item cooldown application for creative players.""")
|
||||||
|
public static boolean creativeNoItemCooldown = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "ctrlQCraftingFix", comments = """
|
||||||
|
Compatibility flag for the upstream result-slot Ctrl+Q crafting fix already present in the current menu code.""")
|
||||||
|
public static boolean ctrlQCraftingFix = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "carpetAlwaysSetDefault", comments = """
|
||||||
|
Compatibility flag for Lophine's config loader, which already writes default values into the compat config during preload.""")
|
||||||
|
public static boolean carpetAlwaysSetDefault = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "placementRotationFix", comments = """
|
||||||
|
Use the player's main body rotation for placement direction checks instead of interpolated head yaw.""")
|
||||||
|
public static boolean placementRotationFix = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tntDoNotUpdate", comments = """
|
||||||
|
Prevent TNT from checking redstone power when first placed.""")
|
||||||
|
public static boolean tntDoNotUpdate = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "totallyNoBlockUpdate", comments = """
|
||||||
|
Suppress neighbor and shape updates globally for block changes.""")
|
||||||
|
public static boolean totallyNoBlockUpdate = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tiscmNetworkProtocol", comments = """
|
||||||
|
Enable the native Carpet TIS Addition network channel on `tiscm:network/v1`.""")
|
||||||
|
public static boolean tiscmNetworkProtocol = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "hopperNoItemCost", comments = """
|
||||||
|
Restore the transferred stack into a hopper when a wool block is placed on top of it.""")
|
||||||
|
public static boolean hopperNoItemCost = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "explosionNoBlockDamage", comments = """
|
||||||
|
Let explosions damage entities without breaking blocks.""")
|
||||||
|
public static boolean explosionNoBlockDamage = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "optimizedTNTHighPriority", comments = """
|
||||||
|
Compatibility flag for the already optimized server explosion path carried by the current runtime.""")
|
||||||
|
public static boolean optimizedTNTHighPriority = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tntPrimerMomentumRemoved", comments = """
|
||||||
|
Remove the random horizontal launch momentum from newly primed TNT.""")
|
||||||
|
public static boolean tntPrimerMomentumRemoved = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tntIgnoreRedstoneSignal", comments = """
|
||||||
|
Ignore redstone power when deciding whether TNT should auto-prime.""")
|
||||||
|
public static boolean tntIgnoreRedstoneSignal = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tntDupingFix", comments = """
|
||||||
|
Toggle the piston desync path used by vanilla TNT duplication setups.""")
|
||||||
|
public static boolean tntDupingFix = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "interactionUpdates", comments = """
|
||||||
|
Control whether player interaction block changes emit normal block updates.
|
||||||
|
Set to false to suppress neighbor and shape updates during block use and breaking.""")
|
||||||
|
public static boolean interactionUpdates = true;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "xpNoCooldown", comments = """
|
||||||
|
Allow players to absorb multiple experience orbs in the same tick without pickup delay.""")
|
||||||
|
public static boolean xpNoCooldown = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "powerfulExpMending", comments = """
|
||||||
|
Let picked-up experience repair all damaged mending items in the player's inventory, not only equipped gear.""")
|
||||||
|
public static boolean powerfulExpMending = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "clientSettingsLostOnRespawnFix", comments = """
|
||||||
|
Reapply the player's last known client settings after respawn.""")
|
||||||
|
public static boolean clientSettingsLostOnRespawnFix = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "sensibleEnderman", comments = """
|
||||||
|
Restrict enderman block pickup to pumpkins and melons only.""")
|
||||||
|
public static boolean sensibleEnderman = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "entityInstantDeathRemoval", comments = """
|
||||||
|
Remove the normal 20gt delay before dead living entities are discarded.""")
|
||||||
|
public static boolean entityInstantDeathRemoval = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "farmlandTrampledDisabled", comments = """
|
||||||
|
Prevent farmland from turning into dirt when entities land on it.""")
|
||||||
|
public static boolean farmlandTrampledDisabled = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "shulkerGolem", comments = """
|
||||||
|
Allow a carved pumpkin on top of a shulker box to summon a shulker.""")
|
||||||
|
public static boolean shulkerGolem = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "preventEndSpikeRespawn", comments = """
|
||||||
|
Skip obsidian spike regeneration during dragon respawn.""")
|
||||||
|
public static boolean preventEndSpikeRespawn = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "yeetOutOfOrderChatKick", comments = """
|
||||||
|
Ignore out-of-order secure chat chain checks instead of invalidating the chat session.""")
|
||||||
|
public static boolean yeetOutOfOrderChatKick = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "betterCraftableBoneBlock", comments = """
|
||||||
|
Add the AMS alternate bone block recipe that yields 3 bone blocks from 9 bones.""")
|
||||||
|
public static boolean betterCraftableBoneBlock = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "betterCraftableDispenser", comments = """
|
||||||
|
Add the AMS alternate dispenser recipes using a dropper.""")
|
||||||
|
public static boolean betterCraftableDispenser = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "viewDistance", comments = """
|
||||||
|
Override the dedicated server's startup view distance with the Carpet-compatible value.""")
|
||||||
|
public static int viewDistance = 12;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tickCommandPermission", comments = """
|
||||||
|
Override the `/tick` command permission level.
|
||||||
|
Accepts values in the range 0..4, where 2 matches old Carpet behavior and 3 keeps vanilla.""")
|
||||||
|
public static int tickCommandPermission = 3;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tickFreezeCommandToggleable", comments = """
|
||||||
|
Make `/tick freeze` toggle back to running when executed while the server is already frozen.""")
|
||||||
|
public static boolean tickFreezeCommandToggleable = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "syncServerMsptMetricsData", comments = """
|
||||||
|
Broadcast live MSPT samples through the native TISCM protocol channel.""")
|
||||||
|
public static boolean syncServerMsptMetricsData = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "simpleInGameCalculator", comments = """
|
||||||
|
Evaluate chat messages prefixed with `=` as a simple calculator expression and reply privately.""")
|
||||||
|
public static boolean simpleInGameCalculator = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "microTiming", comments = """
|
||||||
|
Compatibility flag for the built-in region profiler and timing instrumentation carried by Folia/Moonrise.""")
|
||||||
|
public static boolean microTiming = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "fastRedstoneDust", comments = """
|
||||||
|
Route redstone dust updates through the Alternate Current fast-update backend.""")
|
||||||
|
public static boolean fastRedstoneDust = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "lagFreeSpawning", comments = """
|
||||||
|
Use the lightweight collision and precooked-mob spawning path for natural spawning checks.""")
|
||||||
|
public static boolean lagFreeSpawning = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "optimizedFastEntityMovement", comments = """
|
||||||
|
Compatibility flag for the always-on Moonrise/Paper fast entity movement collision pipeline.""")
|
||||||
|
public static boolean optimizedFastEntityMovement = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "optimizedHardHitBoxEntityCollision", comments = """
|
||||||
|
Compatibility flag for the always-on Moonrise/Paper hard-hitbox entity collision optimizations.""")
|
||||||
|
public static boolean optimizedHardHitBoxEntityCollision = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "tntFuseDuration", comments = """
|
||||||
|
Override the default primed TNT fuse duration in ticks.
|
||||||
|
Accepts values in the range 0..32767.""")
|
||||||
|
public static int tntFuseDuration = 80;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "defaultLoggers", comments = """
|
||||||
|
Carpet-style default logger subscriptions for players.
|
||||||
|
Examples: ["tps", "mob_caps", "counter white"]""")
|
||||||
|
public static List<String> defaultLoggers = List.of();
|
||||||
|
|
||||||
|
public static int normalizedTntFuseDuration() {
|
||||||
|
return Math.clamp(tntFuseDuration, 0, Short.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int normalizedTickCommandPermission() {
|
||||||
|
return Math.clamp(tickCommandPermission, 0, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-1
@@ -22,11 +22,21 @@ public class CommandConfig implements IConfigModule {
|
|||||||
@TransformedConfig(name = "enable-waypoint", directory = {"experiment", "waypoint_bar"})
|
@TransformedConfig(name = "enable-waypoint", directory = {"experiment", "waypoint_bar"})
|
||||||
@ConfigInfo(name = "waypoint_command_enabled", comments =
|
@ConfigInfo(name = "waypoint_command_enabled", comments =
|
||||||
"""
|
"""
|
||||||
Allow to use waypoint command""")
|
Allow to use waypoint command and locator bar""")
|
||||||
public static boolean waypoint = false;
|
public static boolean waypoint = false;
|
||||||
|
|
||||||
@ConfigInfo(name = "scoreboard_command_enabled", comments =
|
@ConfigInfo(name = "scoreboard_command_enabled", comments =
|
||||||
"""
|
"""
|
||||||
Allow to use scoreboard command""")
|
Allow to use scoreboard command""")
|
||||||
public static boolean scoreboard = false;
|
public static boolean scoreboard = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "enabled", directory = {"save_all_command"}, comments =
|
||||||
|
"""
|
||||||
|
Allow to use save-all command""")
|
||||||
|
public static boolean saveAll = false;
|
||||||
|
|
||||||
|
@ConfigInfo(name = "log_all_process", directory = {"save_all_command"}, comments =
|
||||||
|
"""
|
||||||
|
Log all process of save-all command to console""")
|
||||||
|
public static boolean logAllProcess = false;
|
||||||
}
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package fun.bm.lophine.config.modules.function;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.protocol.CarpetServerProtocol;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ConfigClassInfo(name = "creative_fly_no_clip", category = EnumConfigCategory.FUNCTION)
|
||||||
|
public class CreativeFlyNoClipConfig implements IConfigModule {
|
||||||
|
@ConfigInfo(name = "enabled", comments = """
|
||||||
|
Whether to enable creative fly no clip.
|
||||||
|
When enabled, players in creative mode will not collide with blocks while flying.
|
||||||
|
This allows them to pass through blocks without obstruction.""")
|
||||||
|
public static boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||||
|
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "creativeNoClip", enabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
-1
@@ -81,7 +81,6 @@ public class FakeplayerConfig implements IConfigModule {
|
|||||||
@ConfigInfo(name = "enable-locator-bar", comments = """
|
@ConfigInfo(name = "enable-locator-bar", comments = """
|
||||||
Enable locator bar for fakeplayers""")
|
Enable locator bar for fakeplayers""")
|
||||||
public static boolean enableLocatorBar = false;
|
public static boolean enableLocatorBar = false;
|
||||||
|
|
||||||
public static ServerBot.TickType tickType = ServerBot.TickType.ENTITY_LIST;
|
public static ServerBot.TickType tickType = ServerBot.TickType.ENTITY_LIST;
|
||||||
|
|
||||||
private BotCommand command = null;
|
private BotCommand command = null;
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package fun.bm.lophine.config.modules.function;
|
||||||
|
|
||||||
|
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||||
|
import fun.bm.lophine.utils.RandomProfilePool;
|
||||||
|
import me.earthme.luminol.config.IConfigModule;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||||
|
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||||
|
import me.earthme.luminol.config.flags.HotReloadUnsupported;
|
||||||
|
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ConfigClassInfo(category = EnumConfigCategory.FUNCTION, name = "replay-api")
|
||||||
|
public class ReplayAPIConfig implements IConfigModule {
|
||||||
|
@HotReloadUnsupported
|
||||||
|
@ConfigInfo(name = "enable-cache")
|
||||||
|
public static boolean enableCache = true;
|
||||||
|
|
||||||
|
@HotReloadUnsupported
|
||||||
|
@ConfigInfo(name = "cache-photographer-time", comments = """
|
||||||
|
Time to cache photographer profile(in seconds)""")
|
||||||
|
public static int cachePhotographerTime = 3600;
|
||||||
|
|
||||||
|
@HotReloadUnsupported
|
||||||
|
@ConfigInfo(name = "cache-photographer-size", comments = """
|
||||||
|
Maximum size of cache photographer profile""")
|
||||||
|
public static int cachePhotographerSize = 100;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||||
|
RandomProfilePool.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,302 @@
|
|||||||
|
package fun.bm.lophine.protocol;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||||
|
import io.papermc.paper.adventure.PaperAdventure;
|
||||||
|
import io.papermc.paper.threadedregions.RegionizedWorldData;
|
||||||
|
import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundTabListPacket;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.ServerTickRateManager;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.MobCategory;
|
||||||
|
import net.minecraft.world.item.DyeColor;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.NaturalSpawner;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||||
|
import org.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||||
|
import org.leavesmc.leaves.util.HopperCounter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@LeavesProtocol.Register(namespace = "carpet")
|
||||||
|
public class CarpetLoggerProtocol implements LeavesProtocol {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger("CarpetLoggerProtocol");
|
||||||
|
private static final Map<String, Map<String, String>> PLAYER_SUBSCRIPTIONS = new ConcurrentHashMap<>();
|
||||||
|
private static volatile Map<String, String> configuredSubscriptions = null;
|
||||||
|
|
||||||
|
public static void refreshConfiguredDefaults(boolean initial) {
|
||||||
|
Map<String, String> defaults = parseConfiguredDefaults(GeneralCompatConfig.defaultLoggers);
|
||||||
|
configuredSubscriptions = defaults;
|
||||||
|
if (defaults == null || defaults.isEmpty()) {
|
||||||
|
PLAYER_SUBSCRIPTIONS.clear();
|
||||||
|
if (initial) return;
|
||||||
|
for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) {
|
||||||
|
clearHud(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PLAYER_SUBSCRIPTIONS.replaceAll((playerName, ignored) -> defaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String serializeConfiguredDefaults(List<String> configuredLoggers) {
|
||||||
|
List<String> serialized = new ArrayList<>();
|
||||||
|
if (configuredLoggers != null) {
|
||||||
|
for (String entry : configuredLoggers) {
|
||||||
|
if (entry == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String trimmed = entry.trim();
|
||||||
|
if (!trimmed.isEmpty()) {
|
||||||
|
serialized.add(trimmed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return serialized.isEmpty() ? "none" : String.join(",", serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PlayerJoin
|
||||||
|
public static void onPlayerJoin(ServerPlayer player) {
|
||||||
|
if (configuredSubscriptions != null && !configuredSubscriptions.isEmpty()) {
|
||||||
|
PLAYER_SUBSCRIPTIONS.putIfAbsent(player.getScoreboardName(), configuredSubscriptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PlayerLeave
|
||||||
|
public static void onPlayerLeave(ServerPlayer player) {
|
||||||
|
clearHud(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.Ticker(tickerId = "hud")
|
||||||
|
public static void onHudTick() {
|
||||||
|
if (PLAYER_SUBSCRIPTIONS.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
|
||||||
|
Map<String, String> subscriptions = PLAYER_SUBSCRIPTIONS.get(player.getScoreboardName());
|
||||||
|
if (subscriptions == null || subscriptions.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
player.getBukkitEntity().taskScheduler.schedule((LivingEntity livingEntity) -> {
|
||||||
|
if (livingEntity instanceof ServerPlayer scheduledPlayer) {
|
||||||
|
sendHud(server, scheduledPlayer, subscriptions);
|
||||||
|
}
|
||||||
|
}, null, 1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int tickerInterval(String tickerID) {
|
||||||
|
return "hud".equals(tickerID) ? 20 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendHud(MinecraftServer server, ServerPlayer player, Map<String, String> subscriptions) {
|
||||||
|
List<net.minecraft.network.chat.Component> lines = new ArrayList<>();
|
||||||
|
subscriptions.forEach((loggerName, option) -> {
|
||||||
|
switch (loggerName) {
|
||||||
|
case "tps" -> lines.add(buildTpsLine(server));
|
||||||
|
case "mobcaps" -> {
|
||||||
|
net.minecraft.network.chat.Component line = buildMobcapsLine(player, option);
|
||||||
|
if (line != null) {
|
||||||
|
lines.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "counter" -> lines.addAll(buildCounterLines(server, player.level(), option));
|
||||||
|
default -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MutableComponent footer = net.minecraft.network.chat.Component.empty();
|
||||||
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
footer.append(net.minecraft.network.chat.Component.literal("\n"));
|
||||||
|
}
|
||||||
|
footer.append(lines.get(i));
|
||||||
|
}
|
||||||
|
player.connection.send(new ClientboundTabListPacket(net.minecraft.network.chat.Component.empty(), footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void clearHud(ServerPlayer player) {
|
||||||
|
player.connection.send(new ClientboundTabListPacket(net.minecraft.network.chat.Component.empty(), net.minecraft.network.chat.Component.empty()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static net.minecraft.network.chat.Component buildTpsLine(MinecraftServer server) {
|
||||||
|
ServerTickRateManager tickManager = server.tickRateManager();
|
||||||
|
io.papermc.paper.threadedregions.TickData.TickReportData tickData = TickRegionScheduler.getCurrentRegion().getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime());
|
||||||
|
final double tps = tickData.tpsData().segmentAll().average();
|
||||||
|
final double mspt = tickData.timePerTickData().segmentAll().average() / 1.0E6;
|
||||||
|
|
||||||
|
ChatFormatting color = heatmapColor(mspt, tickManager.millisecondsPerTick());
|
||||||
|
return net.minecraft.network.chat.Component.empty()
|
||||||
|
.append(net.minecraft.network.chat.Component.literal("TPS: ").withStyle(ChatFormatting.GRAY))
|
||||||
|
.append(net.minecraft.network.chat.Component.literal(String.format(Locale.US, "%.1f", tps)).withStyle(color))
|
||||||
|
.append(net.minecraft.network.chat.Component.literal(" MSPT: ").withStyle(ChatFormatting.GRAY))
|
||||||
|
.append(net.minecraft.network.chat.Component.literal(String.format(Locale.US, "%.1f", mspt)).withStyle(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static net.minecraft.network.chat.Component buildMobcapsLine(ServerPlayer player, String option) {
|
||||||
|
final ServerLevel level = resolveMobcapsLevel(player, option);
|
||||||
|
if (level == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final RegionizedWorldData data = level.getCurrentWorldData();
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final NaturalSpawner.SpawnState spawnState = data.lastSpawnState;
|
||||||
|
if (spawnState == null) {
|
||||||
|
return net.minecraft.network.chat.Component.literal("Mobcaps: unavailable").withStyle(ChatFormatting.DARK_GRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
int chunks = spawnState.getSpawnableChunkCount();
|
||||||
|
var counts = spawnState.getMobCategoryCounts();
|
||||||
|
MutableComponent line = net.minecraft.network.chat.Component.literal("Mobcaps").withStyle(ChatFormatting.GRAY);
|
||||||
|
for (MobCategory category : MobCategory.values()) {
|
||||||
|
if (category == MobCategory.MISC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int current = counts.getOrDefault(category, 0);
|
||||||
|
int limit = NaturalSpawner.globalLimitForCategory(level, category, chunks);
|
||||||
|
line.append(net.minecraft.network.chat.Component.literal(" " + shortName(category) + " ").withStyle(ChatFormatting.DARK_GRAY));
|
||||||
|
line.append(net.minecraft.network.chat.Component.literal(current + "/" + limit).withStyle(categoryColor(current, limit)));
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<net.minecraft.network.chat.Component> buildCounterLines(MinecraftServer server, Level level, String option) {
|
||||||
|
List<net.minecraft.network.chat.Component> lines = new ArrayList<>();
|
||||||
|
String colors = option == null || option.isBlank() ? "white" : option;
|
||||||
|
for (String rawColor : colors.split(",")) {
|
||||||
|
String colorName = rawColor.trim();
|
||||||
|
if (colorName.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DyeColor color = DyeColor.byName(colorName, null);
|
||||||
|
if (color == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
HopperCounter counter = HopperCounter.getCounter(color);
|
||||||
|
if (counter == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Component component : counter.format(server, level, false)) {
|
||||||
|
lines.add(PaperAdventure.asVanilla(component));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ServerLevel resolveMobcapsLevel(ServerPlayer player, String option) {
|
||||||
|
if (option == null || option.isBlank() || option.equalsIgnoreCase("dynamic")) {
|
||||||
|
return player.level();
|
||||||
|
}
|
||||||
|
return switch (option.toLowerCase(Locale.ROOT)) {
|
||||||
|
case "overworld" -> player.level().dimension() == Level.OVERWORLD ? player.level() : null;
|
||||||
|
case "nether" -> player.level().dimension() == Level.NETHER ? player.level() : null;
|
||||||
|
case "end" -> player.level().dimension() == Level.END ? player.level() : null;
|
||||||
|
default -> player.level();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ChatFormatting heatmapColor(double actual, double reference) {
|
||||||
|
if (actual > reference) {
|
||||||
|
return ChatFormatting.LIGHT_PURPLE;
|
||||||
|
}
|
||||||
|
if (actual > 0.8D * reference) {
|
||||||
|
return ChatFormatting.RED;
|
||||||
|
}
|
||||||
|
if (actual > 0.5D * reference) {
|
||||||
|
return ChatFormatting.YELLOW;
|
||||||
|
}
|
||||||
|
if (actual >= 0.0D) {
|
||||||
|
return ChatFormatting.DARK_GREEN;
|
||||||
|
}
|
||||||
|
return ChatFormatting.GRAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ChatFormatting categoryColor(int current, int limit) {
|
||||||
|
if (limit <= 0) {
|
||||||
|
return ChatFormatting.DARK_GRAY;
|
||||||
|
}
|
||||||
|
double ratio = current / (double) limit;
|
||||||
|
if (ratio >= 1.0D) {
|
||||||
|
return ChatFormatting.RED;
|
||||||
|
}
|
||||||
|
if (ratio >= 0.8D) {
|
||||||
|
return ChatFormatting.YELLOW;
|
||||||
|
}
|
||||||
|
return ChatFormatting.GREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String shortName(MobCategory category) {
|
||||||
|
return switch (category) {
|
||||||
|
case MONSTER -> "M";
|
||||||
|
case CREATURE -> "C";
|
||||||
|
case AMBIENT -> "A";
|
||||||
|
case AXOLOTLS -> "Ax";
|
||||||
|
case UNDERGROUND_WATER_CREATURE -> "UWC";
|
||||||
|
case WATER_CREATURE -> "WC";
|
||||||
|
case WATER_AMBIENT -> "WA";
|
||||||
|
case MISC -> "X";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, String> parseConfiguredDefaults(List<String> configuredLoggers) {
|
||||||
|
LinkedHashMap<String, String> subscriptions = new LinkedHashMap<>();
|
||||||
|
if (configuredLoggers == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (String entry : configuredLoggers) {
|
||||||
|
if (entry == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String chunk : entry.split(",")) {
|
||||||
|
String token = chunk.trim();
|
||||||
|
if (token.isEmpty() || token.equalsIgnoreCase("none")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] parts = token.split("\\s+", 2);
|
||||||
|
String loggerName = parts[0].toLowerCase(Locale.ROOT);
|
||||||
|
if (!isSupported(loggerName)) {
|
||||||
|
LOGGER.debug("Ignoring unsupported Carpet default logger '{}'", loggerName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String option = parts.length == 1 ? defaultOption(loggerName) : parts[1].trim();
|
||||||
|
if (option.isEmpty()) {
|
||||||
|
option = defaultOption(loggerName);
|
||||||
|
}
|
||||||
|
subscriptions.put(loggerName, option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return subscriptions.isEmpty() ? null : Map.copyOf(subscriptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isSupported(String loggerName) {
|
||||||
|
return Arrays.asList("tps", "mobcaps", "counter").contains(loggerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull String defaultOption(String loggerName) {
|
||||||
|
return switch (loggerName) {
|
||||||
|
case "mobcaps" -> "dynamic";
|
||||||
|
case "counter" -> "white";
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
package fun.bm.lophine.protocol.tiscm;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||||
|
import io.papermc.paper.ServerBuildInfo;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.nbt.StringTag;
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||||
|
import org.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||||
|
import org.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||||
|
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@LeavesProtocol.Register(namespace = TISCMProtocol.PROTOCOL_ID)
|
||||||
|
public class TISCMProtocol implements LeavesProtocol {
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public static final String PROTOCOL_ID = "tiscm";
|
||||||
|
private static final String PLATFORM_NAME = "Lophine";
|
||||||
|
private static final String PLATFORM_VERSION = ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE);
|
||||||
|
private static final Map<String, EnumSet<S2CPacket>> CLIENT_SUPPORTED_PACKETS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@Contract("_ -> new")
|
||||||
|
public static ResourceLocation id(String path) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void broadcastMsptSample(long tickCounter, long nanosecond) {
|
||||||
|
if (!GeneralCompatConfig.tiscmNetworkProtocol || !GeneralCompatConfig.syncServerMsptMetricsData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag nbt = new CompoundTag();
|
||||||
|
nbt.putInt("version", 2);
|
||||||
|
nbt.putLong("millisecond", nanosecond / 1_000_000L);
|
||||||
|
nbt.putLong("nanosecond", nanosecond);
|
||||||
|
nbt.putString("type", "tick_server_method");
|
||||||
|
|
||||||
|
TISCMPayload payload = new TISCMPayload(S2CPacket.MSPT_METRICS_SAMPLE.id, nbt);
|
||||||
|
for (ServerPlayer player : MinecraftServer.getServer().getPlayerList().getPlayers()) {
|
||||||
|
if (supports(player, S2CPacket.MSPT_METRICS_SAMPLE)) {
|
||||||
|
ProtocolUtils.sendPayloadPacket(player, payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PayloadReceiver(payload = TISCMPayload.class)
|
||||||
|
public static void handlePayload(ServerPlayer player, TISCMPayload payload) {
|
||||||
|
if (!GeneralCompatConfig.tiscmNetworkProtocol) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<C2SPacket> packetType = C2SPacket.fromId(payload.packetId());
|
||||||
|
if (packetType.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (packetType.get()) {
|
||||||
|
case HI -> handleHi(player, payload.nbt());
|
||||||
|
case SUPPORTED_S2C_PACKETS -> handleSupportedS2CPackets(player, payload.nbt());
|
||||||
|
default -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PlayerLeave
|
||||||
|
public static void onPlayerLeave(ServerPlayer player) {
|
||||||
|
CLIENT_SUPPORTED_PACKETS.remove(player.getStringUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleHi(ServerPlayer player, CompoundTag payload) {
|
||||||
|
String platformName = payload.getString("platform_name").orElse("Unknown");
|
||||||
|
String platformVersion = payload.getString("platform_version").orElse("Unknown");
|
||||||
|
LOGGER.info("Player {} connected with TISCM protocol support ({} @ {})", player.getScoreboardName(), platformName, platformVersion);
|
||||||
|
|
||||||
|
send(player, S2CPacket.HELLO, nbt -> {
|
||||||
|
nbt.putString("platform_name", PLATFORM_NAME);
|
||||||
|
nbt.putString("platform_version", PLATFORM_VERSION);
|
||||||
|
});
|
||||||
|
send(player, S2CPacket.SUPPORTED_C2S_PACKETS, nbt -> nbt.put("supported_c2s_packets", stringList(List.of(
|
||||||
|
C2SPacket.HI.id,
|
||||||
|
C2SPacket.SUPPORTED_S2C_PACKETS.id
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleSupportedS2CPackets(ServerPlayer player, CompoundTag payload) {
|
||||||
|
EnumSet<S2CPacket> packets = EnumSet.noneOf(S2CPacket.class);
|
||||||
|
ListTag listTag = payload.getListOrEmpty("supported_s2c_packets");
|
||||||
|
for (int i = 0; i < listTag.size(); i++) {
|
||||||
|
S2CPacket.fromId(listTag.getString(i).orElse("")).ifPresent(packets::add);
|
||||||
|
}
|
||||||
|
CLIENT_SUPPORTED_PACKETS.put(player.getStringUUID(), packets);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void send(ServerPlayer player, S2CPacket packet, PayloadBuilder builder) {
|
||||||
|
if (!supports(player, packet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag nbt = new CompoundTag();
|
||||||
|
builder.accept(nbt);
|
||||||
|
ProtocolUtils.sendPayloadPacket(player, new TISCMPayload(packet.id, nbt));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean supports(ServerPlayer player, S2CPacket packet) {
|
||||||
|
if (packet.handshake) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumSet<S2CPacket> packets = CLIENT_SUPPORTED_PACKETS.get(player.getStringUUID());
|
||||||
|
return packets != null && packets.contains(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ListTag stringList(List<String> values) {
|
||||||
|
ListTag list = new ListTag();
|
||||||
|
for (String value : values) {
|
||||||
|
list.add(StringTag.valueOf(value));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return GeneralCompatConfig.tiscmNetworkProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface PayloadBuilder {
|
||||||
|
void accept(CompoundTag nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum C2SPacket {
|
||||||
|
HI("hi", true),
|
||||||
|
SUPPORTED_S2C_PACKETS("supported_s2c_packets", true),
|
||||||
|
SPEED_TEST_UPLOAD_PAYLOAD("speed_test_upload_payload", false),
|
||||||
|
SPEED_TEST_PING("speed_test_ping", false);
|
||||||
|
|
||||||
|
private static final Map<String, C2SPacket> BY_ID = Arrays.stream(values()).collect(Collectors.toMap(packet -> packet.id, packet -> packet));
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final boolean handshake;
|
||||||
|
|
||||||
|
C2SPacket(String id, boolean handshake) {
|
||||||
|
this.id = id;
|
||||||
|
this.handshake = handshake;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<C2SPacket> fromId(String id) {
|
||||||
|
return Optional.ofNullable(BY_ID.get(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum S2CPacket {
|
||||||
|
HELLO("hello", true),
|
||||||
|
SUPPORTED_C2S_PACKETS("supported_c2s_packets", true),
|
||||||
|
MSPT_METRICS_SAMPLE("mspt_metrics_sample", false),
|
||||||
|
SPEED_TEST_DOWNLOAD_PAYLOAD("speed_test_download_payload", false),
|
||||||
|
SPEED_TEST_UPLOAD_REQUEST("speed_test_upload_request", false),
|
||||||
|
SPEED_TEST_PING("speed_test_ping", false),
|
||||||
|
SPEED_TEST_ABORT("speed_test_abort", false);
|
||||||
|
|
||||||
|
private static final Map<String, S2CPacket> BY_ID = Arrays.stream(values()).collect(Collectors.toMap(packet -> packet.id, packet -> packet));
|
||||||
|
|
||||||
|
private final String id;
|
||||||
|
private final boolean handshake;
|
||||||
|
|
||||||
|
S2CPacket(String id, boolean handshake) {
|
||||||
|
this.id = id;
|
||||||
|
this.handshake = handshake;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<S2CPacket> fromId(String id) {
|
||||||
|
return Optional.ofNullable(BY_ID.get(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record TISCMPayload(String packetId, CompoundTag nbt) implements LeavesCustomPayload {
|
||||||
|
@ID
|
||||||
|
private static final ResourceLocation NETWORK_ID = TISCMProtocol.id("network/v1");
|
||||||
|
|
||||||
|
@Codec
|
||||||
|
private static final StreamCodec<RegistryFriendlyByteBuf, TISCMPayload> CODEC = StreamCodec.composite(
|
||||||
|
ByteBufCodecs.STRING_UTF8,
|
||||||
|
TISCMPayload::packetId,
|
||||||
|
ByteBufCodecs.COMPOUND_TAG,
|
||||||
|
TISCMPayload::nbt,
|
||||||
|
TISCMPayload::new
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package fun.bm.lophine.utils;
|
||||||
|
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import fun.bm.lophine.config.modules.function.ReplayAPIConfig;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class RandomProfilePool {
|
||||||
|
private static int lastUsedId = 0;
|
||||||
|
private static final Object lock = new Object();
|
||||||
|
private static Cache<Integer, GameProfile> cache;
|
||||||
|
private static final Object lockCache = new Object();
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
if (ReplayAPIConfig.enableCache) {
|
||||||
|
cache = CacheBuilder.newBuilder()
|
||||||
|
.maximumSize(ReplayAPIConfig.cachePhotographerSize)
|
||||||
|
.expireAfterWrite(ReplayAPIConfig.cachePhotographerTime, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameProfile getRandomProfile(String id) {
|
||||||
|
if (ReplayAPIConfig.enableCache) {
|
||||||
|
synchronized (lockCache) {
|
||||||
|
for (Map.Entry<Integer, GameProfile> entry : cache.asMap().entrySet()) {
|
||||||
|
int key0 = entry.getKey();
|
||||||
|
cache.invalidate(key0);
|
||||||
|
GameProfile gp = entry.getValue();
|
||||||
|
GameProfile ret = new GameProfile(gp.getId(), id);
|
||||||
|
gp.getProperties().asMap().forEach(
|
||||||
|
(key, values) ->
|
||||||
|
values.forEach((value) ->
|
||||||
|
ret.getProperties().put(key, value)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new GameProfile(UUID.randomUUID(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void putProfile(GameProfile profile) {
|
||||||
|
if (ReplayAPIConfig.enableCache) {
|
||||||
|
synchronized (lockCache) {
|
||||||
|
cache.put(getNextId(), profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getNextId() {
|
||||||
|
synchronized (lock) {
|
||||||
|
int newId = lastUsedId + 1;
|
||||||
|
while (cache.getIfPresent(newId) != null) {
|
||||||
|
newId++;
|
||||||
|
}
|
||||||
|
lastUsedId = newId;
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package fun.bm.lophine.utils;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
import fun.bm.lophine.config.modules.experiment.CommandConfig;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.commands.SaveAllCommand;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class SaveAllUtil {
|
||||||
|
private static final long TIMEOUT = 1000 * 30; // 30 seconds
|
||||||
|
public static final Object lock = new Object();
|
||||||
|
public static volatile long lastSaveAllTime = 0;
|
||||||
|
private static volatile Pair<CommandSourceStack, Boolean> currentSaveAll = null;
|
||||||
|
private static volatile int regionCount = 0;
|
||||||
|
private static final AtomicInteger savedRegionCount = new AtomicInteger(0);
|
||||||
|
private static final AtomicBoolean withError = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
public static void preSaveAll(CommandSourceStack source, boolean flush) {
|
||||||
|
synchronized (lock) {
|
||||||
|
if (isSaving()) {
|
||||||
|
source.sendFailure(Component.literal("Server is already in saving! Please wait..."));
|
||||||
|
} else {
|
||||||
|
source.sendSuccess(() -> Component.translatable("commands.save.saving"), false);
|
||||||
|
currentSaveAll = Pair.of(source, flush);
|
||||||
|
// we need to count how many regions we need to save
|
||||||
|
AtomicInteger count = new AtomicInteger();
|
||||||
|
for (ServerLevel world : source.getServer().getAllLevels()) {
|
||||||
|
world.regioniser.computeForAllRegions(unused -> {
|
||||||
|
count.getAndIncrement();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
regionCount = count.get();
|
||||||
|
savedRegionCount.set(0);
|
||||||
|
withError.set(false);
|
||||||
|
lastSaveAllTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void postRegionSave(io.papermc.paper.threadedregions.TickRegions.TickRegionData region) {
|
||||||
|
Pair<CommandSourceStack, Boolean> currentSaveAll = SaveAllUtil.currentSaveAll;
|
||||||
|
synchronized (lock) {
|
||||||
|
if (lastSaveAllTime < region.lastSavedTime) return; // already saved
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
region.world.moonrise$getChunkTaskScheduler().chunkHolderManager.saveAllChunksRegionised(currentSaveAll.getSecond(), false, CommandConfig.logAllProcess, false, true, false);
|
||||||
|
currentSaveAll.getFirst().getServer().getPlayerList().saveAll();
|
||||||
|
MinecraftServer.LOGGER.info("Saved chunks in region around chunk {} in world '{}'", region.region.getCenterChunk(), region.region.regioniser.world.getWorld().getName());
|
||||||
|
} catch (final Throwable thr) {
|
||||||
|
CommandSyntaxException error = SaveAllCommand.getErrorFailed().create();
|
||||||
|
currentSaveAll.getFirst().sendFailure(Component.literal(error.getMessage()));
|
||||||
|
MinecraftServer.LOGGER.error(error.getMessage(), thr);
|
||||||
|
withError.set(true);
|
||||||
|
}
|
||||||
|
region.lastSavedTime = System.currentTimeMillis();
|
||||||
|
int saved;
|
||||||
|
synchronized (savedRegionCount) {
|
||||||
|
saved = savedRegionCount.incrementAndGet();
|
||||||
|
}
|
||||||
|
if (saved >= regionCount) {
|
||||||
|
if (withError.get()) {
|
||||||
|
currentSaveAll.getFirst().sendFailure(Component.literal("At least one region failed to save!"));
|
||||||
|
} else if (saved == regionCount) {
|
||||||
|
currentSaveAll.getFirst().sendSuccess(() -> Component.translatable("commands.save.success"), true);
|
||||||
|
SaveAllUtil.currentSaveAll = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkTimeout() {
|
||||||
|
Pair<CommandSourceStack, Boolean> currentSaveAll = SaveAllUtil.currentSaveAll;
|
||||||
|
if (!isSaving()) return;
|
||||||
|
if (System.currentTimeMillis() - lastSaveAllTime > TIMEOUT) {
|
||||||
|
currentSaveAll.getFirst().sendFailure(Component.literal("At least one region save data timeout!"));
|
||||||
|
currentSaveAll.getFirst().sendFailure(Component.literal("Regions need to save expect is " + regionCount + ", but only " + savedRegionCount.get() + " saved!"));
|
||||||
|
SaveAllUtil.currentSaveAll = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSaving() {
|
||||||
|
synchronized (lock) {
|
||||||
|
return currentSaveAll != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,7 @@ public class ServerI18nUtil {
|
|||||||
} catch (UnsupportedLanguageException e) {
|
} catch (UnsupportedLanguageException e) {
|
||||||
logger.warn("Unsupported language: {}", LanguageConfig.lang);
|
logger.warn("Unsupported language: {}", LanguageConfig.lang);
|
||||||
// Fallback to English
|
// Fallback to English
|
||||||
final ConfigsInstance configsInstance = ConfigManager.configfiles.get("lophine");
|
final ConfigsInstance configsInstance = ConfigManager.getConfigs("lophine");
|
||||||
configsInstance.setConfig(new String[]{"function", "language", "lang"}, "en_us");
|
configsInstance.setConfig(new String[]{"function", "language", "lang"}, "en_us");
|
||||||
configsInstance.reloadAsync(true);
|
configsInstance.reloadAsync(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
+2
@@ -4,6 +4,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class AbstractConcurrentTable<X, Y, Z> {
|
public abstract class AbstractConcurrentTable<X, Y, Z> {
|
||||||
|
public abstract void putOrUpdate(X x, Y y, Z z);
|
||||||
|
|
||||||
public abstract void put(X x, Y y, Z z);
|
public abstract void put(X x, Y y, Z z);
|
||||||
|
|
||||||
public abstract void remove(X x, Y y, Z z);
|
public abstract void remove(X x, Y y, Z z);
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ import java.util.function.Predicate;
|
|||||||
public class ConcurrentTable<X, Y, Z> extends AbstractConcurrentTable<X, Y, Z> {
|
public class ConcurrentTable<X, Y, Z> extends AbstractConcurrentTable<X, Y, Z> {
|
||||||
protected final ConcurrentLinkedDeque<TableEntry<X, Y, Z>> data = new ConcurrentLinkedDeque<>();
|
protected final ConcurrentLinkedDeque<TableEntry<X, Y, Z>> data = new ConcurrentLinkedDeque<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putOrUpdate(X x, Y y, Z z) {
|
||||||
|
for (TableEntry<X, Y, Z> entry : data) {
|
||||||
|
if (entry.getX().equals(x) && entry.getY().equals(y)) {
|
||||||
|
entry.setZ(z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.put(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(X x, Y y, Z z) {
|
public void put(X x, Y y, Z z) {
|
||||||
data.add(new TableEntry<>(x, y, z));
|
data.add(new TableEntry<>(x, y, z));
|
||||||
|
|||||||
+31
-2
@@ -11,8 +11,30 @@ public class OptimizedConcurrentTable<X, Y, Z> extends ConcurrentTable<X, Y, Z>
|
|||||||
private final ConcurrentHashMap<Z, ConcurrentHashMap<X, Set<Y>>> zxIndex = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Z, ConcurrentHashMap<X, Set<Y>>> zxIndex = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(X x, Y y, Z z) {
|
public void putOrUpdate(X x, Y y, Z z) {
|
||||||
super.put(x, y, z);
|
boolean updated = false;
|
||||||
|
|
||||||
|
for (TableEntry<X, Y, Z> entry : data) {
|
||||||
|
if (entry.getX().equals(x) && entry.getY().equals(y)) {
|
||||||
|
removeFromIndex(xyIndex, entry.getX(), entry.getY(), entry.getZ());
|
||||||
|
removeFromIndex(yzIndex, entry.getY(), entry.getZ(), entry.getX());
|
||||||
|
removeFromIndex(zxIndex, entry.getZ(), entry.getX(), entry.getY());
|
||||||
|
|
||||||
|
entry.setZ(z);
|
||||||
|
|
||||||
|
putData(x, y, z);
|
||||||
|
|
||||||
|
updated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
this.put(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putData(X x, Y y, Z z) {
|
||||||
xyIndex.computeIfAbsent(x, k -> new ConcurrentHashMap<>())
|
xyIndex.computeIfAbsent(x, k -> new ConcurrentHashMap<>())
|
||||||
.computeIfAbsent(y, k -> ConcurrentHashMap.newKeySet()).add(z);
|
.computeIfAbsent(y, k -> ConcurrentHashMap.newKeySet()).add(z);
|
||||||
yzIndex.computeIfAbsent(y, k -> new ConcurrentHashMap<>())
|
yzIndex.computeIfAbsent(y, k -> new ConcurrentHashMap<>())
|
||||||
@@ -21,6 +43,13 @@ public class OptimizedConcurrentTable<X, Y, Z> extends ConcurrentTable<X, Y, Z>
|
|||||||
.computeIfAbsent(x, k -> ConcurrentHashMap.newKeySet()).add(y);
|
.computeIfAbsent(x, k -> ConcurrentHashMap.newKeySet()).add(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(X x, Y y, Z z) {
|
||||||
|
super.put(x, y, z);
|
||||||
|
putData(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(X x, Y y, Z z) {
|
public void remove(X x, Y y, Z z) {
|
||||||
super.remove(x, y, z);
|
super.remove(x, y, z);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package fun.bm.lophine.utils.concurrent;
|
|||||||
public class TableEntry<X, Y, Z> {
|
public class TableEntry<X, Y, Z> {
|
||||||
private final X x;
|
private final X x;
|
||||||
private final Y y;
|
private final Y y;
|
||||||
private final Z z;
|
private Z z;
|
||||||
|
|
||||||
public TableEntry(X x, Y y, Z z) {
|
public TableEntry(X x, Y y, Z z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -22,4 +22,8 @@ public class TableEntry<X, Y, Z> {
|
|||||||
public Z getZ() {
|
public Z getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setZ(Z z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,15 @@
|
|||||||
package org.leavesmc.leaves.bot;
|
package org.leavesmc.leaves.bot;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.component.ItemContainerContents;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -34,23 +38,66 @@ public class BotUtil {
|
|||||||
public static void replenishment(@NotNull ItemStack itemStack, NonNullList<ItemStack> itemStackList) {
|
public static void replenishment(@NotNull ItemStack itemStack, NonNullList<ItemStack> itemStackList) {
|
||||||
int count = itemStack.getMaxStackSize() / 2;
|
int count = itemStack.getMaxStackSize() / 2;
|
||||||
if (itemStack.getCount() <= 8 && count > 8) {
|
if (itemStack.getCount() <= 8 && count > 8) {
|
||||||
for (ItemStack itemStack1 : itemStackList) {
|
if (pullMatchingStack(itemStack, itemStackList, count)) {
|
||||||
if (itemStack1 == ItemStack.EMPTY || itemStack1 == itemStack) {
|
return;
|
||||||
|
}
|
||||||
|
if (FakePlayerCompatConfig.fakePlayerAutoReplenishmentFormShulkerBox) {
|
||||||
|
pullMatchingStackFromShulkerBox(itemStack, itemStackList, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean pullMatchingStack(@NotNull ItemStack targetStack, NonNullList<ItemStack> itemStackList, int transferLimit) {
|
||||||
|
for (ItemStack inventoryStack : itemStackList) {
|
||||||
|
if (inventoryStack == ItemStack.EMPTY || inventoryStack == targetStack) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ItemStack.isSameItemSameComponents(inventoryStack, targetStack)) {
|
||||||
|
if (inventoryStack.getCount() > transferLimit) {
|
||||||
|
targetStack.setCount(targetStack.getCount() + transferLimit);
|
||||||
|
inventoryStack.setCount(inventoryStack.getCount() - transferLimit);
|
||||||
|
} else {
|
||||||
|
targetStack.setCount(targetStack.getCount() + inventoryStack.getCount());
|
||||||
|
inventoryStack.setCount(0);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean pullMatchingStackFromShulkerBox(@NotNull ItemStack targetStack, NonNullList<ItemStack> itemStackList, int transferLimit) {
|
||||||
|
for (ItemStack containerStack : itemStackList) {
|
||||||
|
if (containerStack == ItemStack.EMPTY || !containerStack.is(ItemTags.SHULKER_BOXES)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemContainerContents contents = containerStack.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY);
|
||||||
|
NonNullList<ItemStack> shulkerItems = NonNullList.withSize(contents.items.size(), ItemStack.EMPTY);
|
||||||
|
contents.copyInto(shulkerItems);
|
||||||
|
|
||||||
|
for (int slot = 0; slot < shulkerItems.size(); slot++) {
|
||||||
|
ItemStack shulkerStack = shulkerItems.get(slot);
|
||||||
|
if (shulkerStack.isEmpty() || !ItemStack.isSameItemSameComponents(shulkerStack, targetStack)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemStack.isSameItemSameComponents(itemStack1, itemStack)) {
|
int moved = Math.min(Math.min(transferLimit, shulkerStack.getCount()), targetStack.getMaxStackSize() - targetStack.getCount());
|
||||||
if (itemStack1.getCount() > count) {
|
if (moved <= 0) {
|
||||||
itemStack.setCount(itemStack.getCount() + count);
|
return false;
|
||||||
itemStack1.setCount(itemStack1.getCount() - count);
|
|
||||||
} else {
|
|
||||||
itemStack.setCount(itemStack.getCount() + itemStack1.getCount());
|
|
||||||
itemStack1.setCount(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targetStack.grow(moved);
|
||||||
|
shulkerStack.shrink(moved);
|
||||||
|
shulkerItems.set(slot, shulkerStack.isEmpty() ? ItemStack.EMPTY : shulkerStack);
|
||||||
|
containerStack.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerItems));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void replaceTool(@NotNull EquipmentSlot slot, @NotNull ServerBot bot) {
|
public static void replaceTool(@NotNull EquipmentSlot slot, @NotNull ServerBot bot) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package org.leavesmc.leaves.bot;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||||
import io.papermc.paper.adventure.PaperAdventure;
|
import io.papermc.paper.adventure.PaperAdventure;
|
||||||
import io.papermc.paper.event.entity.EntityKnockbackEvent;
|
import io.papermc.paper.event.entity.EntityKnockbackEvent;
|
||||||
@@ -52,9 +53,11 @@ import net.minecraft.world.entity.PositionMoveRotation;
|
|||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Input;
|
import net.minecraft.world.entity.player.Input;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.entity.projectile.FishingHook;
|
||||||
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
import net.minecraft.world.entity.projectile.ProjectileUtil;
|
||||||
import net.minecraft.world.entity.vehicle.AbstractBoat;
|
import net.minecraft.world.entity.vehicle.AbstractBoat;
|
||||||
import net.minecraft.world.inventory.ChestMenu;
|
import net.minecraft.world.inventory.ChestMenu;
|
||||||
|
import net.minecraft.world.item.FishingRodItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import net.minecraft.world.level.GameRules;
|
import net.minecraft.world.level.GameRules;
|
||||||
@@ -83,6 +86,8 @@ import java.util.*;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class ServerBot extends ServerPlayer {
|
public class ServerBot extends ServerPlayer {
|
||||||
|
private static final int AUTO_FISH_RECAST_DELAY = 4;
|
||||||
|
private static final int AUTO_FISH_ENTITY_DELAY = 20;
|
||||||
|
|
||||||
private final List<AbstractBotAction<?>> actions;
|
private final List<AbstractBotAction<?>> actions;
|
||||||
private final Map<String, AbstractBotConfig<?, ?, ?>> configs;
|
private final Map<String, AbstractBotConfig<?, ?, ?>> configs;
|
||||||
@@ -100,6 +105,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
public int notSleepTicks;
|
public int notSleepTicks;
|
||||||
|
|
||||||
public int removeTaskId = -1;
|
public int removeTaskId = -1;
|
||||||
|
private int autoFishCooldown = 0;
|
||||||
|
|
||||||
public ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) {
|
public ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) {
|
||||||
super(server, world, profile, ClientInformation.createDefault());
|
super(server, world, profile, ClientInformation.createDefault());
|
||||||
@@ -248,6 +254,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.getCooldowns().tick();
|
this.getCooldowns().tick();
|
||||||
|
this.tickAutoFish();
|
||||||
this.updatePlayerPose();
|
this.updatePlayerPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +313,18 @@ public class ServerBot extends ServerPlayer {
|
|||||||
teleportTransition.postTeleportTransition().onTransition(this);
|
teleportTransition.postTeleportTransition().onTransition(this);
|
||||||
this.isChangingDimension = false;
|
this.isChangingDimension = false;
|
||||||
|
|
||||||
|
// Lophine - We don't have this
|
||||||
|
/* if (LeavesConfig.modify.netherPortalFix) {
|
||||||
|
final ResourceKey<Level> fromDim = fromLevel.dimension();
|
||||||
|
final ResourceKey<Level> toDim = level().dimension();
|
||||||
|
if (!((fromDim != Level.OVERWORLD || toDim != Level.NETHER) && (fromDim != Level.NETHER || toDim != Level.OVERWORLD))) {
|
||||||
|
BlockPos fromPortal = org.leavesmc.leaves.util.ReturnPortalManager.findPortalAt(this, fromDim, lastPos);
|
||||||
|
BlockPos toPos = this.blockPosition();
|
||||||
|
if (fromPortal != null) {
|
||||||
|
org.leavesmc.leaves.util.ReturnPortalManager.storeReturnPortal(this, toDim, toPos, fromPortal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
if (this.isBlocking()) {
|
if (this.isBlocking()) {
|
||||||
this.stopUsingItem();
|
this.stopUsingItem();
|
||||||
}
|
}
|
||||||
@@ -338,8 +357,10 @@ public class ServerBot extends ServerPlayer {
|
|||||||
ItemStack item = this.getItemInHand(hand);
|
ItemStack item = this.getItemInHand(hand);
|
||||||
|
|
||||||
if (!item.isEmpty()) {
|
if (!item.isEmpty()) {
|
||||||
BotUtil.replenishment(item, getInventory().getNonEquipmentItems());
|
if (FakePlayerCompatConfig.fakePlayerAutoReplenishment) {
|
||||||
if (BotUtil.isDamage(item, 10)) {
|
BotUtil.replenishment(item, getInventory().getNonEquipmentItems());
|
||||||
|
}
|
||||||
|
if (FakePlayerCompatConfig.fakePlayerAutoReplaceTool && BotUtil.isDamage(item, 10)) {
|
||||||
BotUtil.replaceTool(hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND, this);
|
BotUtil.replaceTool(hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +408,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
|
|
||||||
nbt.store("createStatus", CompoundTag.CODEC, createNbt);
|
nbt.store("createStatus", CompoundTag.CODEC, createNbt);
|
||||||
|
|
||||||
if (!this.actions.isEmpty()) {
|
if (FakePlayerCompatConfig.fakePlayerReloadAction && !this.actions.isEmpty()) {
|
||||||
ValueOutput.TypedOutputList<CompoundTag> actionNbt = nbt.list("actions", CompoundTag.CODEC);
|
ValueOutput.TypedOutputList<CompoundTag> actionNbt = nbt.list("actions", CompoundTag.CODEC);
|
||||||
for (AbstractBotAction<?> action : this.actions) {
|
for (AbstractBotAction<?> action : this.actions) {
|
||||||
actionNbt.add(action.save(new CompoundTag()));
|
actionNbt.add(action.save(new CompoundTag()));
|
||||||
@@ -426,7 +447,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
this.gameProfile = new BotList.CustomGameProfile(this.getUUID(), this.createState.name(), this.createState.skin());
|
this.gameProfile = new BotList.CustomGameProfile(this.getUUID(), this.createState.name(), this.createState.skin());
|
||||||
|
|
||||||
|
|
||||||
if (nbt.list("actions", CompoundTag.CODEC).isPresent()) {
|
if (FakePlayerCompatConfig.fakePlayerReloadAction && nbt.list("actions", CompoundTag.CODEC).isPresent()) {
|
||||||
ValueInput.TypedInputList<CompoundTag> actionNbt = nbt.list("actions", CompoundTag.CODEC).orElseThrow();
|
ValueInput.TypedInputList<CompoundTag> actionNbt = nbt.list("actions", CompoundTag.CODEC).orElseThrow();
|
||||||
actionNbt.forEach(actionTag -> {
|
actionNbt.forEach(actionTag -> {
|
||||||
AbstractBotAction<?> action = Actions.getForName(actionTag.getString("actionName").orElseThrow());
|
AbstractBotAction<?> action = Actions.getForName(actionTag.getString("actionName").orElseThrow());
|
||||||
@@ -443,6 +464,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
for (CompoundTag configTag : configNbt) {
|
for (CompoundTag configTag : configNbt) {
|
||||||
AbstractBotConfig<?, ?, ?> config = Configs.getConfig(configTag.getString("configName").orElseThrow());
|
AbstractBotConfig<?, ?, ?> config = Configs.getConfig(configTag.getString("configName").orElseThrow());
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
|
config.setBot(this);
|
||||||
config.load(configTag);
|
config.load(configTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,7 +521,7 @@ public class ServerBot extends ServerPlayer {
|
|||||||
Component defaultMessage = this.getCombatTracker().getDeathMessage();
|
Component defaultMessage = this.getCombatTracker().getDeathMessage();
|
||||||
|
|
||||||
BotDeathEvent event = new BotDeathEvent(this.getBukkitEntity(), PaperAdventure.asAdventure(defaultMessage), flag);
|
BotDeathEvent event = new BotDeathEvent(this.getBukkitEntity(), PaperAdventure.asAdventure(defaultMessage), flag);
|
||||||
MinecraftServer.getServer().server.getPluginManager().callEvent(event);
|
this.getServer().server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
if (this.getHealth() <= 0) {
|
if (this.getHealth() <= 0) {
|
||||||
@@ -645,6 +667,45 @@ public class ServerBot extends ServerPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tickAutoFish() {
|
||||||
|
if (!fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig.fakePlayerAutoFish || this.hasActiveAction("fish")) {
|
||||||
|
this.autoFishCooldown = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.autoFishCooldown > 0) {
|
||||||
|
this.autoFishCooldown--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack mainHand = this.getMainHandItem();
|
||||||
|
if (mainHand.isEmpty() || !(mainHand.getItem() instanceof FishingRodItem)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FishingHook fishingHook = this.fishing;
|
||||||
|
if (fishingHook != null) {
|
||||||
|
if (fishingHook.currentState == FishingHook.FishHookState.HOOKED_IN_ENTITY) {
|
||||||
|
mainHand.use(this.level(), this, InteractionHand.MAIN_HAND);
|
||||||
|
this.autoFishCooldown = AUTO_FISH_ENTITY_DELAY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fishingHook.nibble > 0) {
|
||||||
|
mainHand.use(this.level(), this, InteractionHand.MAIN_HAND);
|
||||||
|
this.autoFishCooldown = AUTO_FISH_RECAST_DELAY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainHand.use(this.level(), this, InteractionHand.MAIN_HAND);
|
||||||
|
this.autoFishCooldown = AUTO_FISH_RECAST_DELAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasActiveAction(String actionName) {
|
||||||
|
return this.actions.stream().anyMatch(action -> !action.isCancelled() && action.getName().equals(actionName));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addBotAction(AbstractBotAction<?> action, CommandSender sender) {
|
public boolean addBotAction(AbstractBotAction<?> action, CommandSender sender) {
|
||||||
if (!FakeplayerConfig.canUseAction) {
|
if (!FakeplayerConfig.canUseAction) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
|
|
||||||
package org.leavesmc.leaves.bot;
|
package org.leavesmc.leaves.bot;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
@@ -40,7 +42,7 @@ public class ServerBotGameMode extends ServerPlayerGameMode {
|
|||||||
|
|
||||||
public ServerBotGameMode(ServerBot bot) {
|
public ServerBotGameMode(ServerBot bot) {
|
||||||
super(bot);
|
super(bot);
|
||||||
super.setGameModeForPlayer(GameType.SURVIVAL, null);
|
super.setGameModeForPlayer(getInitialGameMode(bot), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,4 +135,8 @@ public class ServerBotGameMode extends ServerPlayerGameMode {
|
|||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static GameType getInitialGameMode(ServerBot bot) {
|
||||||
|
return FakePlayerCompatConfig.fakePlayerDefaultSurvivalMode ? GameType.SURVIVAL : MinecraftServer.getServer().getDefaultGameType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
@@ -17,9 +17,12 @@
|
|||||||
|
|
||||||
package org.leavesmc.leaves.bot.agent.actions;
|
package org.leavesmc.leaves.bot.agent.actions;
|
||||||
|
|
||||||
|
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.phys.EntityHitResult;
|
import net.minecraft.world.phys.EntityHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -51,6 +54,13 @@ public class ServerUseItemToAction extends AbstractUseBotAction<ServerUseItemToA
|
|||||||
Vec3 vec3 = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
|
Vec3 vec3 = hitResult.getLocation().subtract(entity.getX(), entity.getY(), entity.getZ());
|
||||||
bot.updateItemInHand(hand);
|
bot.updateItemInHand(hand);
|
||||||
InteractionResult interactionResult = entity.interactAt(bot, vec3, hand);
|
InteractionResult interactionResult = entity.interactAt(bot, vec3, hand);
|
||||||
|
if (FakePlayerCompatConfig.fakePlayerInteractLikeClient
|
||||||
|
&& entity instanceof ArmorStand stand
|
||||||
|
&& !stand.isMarker()
|
||||||
|
&& !bot.isSpectator()
|
||||||
|
&& !bot.getItemInHand(hand).is(Items.NAME_TAG)) {
|
||||||
|
interactionResult = InteractionResult.PASS;
|
||||||
|
}
|
||||||
if (!interactionResult.consumesAction()) {
|
if (!interactionResult.consumesAction()) {
|
||||||
interactionResult = bot.interactOn(hitResult.getEntity(), hand);
|
interactionResult = bot.interactOn(hitResult.getEntity(), hand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package org.leavesmc.leaves.protocol;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.codec.ByteBufCodecs;
|
||||||
|
import net.minecraft.network.codec.StreamCodec;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.protocol.core.LeavesCustomPayload;
|
||||||
|
import org.leavesmc.leaves.protocol.core.LeavesProtocol;
|
||||||
|
import org.leavesmc.leaves.protocol.core.ProtocolHandler;
|
||||||
|
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@LeavesProtocol.Register(namespace = "carpet")
|
||||||
|
public class CarpetServerProtocol implements LeavesProtocol {
|
||||||
|
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||||
|
|
||||||
|
public static final String PROTOCOL_ID = "carpet";
|
||||||
|
public static final String VERSION = ProtocolUtils.buildProtocolVersion(PROTOCOL_ID);
|
||||||
|
|
||||||
|
private static final String HI = "69";
|
||||||
|
private static final String HELLO = "420";
|
||||||
|
|
||||||
|
@Contract("_ -> new")
|
||||||
|
public static ResourceLocation id(String path) {
|
||||||
|
return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PlayerJoin
|
||||||
|
public static void onPlayerJoin(ServerPlayer player) {
|
||||||
|
CompoundTag data = new CompoundTag();
|
||||||
|
data.putString(HI, VERSION);
|
||||||
|
ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ProtocolHandler.PayloadReceiver(payload = CarpetPayload.class)
|
||||||
|
private static void handleHello(@NotNull ServerPlayer player, @NotNull CarpetServerProtocol.CarpetPayload payload) {
|
||||||
|
if (payload.nbt.contains(HELLO)) {
|
||||||
|
LOGGER.info("Player {} joined with carpet {}", player.getScoreboardName(), payload.nbt.getString(HELLO).orElse("Unknown"));
|
||||||
|
CompoundTag data = new CompoundTag();
|
||||||
|
CarpetRules.write(data);
|
||||||
|
ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive() {
|
||||||
|
return CarpetRules.hasRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CarpetRules {
|
||||||
|
|
||||||
|
private static final Map<String, CarpetRule> rules = new HashMap<>();
|
||||||
|
|
||||||
|
public static void write(@NotNull CompoundTag tag) {
|
||||||
|
CompoundTag rulesNbt = new CompoundTag();
|
||||||
|
rules.values().forEach(rule -> rule.writeNBT(rulesNbt));
|
||||||
|
|
||||||
|
tag.put("Rules", rulesNbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register(CarpetRule rule) {
|
||||||
|
rules.put(rule.name, rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
rules.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasRules() {
|
||||||
|
return !rules.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record CarpetRule(String identifier, String name, String value) {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract("_, _, _ -> new")
|
||||||
|
public static CarpetRule of(String identifier, String name, Enum<?> value) {
|
||||||
|
return new CarpetRule(identifier, name, value.name().toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract("_, _, _ -> new")
|
||||||
|
public static CarpetRule of(String identifier, String name, boolean value) {
|
||||||
|
return new CarpetRule(identifier, name, Boolean.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract("_, _, _ -> new")
|
||||||
|
public static CarpetRule of(String identifier, String name, int value) {
|
||||||
|
return new CarpetRule(identifier, name, Integer.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract("_, _, _ -> new")
|
||||||
|
public static CarpetRule of(String identifier, String name, long value) {
|
||||||
|
return new CarpetRule(identifier, name, Long.toString(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Contract("_, _, _ -> new")
|
||||||
|
public static CarpetRule of(String identifier, String name, String value) {
|
||||||
|
return new CarpetRule(identifier, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeNBT(@NotNull CompoundTag rules) {
|
||||||
|
CompoundTag rule = new CompoundTag();
|
||||||
|
String key = name;
|
||||||
|
|
||||||
|
while (rules.contains(key)) {
|
||||||
|
key = key + "2";
|
||||||
|
}
|
||||||
|
|
||||||
|
rule.putString("Value", value);
|
||||||
|
rule.putString("Manager", identifier);
|
||||||
|
rule.putString("Rule", name);
|
||||||
|
rules.put(key, rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public record CarpetPayload(CompoundTag nbt) implements LeavesCustomPayload {
|
||||||
|
@ID
|
||||||
|
private static final ResourceLocation HELLO_ID = CarpetServerProtocol.id("hello");
|
||||||
|
|
||||||
|
@Codec
|
||||||
|
private static final StreamCodec<FriendlyByteBuf, CarpetPayload> CODEC = StreamCodec.composite(
|
||||||
|
ByteBufCodecs.COMPOUND_TAG, CarpetPayload::nbt, CarpetPayload::new
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -84,6 +84,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol {
|
|||||||
private static void onPlayerLeave(ServerPlayer player) {
|
private static void onPlayerLeave(ServerPlayer player) {
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
loggerPlayers.remove(player);
|
loggerPlayers.remove(player);
|
||||||
|
DATA.rowMap().values().forEach(row -> row.remove(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ProtocolHandler.PayloadReceiver(payload = HudDataPayload.class)
|
@ProtocolHandler.PayloadReceiver(payload = HudDataPayload.class)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.leavesmc.leaves.replay;
|
|||||||
|
|
||||||
import ca.spottedleaf.moonrise.common.util.TickThread;
|
import ca.spottedleaf.moonrise.common.util.TickThread;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import fun.bm.lophine.utils.RandomProfilePool;
|
||||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ClientInformation;
|
import net.minecraft.server.level.ClientInformation;
|
||||||
@@ -70,7 +71,7 @@ public class ServerPhotographer extends ServerPlayer {
|
|||||||
MinecraftServer server = MinecraftServer.getServer();
|
MinecraftServer server = MinecraftServer.getServer();
|
||||||
|
|
||||||
ServerLevel world = ((CraftWorld) state.loc.getWorld()).getHandle();
|
ServerLevel world = ((CraftWorld) state.loc.getWorld()).getHandle();
|
||||||
GameProfile profile = new GameProfile(UUID.randomUUID(), state.id);
|
GameProfile profile = RandomProfilePool.getRandomProfile(state.id); // Lophine - add cache
|
||||||
|
|
||||||
ServerPhotographer photographer = new ServerPhotographer(server, world, profile);
|
ServerPhotographer photographer = new ServerPhotographer(server, world, profile);
|
||||||
photographer.absSnapTo(state.loc.x(), state.loc.y(), state.loc.z(), state.loc.getYaw(), state.loc.getPitch());
|
photographer.absSnapTo(state.loc.x(), state.loc.y(), state.loc.z(), state.loc.getYaw(), state.loc.getPitch());
|
||||||
@@ -165,6 +166,7 @@ public class ServerPhotographer extends ServerPlayer {
|
|||||||
photographers.remove(this);
|
photographers.remove(this);
|
||||||
|
|
||||||
MinecraftServer.getServer().getPlayerList().removePhotographer(this);
|
MinecraftServer.getServer().getPlayerList().removePhotographer(this);
|
||||||
|
RandomProfilePool.putProfile(this.gameProfile); // Lophine - add cache
|
||||||
if (!recorder.isSaved()) {
|
if (!recorder.isSaved()) {
|
||||||
CompletableFuture<Void> future = recorder.saveRecording(saveFile, save);
|
CompletableFuture<Void> future = recorder.saveRecording(saveFile, save);
|
||||||
if (!async) {
|
if (!async) {
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@
|
|||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
linter: jetbrains/qodana-jvm:2025.2
|
linter: jetbrains/qodana-jvm-community:latest
|
||||||
profile:
|
profile:
|
||||||
name: qodana.recommended
|
name: qodana.recommended
|
||||||
include:
|
include:
|
||||||
- name: CheckDependencyLicenses
|
- name: CheckDependencyLicenses
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
|
val weightVersion: String by settings
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
maven("https://repo.menthamc.org/repository/maven-public/")
|
maven("https://repo.menthamc.org/repository/maven-public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("moe.luminolmc.hyacinthusweight.patcher") version weightVersion
|
||||||
|
id("moe.luminolmc.hyacinthusweight.core") version weightVersion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|||||||
Reference in New Issue
Block a user