37 Commits
Author SHA1 Message Date
AxTps f985a22d8a fix: 补齐缺失的 5 条规则中文名,修正 en_us 中的中文描述
build / build (push) Canceled after 0s
- 补 elytraCraftable / armadilloImmediateDespawns / offlineFakePlayers / netherPortalSize / trialSpawnerCD 的 name(此前 /list 里显示为驼峰字段名)
- en_us 的 offlineFakePlayers.desc 由中文改为英文
2026-10-17 15:10:14 +08:00
AxTps 61ce9891b9 fix: 碎冰规则改为只保留水源变碎冰,流动水不再中断水流
原实现直接拦截 setBlockAndUpdate 并返回 false,导致邻接蓝冰的流动水被 shouldSpreadLiquid 的 return false 短路,水流扩散停止。
改为在 BlockState#is(BLUE_ICE) 判断处做手脚:规则开启且当前水非水源时让 is 返回 false,原版整个变碎冰分支被跳过,shouldSpreadLiquid 正常返回 true,水流照常扩散。
2026-10-17 15:10:07 +08:00
AxTps 94fafe972c fix: 适配 26.4 快照的 API 变更
build / build (push) Canceled after 0s
- 升级 Gradle wrapper 到 9.8.1(Loom 1.19.1 要求 Gradle >= 9.8.0)
- accesswidener:EnderMan$EndermanTakeBlockGoal -> Enderman$EndermanTakeBlockGoal(大小写变更)
- MixinRedstoneWireBlock:RedStoneWireBlock -> RedstoneWireBlock(类名大小写变更)
- MixinSpawnHelper:EntityType.BAT -> EntityTypes.BAT(实体常量迁移到 EntityTypes)
- BotCommand:CommonListenerCookie 构造器新增 ClientDebugInfo 参数
- MixinEnderDragonFight:EndPodiumFeature.getLocation(BlockPos) 移除,改用 EnderDragonFight.getPodiumLocation(BlockPos) 并 Shadow origin 字段
- ShulkerBoxItemUtil:ItemContainerContents.allItemsCopyStream() -> nonEmptyItemCopyStream()
2026-10-17 14:41:56 +08:00
AxTps f9a198a892 feat: 适配 26.4 并新增横向流动水不产生碎冰规则
build / build (push) Canceled after 0s
- gradle.properties 切换到 26.4-snapshot-4 / Loom 1.19-SNAPSHOT / Loader 0.20.0 / Fabric API 0.163.0+26.4 / Carpet 26.4-beta-3
- 新增规则 noBrittleIceFromFlowingWater,默认关闭
- LiquidBlock#shouldSpreadLiquid 用 WrapOperation 拦截碎冰替换:只有竖直下落的水(FlowingFluid#isFalling)才允许把邻接蓝冰转成碎冰,横向流动的水跳过
- 补 zh_cn/en_us 规则名与描述
2026-10-17 14:26:21 +08:00
AxTps 0df145927f chore: 版本号升至0.25.0,去掉榜单诊断日志 2026-10-06 21:46:38 +08:00
AxTps 5cfe2f1694 fix: onClientRequest先REMOVE再ADD objective+补分数包(两榜都显示且不崩) 2026-10-06 21:43:15 +08:00
AxTps ea7720b7cd fix: 回退重发分数包(导致客户端unknown objective,两榜都不显示) 2026-10-06 21:41:48 +08:00
AxTps 1c77347dc2 fix: onClientRequest重发该objective的分数包(客户端空榜不显示)
sls_deaths分数值不变时服务端不发分数包,客户端收到空objective不渲染。改成请求时重发所有分数包(只发Score包避免重复创建)。
2026-10-06 21:38:27 +08:00
AxTps 35b05eb044 debug: onClientRequest打印obj是否null 2026-10-06 21:34:58 +08:00
AxTps a434f12749 fix: 回退syncScores里的startTrackingObjective(不幂等导致客户端重复建objective崩溃) 2026-10-06 21:30:55 +08:00
AxTps 93e7416056 fix: syncScores每次确保objective在追踪(分数才同步给客户端) 2026-10-06 21:28:10 +08:00
AxTps 62397479be fix: 修复BoardManager末尾字面量\\n编译错误 2026-10-06 21:23:50 +08:00
AxTps 5001b2f5a2 feat: /slsboard改发请求包,服务端给该玩家单独发display包(per-player显示)
客户端本地setDisplayObjective会被服务端覆盖,改用C2S请求包,服务端单独发ClientboundSetDisplayObjectivePacket给请求者。
2026-10-06 21:22:42 +08:00
AxTps d3bd73f7c5 fix: 调用startTrackingObjective让客户端收到objective
load进来的objective未在trackedObjectives集合,客户端收不到。SERVER_STARTED时显式startTrackingObjective。
2026-10-06 21:04:18 +08:00
AxTps d44ea0f4a7 fix: objective改在SERVER_STARTED创建(scoreboard load完成后)
轮询线程比scoreboard.load更早跑,仍会撞名崩溃。改用ServerLifecycleEvents.SERVER_STARTED。
2026-10-06 21:01:03 +08:00
AxTps de966ac511 fix: 修复objective重复创建崩溃(ensure推迟到scoreboard load后)
onServerLoaded时机太早,scoreboard.dat还没load完,getObjective返回null导致重复addObjective崩溃。改为syncScores首次调用时ensure。
2026-10-06 20:52:24 +08:00
AxTps 33542f9678 debug: ensureObjectives加日志 2026-10-06 20:47:17 +08:00
AxTps 870223bc1e refactor: 榜单改用原版计分板侧边栏显示
服务端读stats定期写入scoreboard objective;客户端/slsboard设本地sidebar display。删掉自绘HUD和网络包(GuiGraphicsExtractor渲染不走)。
2026-10-06 20:42:40 +08:00
AxTps 2097a241aa fix: HUD画之前调nextStratum(原版计分板也这么做,否则不渲染) 2026-10-06 20:36:22 +08:00
AxTps 8576395126 debug: totalMined打印stats map的size/挖掘条目数/总和 2026-10-06 20:32:15 +08:00
AxTps 72fbc95874 fix: totalMined改用遍历stats map(之前遍历所有方块读不到数据)
AW暴露StatsCounter.stats字段。之前遍历BuiltInRegistries.BLOCK用getValue(StatType,block)大多返回0,导致挖掘数偏低。
2026-10-06 20:25:40 +08:00
AxTps 1ee529eb5b debug: 加客户端收包日志,去服务端刷屏日志 2026-10-06 20:11:40 +08:00
AxTps bdac8233a6 debug: 服务端加榜单同步/分数诊断日志 2026-10-06 20:07:32 +08:00
AxTps 4cc1b64fc3 fix: HUD去日志+空列表return,服务端每5秒定期同步榜单数据 2026-10-06 20:06:37 +08:00
AxTps 664d2a39cf debug: HUD加诊断日志 + 改为右侧居中 2026-10-06 20:03:18 +08:00
AxTps 99b431145f fix: 修复CustomPacketPayload.createType导致的启动崩溃
createType(String)的参数是纯路径不能含冒号,改用new Type(Identifier.fromNamespaceAndPath(namespace,path))。
2026-10-06 19:58:42 +08:00
AxTps 3fde7e2c1b feat: 加slsBoardEnabled规则作榜单总开关(服务端规则控制客户端命令)
BoardTogglePayload同步开关状态;客户端/slsboard检查enabled,未开启则拒绝。ServerMain加轮询线程检测规则变化。
2026-10-06 19:49:26 +08:00
AxTps 7366a8b244 feat: 玩家加入时同步榜单数据(ServerPlayConnectionEvents.JOIN) 2026-10-06 19:39:35 +08:00
AxTps 9e32c4dbfa fix: 客户端命令类名改用ClientCommands(26.1.2无ClientCommandManager) 2026-10-06 19:37:52 +08:00
AxTps fa526b0839 fix: 客户端命令改用ClientCommandManager(FabricClientCommandSource) 2026-10-06 19:36:33 +08:00
AxTps ac6cd5c1b5 feat: 榜单客户端(接收包+/slsboard命令+右侧HUD)
BoardClient注册客户端入口:接收BoardSyncPayload、/slsboard deaths/mined/off切换显示、HudElementRegistry注册右侧HUD。各玩家本地状态独立,不同步。
2026-10-06 19:34:48 +08:00
AxTps f63a59495e fix: PayloadTypeRegistry改用clientboundPlay()注册 2026-10-06 19:27:35 +08:00
AxTps fba85271f4 feat: 榜单同步服务端(读stats+网络包下发)
BoardSyncPayload自定义包,BoardSyncManager读原版stats(挖掘总数/死亡数)构建Top10排行。顺带补回之前漏掉的BotListManager.load()。
2026-10-06 19:22:34 +08:00
AxTps 993001c4ef chore: 版本号升至0.24.0 2026-10-06 06:24:16 +08:00
AxTps 9e03c076ae fix: 载具堆叠改为Slot层,仅玩家背包可叠
删除全局ItemInstanceMixin(会让所有容器都叠)。新增SlotMixin:仅当container是玩家Inventory且物品是矿车/船时返回64。
2026-10-05 19:23:34 +08:00
AxTps c647189f77 fix: 修ItemInstanceMixin的instanceof编译错误(用(Object)强转) 2026-10-05 19:19:18 +08:00
AxTps 022b2144d3 feat: 新增载具可堆叠规则(矿车/船堆叠至64)
mixin ItemInstance.getMaxStackSize,规则开启时矿车/船返回64,实现自动堆叠。新增item mixin分组。
2026-10-05 19:11:12 +08:00
19 changed files with 421 additions and 20 deletions

