死亡 生成 黄豆获取1
This commit is contained in:
1 parent
faa3a22631
commit
104603fd64
6 files changed
+654
-2
No files matched your search
+27
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user