死亡 生成 黄豆获取1

This commit is contained in:
wenhe committed 2026-09-24 12:53:16 +08:00
1 parent faa3a22631
commit 104603fd64
6 files changed
+654 -2

No files matched your search

@@ -107,4 +107,14 @@ DESTROY_DROP = {
"rtdd:cutscallions_2": "rtdd:scallions",
"rtdd:cutscallions_3": "rtdd:scallions",
"rtdd:cutscallions_4": "rtdd:scallions",
}
# ---- 打碎草/杂草 概率获得黄豆(和黄原版打草掉小麦种子一样, ~14%) ----
# 黄豆物品与石磨(CHUJU)共用同一物品 rtndd:soybean
SOYBEAN_ITEM = "rtdd:soybean" # 黄豆(与石磨同物品, 见 ChujuData)
GRASS_DROP_CHANCE = 0.15 # 打草掉黄豆概率(参照原版小麦种子)
GRASS_BLOCKS = { # 草/杂草方块(网易 tallgrass 含 aux 变体)
"minecraft:tallgrass",
"minecraft:short_grass",
"minecraft:double_plant",
}
@@ -21,6 +21,7 @@
================================================================================
"""
import time
import random
import mod.server.extraServerApi as serverApi
# ---- 网易API基础对象 ----
@@ -36,6 +37,7 @@ from ..ShicaiData import (
CLEAVER_ITEM, CHOP_CHAINS, GARLIC_BLOCK, GARLIC_CHOP_COUNT,
GARLIC_DROP, FLOUR_BLOCK, COATING_RULES, DESTROY_DROP,
MEAT_PRESS_RULES,
SOYBEAN_ITEM, GRASS_DROP_CHANCE, GRASS_BLOCKS,
)
# ---- 统一分发器 ----
@@ -87,6 +89,8 @@ class ShicaiService(BlueFoxServerSystem):
# ---- 注册到统一分发器 ----
FeatureDispatcher.register(self)
# 打碎草掉黄豆: 把本服务的草掉落逻辑挂到分发器的破坏方块路由上
FeatureDispatcher.registerGrassDrop(self)
# ============================================================================
# 一、给 FeatureDispatcher 的接口
@@ -161,6 +165,29 @@ class ShicaiService(BlueFoxServerSystem):
pass
return True
def handleGrassDrop(self, args):
"""由 FeatureDispatcher 破坏方块路由调用的"打草掉黄豆"。
被破坏方块是草/杂草时, 按 GRASS_DROP_CHANCE 概率掉 1 个黄豆掉落物。
只产生掉落, 不取消破坏本身、不设 skip, 原版打草行为保持不变。
返回 True=已处理(是草); False=不属本功能(非草)。"""
blockName = args.get("fullName") or args.get("blockName")
if not blockName or blockName not in GRASS_BLOCKS:
return False
playerId = args.get("playerId")
if not playerId:
return True
# 概率掉落黄豆
if random.random() <= GRASS_DROP_CHANCE:
x, y, z = args.get("x"), args.get("y"), args.get("z")
dim = comp.CreateDimension(playerId).GetEntityDimensionId()
try:
self.CreateEngineItemEntity(
{"itemName": SOYBEAN_ITEM, "count": 1, "auxValue": 0},
dim, (x, y + 0.5, z))
except Exception:
pass
return True
def handleBlockUse(self, args):
"""由 FeatureDispatcher 转发的右键方块入口"""
blockName = args.get("blockName")