No files matched your search

+6 -6
View File
@@ -5,13 +5,13 @@ org.gradle.configuration-cache=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=26.1.2
loader_version=0.19.5
loom_version=1.18-SNAPSHOT
minecraft_version=26.4-snapshot-4
loader_version=0.20.0
loom_version=1.19-SNAPSHOT
# Mod Properties
mod_version = 0.23
mod_version = 0.26.0-26.4
maven_group = com.github.zly2006
archives_base_name = carpet-sls-addition
# Dependencies
fabric_version=0.155.3+26.1.2
carpet_core_version=26.1+v260401
fabric_version=0.163.0+26.4
carpet_core_version=26.4-beta-3+v261013
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
@@ -77,4 +77,13 @@ public class SLSCarpetSettings {
@Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean unbreakableDecoratedPot = false;
@Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean stackableVehicles = false;
@Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean slsBoardEnabled = false;
@Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean noBrittleIceFromFlowingWater = false;
}
@@ -43,6 +43,13 @@ public class ServerMain implements ModInitializer, CarpetExtension {
LOGGER.info("[SLSA] onInitialize: managing Carpet extension");
INSTANCE = this;
CarpetServer.manageExtension(this);
com.github.zly2006.carpetslsaddition.net.BoardRequestPayload.register();
// 客户端请求显示榜单 → 给该玩家单独发 display 包
net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.registerGlobalReceiver(
com.github.zly2006.carpetslsaddition.net.BoardRequestPayload.TYPE,
(payload, context) -> context.server().execute(() ->
com.github.zly2006.carpetslsaddition.util.BoardManager.onClientRequest(
context.player(), payload.objectiveName())));
}
@Override
@@ -53,6 +60,32 @@ public class ServerMain implements ModInitializer, CarpetExtension {
@Override
public void onServerLoaded(MinecraftServer server) {
ServerMain.server = server;
com.github.zly2006.carpetslsaddition.util.BotListManager.load();
startBoardWatcher(server);
}
/** 服务器完全启动后创建 objective(此时 scoreboard 已 load 完,避免重名崩溃)。 */
static {
net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.SERVER_STARTED.register(server ->
com.github.zly2006.carpetslsaddition.util.BoardManager.ensureObjectives(server));
}
/** 每秒检测 slsBoardEnabled 规则变化并同步给客户端。 */
private void startBoardWatcher(MinecraftServer server) {
Thread t = new Thread(() -> {
while (!Thread.currentThread().isInterrupted()) {
try {
com.github.zly2006.carpetslsaddition.util.BoardManager.syncScores(server);
Thread.sleep(1000L);
} catch (InterruptedException e) {
return;
} catch (Throwable ex) {
LOGGER.debug("[SLSA] board watcher error: {}", ex.toString());
}
}
}, "SLSA-BoardWatcher");
t.setDaemon(true);
t.start();
}
@Override
@@ -0,0 +1,49 @@
package com.github.zly2006.carpetslsaddition.client;
import com.github.zly2006.carpetslsaddition.net.BoardRequestPayload;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.command.v2.ClientCommands;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.Component;
/**
* 客户端入口:/slsboard 命令,请求服务端给自己显示某个榜单。
*
* <p>服务端收到请求后,给该玩家单独发 display 包,实现各玩家各自显示、互不影响。
* 数据由服务端从 stats 同步到 scoreboard objective(见 BoardManager)。
*/
@Environment(EnvType.CLIENT)
public class BoardClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommands.literal("slsboard")
.then(ClientCommands.literal("deaths").executes(c -> request(c.getSource(), "sls_deaths")))
.then(ClientCommands.literal("mined").executes(c -> request(c.getSource(), "sls_mined")))
.then(ClientCommands.literal("off").executes(c -> request(c.getSource(), "")))
.then(ClientCommands.argument("board", StringArgumentType.word())
.suggests((c, b) -> SharedSuggestionProvider.suggest(
new String[]{"deaths", "mined", "off"}, b))
.executes(c -> {
String v = StringArgumentType.getString(c, "board");
return request(c.getSource(), "off".equals(v) ? "" : "sls_" + v);
}))
);
});
}
private static int request(FabricClientCommandSource source, String objectiveName) {
ClientPlayNetworking.send(new BoardRequestPayload(objectiveName));
source.sendFeedback(Component.literal(
objectiveName.isEmpty() ? "[SLSA] 榜单已关闭" : "[SLSA] 请求显示:" + objectiveName));
return 1;
}
}
@@ -41,6 +41,7 @@ import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.CommonListenerCookie;
import net.minecraft.server.network.ClientDebugInfo;
import net.minecraft.server.players.NameAndId;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.entity.ai.attributes.Attributes;
@@ -386,7 +387,7 @@ public class BotCommand {
EntityPlayerMPFake bot = constructor.newInstance(server, worldIn, gameprofile, ClientInformation.createDefault(), false);
bot.fixStartingPosition = () -> bot.snapTo(pos.x, pos.y, pos.z, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), bot, new CommonListenerCookie(gameprofile, 0, bot.clientInformation(), false));
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), bot, new CommonListenerCookie(gameprofile, 0, bot.clientInformation(), false, new ClientDebugInfo()));
bot.teleportTo(worldIn, pos.x, pos.y, pos.z, Set.of(), (float) yaw, (float) pitch, true);
bot.setHealth(20.0F);
@@ -0,0 +1,69 @@
package com.github.zly2006.carpetslsaddition.mixin.block;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
/**
* 26.4 快照加入的“碎冰”(Brittle Ice)机制:
* LiquidBlock#shouldSpreadLiquid 中,水流方块任意水平方向的邻居是蓝冰时,
* 会把当前水流方块替换为碎冰。
*
* 开启 noBrittleIceFromFlowingWater 规则后:
* 只有「水源方块」贴蓝冰时照常变碎冰;所有「流动的水」(横向、下落)都不再变碎冰,
* 且水流扩散不受影响。
*
* 实现:原版判断邻居是不是蓝冰用 BlockState#is(Blocks.BLUE_ICE),一旦命中就
* 变碎冰并 return false(中断扩散)。本 mixin 让流动水贴蓝冰时这次 is() 返回 false,
* 整个“变碎冰”分支被跳过,shouldSpreadLiquid 正常返回 true,水流照常扩散。
* 位置信息通过 ThreadLocal 从方法入口传入。
*/
@Mixin(LiquidBlock.class)
public class MixinFlowingWaterBrittleIce {
@Unique
private static final ThreadLocal<Level> CURRENT_LEVEL = new ThreadLocal<>();
@Unique
private static final ThreadLocal<BlockPos> CURRENT_POS = new ThreadLocal<>();
@Inject(method = "shouldSpreadLiquid", at = @At("HEAD"))
private void captureArgs(Level level, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir) {
CURRENT_LEVEL.set(level);
CURRENT_POS.set(pos);
}
@WrapOperation(
method = "shouldSpreadLiquid",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Ljava/lang/Object;)Z")
)
private boolean wrapIsBlueIce(BlockState instance, Object target, Operation<Boolean> original) {
Boolean result = original.call(instance, target);
if (!result) return false;
// 只有判断目标确实是 BLUE_ICE 时才可能干预
if (!(target instanceof net.minecraft.world.level.block.Block b) || !b.equals(Blocks.BLUE_ICE)) {
return true;
}
if (!SLSCarpetSettings.noBrittleIceFromFlowingWater) return true;
Level level = CURRENT_LEVEL.get();
BlockPos pos = CURRENT_POS.get();
if (level == null || pos == null) return true;
FluidState current = level.getFluidState(pos);
// 流动水(非水源)不让它触发碎冰替换
if (!current.isSource()) {
return false;
}
return true;
}
}
@@ -3,13 +3,13 @@ package com.github.zly2006.carpetslsaddition.mixin.block;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RedStoneWireBlock;
import net.minecraft.world.level.block.RedstoneWireBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = RedStoneWireBlock.class, priority = 1)
@Mixin(value = RedstoneWireBlock.class, priority = 1)
public class MixinRedstoneWireBlock {
// oldRedstoneConnectionLogic:让红石能连到活板门上的红石线。
// 新版在 getConnectingSide 里用 `blockState.getBlock() instanceof TrapDoorBlock` 判断。
@@ -15,7 +15,7 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld;
import net.minecraft.world.level.block.state.pattern.BlockPattern;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.EndPodiumFeature;
import net.minecraft.world.level.dimension.end.EnderDragonFight;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
@@ -37,6 +37,9 @@ public class MixinEnderDragonFight {
@Shadow
private BlockPos exitPortalLocation;
@Shadow
private BlockPos origin;
@Unique
private int defaultChunkX = -8;
@Unique
@@ -79,13 +82,13 @@ public class MixinEnderDragonFight {
if (SLSCarpetSettings.optimizedOnDragonRespawn && defaultOriginY != -1) {
i = defaultOriginY;
} else {
i = this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(BlockPos.ZERO).getX(), EndPodiumFeature.getLocation(BlockPos.ZERO).getZ());
i = this.level.getHeight(Heightmap.Types.MOTION_BLOCKING, EnderDragonFight.getPodiumLocation(this.origin).getX(), EnderDragonFight.getPodiumLocation(this.origin).getZ());
}
boolean notFirstSearch = false;
for (j = i; j >= 0; --j) {
BlockPattern.BlockPatternMatch result2;
BlockPos origin = EndPodiumFeature.getLocation(BlockPos.ZERO);
BlockPos searchPos = new BlockPos(origin.getX(), j, origin.getZ());
BlockPos podiumPos = EnderDragonFight.getPodiumLocation(this.origin);
BlockPos searchPos = new BlockPos(podiumPos.getX(), j, podiumPos.getZ());
if (SLSCarpetSettings.optimizedOnDragonRespawn && notFirstSearch) {
result2 = partialSearchAround(this.exitPortalPattern, this.level, searchPos);
} else {
@@ -0,0 +1,45 @@
package com.github.zly2006.carpetslsaddition.mixin.item;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.BoatItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MinecartItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
/**
* 载具堆叠(仅玩家背包):矿车/船在【玩家背包】内可堆叠到 64,其他容器不堆叠。
*
* <p>原理:{@code Slot.getMaxStackSize(ItemStack)} = min(容器上限, 物品上限)。
* 载具的物品上限全局为 1(默认不叠)。本 mixin 在【容器是玩家背包 Inventory】且物品是载具时,
* 直接返回 64,绕过 min 限制。
*
* <p>这样只有玩家背包(物品栏 36 格)内能叠,箱子/漏斗/潜影盒等其他容器不受影响。
*/
@Mixin(Slot.class)
public abstract class SlotMixin {
@Inject(method = "getMaxStackSize(Lnet/minecraft/world/item/ItemStack;)I", at = @At("HEAD"), cancellable = true)
private void stackableVehiclesInPlayerInventory(ItemStack stack, CallbackInfoReturnable<Integer> cir) {
if (!SLSCarpetSettings.stackableVehicles) {
return;
}
if (stack == null || stack.isEmpty()) {
return;
}
Slot self = (Slot) (Object) this;
// 仅玩家背包
if (!(self.container instanceof Inventory)) {
return;
}
Item item = stack.getItem();
if (item instanceof MinecartItem || item instanceof BoatItem) {
cir.setReturnValue(64);
}
}
}
@@ -3,6 +3,7 @@ package com.github.zly2006.carpetslsaddition.mixin.world;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.NaturalSpawner;
import org.spongepowered.asm.mixin.Mixin;
@@ -16,7 +17,7 @@ public class MixinSpawnHelper {
// 改为在 getMobForSpawn 返回处拦截。
@Inject(method = "getMobForSpawn", at = @At("HEAD"), cancellable = true)
private static void onCreateMob(ServerLevel level, EntityType<?> type, CallbackInfoReturnable<Mob> cir) {
if (SLSCarpetSettings.noBatSpawning && type == EntityType.BAT) {
if (SLSCarpetSettings.noBatSpawning && type == EntityTypes.BAT) {
cir.setReturnValue(null);
}
}
@@ -0,0 +1,35 @@
package com.github.zly2006.carpetslsaddition.net;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.Identifier;
/**
* 客户端 → 服务端:请求显示某个榜单(或关闭)。
*
* <p>服务端收到后,给该玩家单独发送 {@code ClientboundSetDisplayObjectivePacket},
* 实现"各玩家各自显示、互不影响"。
*
* <p>{@code objectiveName} 为空字符串表示关闭。
*/
public record BoardRequestPayload(String objectiveName) implements CustomPacketPayload {
public static final CustomPacketPayload.Type<BoardRequestPayload> TYPE =
new CustomPacketPayload.Type<>(Identifier.fromNamespaceAndPath("slsa", "board_request"));
public static final StreamCodec<RegistryFriendlyByteBuf, BoardRequestPayload> CODEC = StreamCodec.composite(
ByteBufCodecs.STRING_UTF8, BoardRequestPayload::objectiveName,
BoardRequestPayload::new
);
@Override
public CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
return TYPE;
}
public static void register() {
net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry.serverboundPlay().register(TYPE, CODEC);
}
}
@@ -0,0 +1,127 @@
package com.github.zly2006.carpetslsaddition.util;
import com.github.zly2006.carpetslsaddition.ServerMain;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.ServerStatsCounter;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.ScoreAccess;
import net.minecraft.world.scores.ScoreHolder;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
/**
* 死亡榜 / 挖掘榜的 scoreboard 管理器(服务端)。
*
* <p>数据源是 vanilla stats,但 stats 不会自动同步给其他客户端。
* 因此本类定期把 stats 的聚合值写入 scoreboard objective,
* 客户端再用原版计分板侧边栏显示(scoreboard 会自动同步给所有客户端)。
*
* <ul>
* <li>{@code sls_deaths}:死亡次数(DUMMY 判据,从 stats 的 {@link Stats#DEATHS} 写入)。</li>
* <li>{@code sls_mined}:挖掘总数(DUMMY 判据,从 stats 的 {@link Stats#BLOCK_MINED} 聚合)。</li>
* </ul>
*/
public final class BoardManager {
private BoardManager() {}
public static final String OBJ_DEATHS = "sls_deaths";
public static final String OBJ_MINED = "sls_mined";
/** 确保两个 objective 存在(服务器启动/重载时调用)。 */
public static void ensureObjectives(MinecraftServer server) {
Scoreboard sb = server.getScoreboard();
ServerMain.LOGGER.info("[SLSA] ensureObjectives called, deaths={} mined={}",
sb.getObjective(OBJ_DEATHS) != null, sb.getObjective(OBJ_MINED) != null);
if (sb.getObjective(OBJ_DEATHS) == null) {
sb.addObjective(OBJ_DEATHS, ObjectiveCriteria.DUMMY,
Component.literal("死亡榜"), ObjectiveCriteria.RenderType.INTEGER, true, null);
ServerMain.LOGGER.info("[SLSA] created scoreboard objective {}", OBJ_DEATHS);
}
if (sb.getObjective(OBJ_MINED) == null) {
sb.addObjective(OBJ_MINED, ObjectiveCriteria.DUMMY,
Component.literal("挖掘榜"), ObjectiveCriteria.RenderType.INTEGER, true, null);
ServerMain.LOGGER.info("[SLSA] created scoreboard objective {}", OBJ_MINED);
}
// 让客户端能收到这两个 objective(load 进来的 objective 可能未被追踪)
if (sb instanceof net.minecraft.server.ServerScoreboard ssb) {
Objective d = sb.getObjective(OBJ_DEATHS);
if (d != null) ssb.startTrackingObjective(d);
Objective m = sb.getObjective(OBJ_MINED);
if (m != null) ssb.startTrackingObjective(m);
}
}
/** 读取某玩家的挖掘总数(遍历 stats map 中 BLOCK_MINED 类型条目)。 */
private static int totalMined(ServerStatsCounter counter) {
int sum = 0;
for (Stat<?> stat : counter.stats.keySet()) {
if (stat.getType() == Stats.BLOCK_MINED) {
sum += counter.getValue(stat);
}
}
return sum;
}
/** 读取某玩家的死亡次数。 */
private static int totalDeaths(ServerStatsCounter counter) {
return counter.getValue(Stats.CUSTOM, Stats.DEATHS);
}
/** 把一个分数写入 objective(若不存在则创建/更新)。 */
private static void setScore(Scoreboard sb, Objective obj, ServerPlayer player, int value) {
if (obj == null) {
return;
}
ScoreAccess access = sb.getOrCreatePlayerScore((ScoreHolder) player, obj);
access.set(value);
}
/** 从 stats 同步所有在线玩家的分数到 scoreboard(定期调用)。 */
public static void syncScores(MinecraftServer server) {
Scoreboard sb = server.getScoreboard();
Objective deaths = sb.getObjective(OBJ_DEATHS);
Objective mined = sb.getObjective(OBJ_MINED);
if (deaths == null && mined == null) {
return;
}
for (ServerPlayer player : server.getPlayerList().getPlayers()) {
ServerStatsCounter counter = player.getStats();
setScore(sb, deaths, player, totalDeaths(counter));
setScore(sb, mined, player, totalMined(counter));
}
}
/** 客户端请求显示某榜单 → 给该玩家单独发 display 包(不影响其他玩家)。 */
public static void onClientRequest(ServerPlayer player, String objectiveName) {
MinecraftServer server = ServerMain.server;
if (server == null) {
return;
}
Objective obj = objectiveName == null || objectiveName.isEmpty()
? null
: server.getScoreboard().getObjective(objectiveName);
// 干净重建客户端该 objective:先 REMOVE(客户端没有则忽略),再 ADD + 分数包
if (obj != null) {
player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetObjectivePacket(
obj, net.minecraft.network.protocol.game.ClientboundSetObjectivePacket.METHOD_REMOVE));
player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetObjectivePacket(
obj, net.minecraft.network.protocol.game.ClientboundSetObjectivePacket.METHOD_ADD));
if (server.getScoreboard() instanceof net.minecraft.server.ServerScoreboard ssb) {
for (var pkt : ssb.getStartTrackingPackets(obj)) {
if (pkt instanceof net.minecraft.network.protocol.game.ClientboundSetScorePacket) {
player.connection.send(pkt);
}
}
}
}
// 发 display 包(slot=SIDEBAR,objective 可为 null 表示清除)
player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetDisplayObjectivePacket(
net.minecraft.world.scores.DisplaySlot.SIDEBAR, obj));
}
}
@@ -23,7 +23,7 @@ public class ShulkerBoxItemUtil {
if (itemStack.getItem() instanceof BlockItem blockItem
&& blockItem.getBlock() instanceof ShulkerBoxBlock) {
return itemStack.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY)
.allItemsCopyStream().findAny().isEmpty();
.nonEmptyItemCopyStream().findAny().isEmpty();
}
return false;
}
@@ -48,7 +48,7 @@
"carpet.rule.elytraCraftable.desc": "Make elytra craftable for Minecraft 1.20.6+ (eltra wont disappear when crafting)",
"carpet.rule.botMaxOnlineTime.desc": "Set the maximum living time of the bot which create by carpet sls addition.",
"carpet.rule.spectatorCannotUseLeash.desc": "If a player is a spectator, they cannot use the leash.",
"carpet.rule.offlineFakePlayers.desc": "假人强制离线uuid",
"carpet.rule.offlineFakePlayers.desc": "Force fake players to use offline UUIDs",
"carpet.rule.armadilloImmediateDespawns.desc": "Armadillos will despawn immediately if they are 128 blocks away from the player.",
"carpet.rule.turtleLocalNesting.name": "Turtle Local Nesting",
"carpet.rule.turtleLocalNesting.desc": "Turtles carrying eggs will lay them on reachable sand near the closest local water source instead of returning to their birthplace.",
@@ -72,5 +72,16 @@
"carpet.slsa.bot.respawned": "The bot %s's online time has been reset.",
"carpet.slsa.bot.not_a_bot": "The player %s is not created by carpet sls addition, so you can't reset the online time.",
"carpet.slsa.block.deep_slate_core": "Deepslate Core"
"carpet.slsa.block.deep_slate_core": "Deepslate Core",
"carpet.rule.stackableVehicles.name": "Stackable vehicles",
"carpet.rule.stackableVehicles.desc": "Minecarts and boats can stack up to 64, auto-merging on pickup",
"carpet.rule.slsBoardEnabled.name": "Enable boards",
"carpet.rule.slsBoardEnabled.desc": "Allow players to use /slsboard to show death/mining leaderboards",
"carpet.rule.noBrittleIceFromFlowingWater.name": "No brittle ice from flowing water",
"carpet.rule.noBrittleIceFromFlowingWater.desc": "Only water flowing straight down onto blue ice forms brittle ice. Horizontally flowing water will not.",
"carpet.rule.elytraCraftable.name": "Craftable elytra",
"carpet.rule.armadilloImmediateDespawns.name": "Armadillos despawn immediately",
"carpet.rule.offlineFakePlayers.name": "Force offline UUID for fake players",
"carpet.rule.netherPortalSize.name": "Max nether portal size",
"carpet.rule.trialSpawnerCD.name": "Trial spawner cooldown"
}
@@ -72,5 +72,16 @@
"carpet.slsa.bot.respawned": "假人%s的在线时长已重置!",
"carpet.slsa.bot.not_a_bot": "假人%s不是由Carpet SLS Addition生成的,所以你不能重置它的在线时间!",
"carpet.slsa.block.deep_slate_core": "深板岩核心"
"carpet.slsa.block.deep_slate_core": "深板岩核心",
"carpet.rule.stackableVehicles.name": "载具可堆叠",
"carpet.rule.stackableVehicles.desc": "矿车和船的物品可以堆叠到64,拾取时自动合并",
"carpet.rule.slsBoardEnabled.name": "启用榜单",
"carpet.rule.slsBoardEnabled.desc": "允许玩家用 /slsboard 显示死亡榜/挖掘榜",
"carpet.rule.noBrittleIceFromFlowingWater.name": "横向流动水不产生碎冰",
"carpet.rule.noBrittleIceFromFlowingWater.desc": "只有竖直向下的水流接触蓝冰时才会产生碎冰,横向流动的水不再转化",
"carpet.rule.elytraCraftable.name": "鞘翅可合成",
"carpet.rule.armadilloImmediateDespawns.name": "犰狳立即消失",
"carpet.rule.offlineFakePlayers.name": "假人强制离线UUID",
"carpet.rule.netherPortalSize.name": "地狱门最大尺寸",
"carpet.rule.trialSpawnerCD.name": "试炼刷怪笼冷却"
}
+3
View File
@@ -19,6 +19,9 @@
"entrypoints": {
"main": [
"com.github.zly2006.carpetslsaddition.ServerMain"
],
"client": [
"com.github.zly2006.carpetslsaddition.client.BoardClient"
]
},
"accessWidener": "slsa.accesswidener",
+3 -1
View File
@@ -1,6 +1,8 @@
accessWidener v1 official
accessible class net/minecraft/world/entity/monster/EnderMan$EndermanTakeBlockGoal
accessible class net/minecraft/world/entity/monster/Enderman$EndermanTakeBlockGoal
accessible method net/minecraft/world/entity/Entity unsetRemoved ()V
accessible field net/minecraft/world/entity/Entity entityData Lnet/minecraft/network/syncher/SynchedEntityData;
accessible field net/minecraft/world/entity/Avatar DATA_PLAYER_MODE_CUSTOMISATION Lnet/minecraft/network/syncher/EntityDataAccessor;
accessible field net/minecraft/stats/StatsCounter stats Lit/unimi/dsi/fastutil/objects/Object2IntMap;
@@ -12,6 +12,8 @@
"block.MixinDecoratedPotBlock",
"block.MixinTrialSpawnerData",
"block.MixinTrialSpawnerState",
"block.MixinFlowingWaterBrittleIce",
"item.SlotMixin",
"carpet.MixinEntityPlayerMPFake",
"carpet.MixinPlayerCommand",
"elytra.ItemAccessor",