汤锅功能实现 5 计时 提示修改 蔬菜鱼片汤补充 锅铲添油实现
This commit is contained in:
1 parent
31bb44a409
commit
c342dcc93d
12 files changed
+585
-395
No files matched your search
+127
-5
@@ -48,6 +48,7 @@ from ..ChujuData import (
|
||||
BOWL_ITEM, PLATE_ITEM, CREAM_ITEM, EGG_CUSTARD_ITEM, BEATER_BLOCKS,
|
||||
SOYBEAN_ITEM, SOYBEAN_COUNT, STONEMILL_GRIND_COUNT,
|
||||
GLASS_TANK_ITEM, OIL_CAN_ITEM, STEAMER_RULES,
|
||||
SPATULA, SPATULA_OIL, WOK, OIL_PAN, OIL_CAN_USES,
|
||||
)
|
||||
|
||||
# ---- 统一分发器 ----
|
||||
@@ -82,7 +83,8 @@ class ChujuService(BlueFoxServerSystem):
|
||||
# ---- 空手右键"丸子机计时源"(meatballmaker_3/4): 放在点燃炉灶上 -> 开始计时 ----
|
||||
# 提示包含"总共多少秒": _3(加料完成) 半熟30秒+熟30秒=60秒; _4(半熟) 剩30秒
|
||||
self.timerSources = set()
|
||||
self.startTimerTips = {}
|
||||
self.startTimerTips = {} # 空手右键启动计时 -> 提示(含总共多少秒)
|
||||
self.timingTips = {} # 空手右键"已在计时中" -> 提示(同样含总共多少秒)
|
||||
for r in MEATBALL_TIMERS:
|
||||
src = r["source"]
|
||||
self.timerSources.add(src)
|
||||
@@ -91,8 +93,10 @@ class ChujuService(BlueFoxServerSystem):
|
||||
sec = r.get("time", 60)
|
||||
if src == "rtdd:meatballmaker_3":
|
||||
self.startTimerTips[src] = "§a开始烹制…共需计时60秒(半熟30秒+熟30秒); 计时结束变成 章鱼小丸子"
|
||||
self.timingTips[src] = "§e正在烹制中…共需计时60秒(半熟30秒+熟30秒), 计时结束变成 章鱼小丸子"
|
||||
else:
|
||||
self.startTimerTips[src] = "§a开始烹制…共需计时%d秒; 计时结束变成 章鱼小丸子" % sec
|
||||
self.timingTips[src] = "§e正在烹制中…共需计时%d秒, 计时结束变成 章鱼小丸子" % sec
|
||||
|
||||
# ---- 右键冷却表 ----
|
||||
self.cooldown = {}
|
||||
@@ -109,8 +113,38 @@ class ChujuService(BlueFoxServerSystem):
|
||||
return self.featureBlocks
|
||||
|
||||
def getItemUseOnRules(self):
|
||||
"""手持物品右键方块表面不需要单独路由, 返回空"""
|
||||
return {}
|
||||
"""手持物品右键方块表面路由: 锅铲/带油锅铲 右键 油罐/炒锅 (蘸油/还油/上油)"""
|
||||
return {SPATULA: True, SPATULA_OIL: True}
|
||||
|
||||
def handleItemUseOn(self, args):
|
||||
"""手持 锅铲/带油锅铲 右键 方块表面:
|
||||
19. 锅铲(spatula) 右键油罐(oilcan) -> 变带油锅铲(附魔光效), 油罐次数-1(用完变玻璃罐)
|
||||
19a. 带油锅铲 右键油罐 -> 变回锅铲, 油罐次数+1
|
||||
20. 带油锅铲 右键炒锅(wok) -> 炒锅变炒锅(添油)(oilpan), 油铲变回锅铲
|
||||
物品形态变化直接替换手持物品(不掉落物)。
|
||||
返回 True=处理了; False=不属本功能管(交还默认行为)。"""
|
||||
itemName = args.get("itemName")
|
||||
playerId = args.get("playerId") or args.get("entityId")
|
||||
x, y, z = args.get("x"), args.get("y"), args.get("z")
|
||||
pos = (x, y, z)
|
||||
dim = comp.CreateDimension(playerId).GetEntityDimensionId()
|
||||
key = (dim, x, y, z)
|
||||
try:
|
||||
b = comp.CreateBlockInfo(LevelId).GetBlockNew(pos, dim)
|
||||
clickedName = b.get("name") if b else None
|
||||
except Exception:
|
||||
clickedName = None
|
||||
|
||||
# 19: 锅铲 蘸油罐
|
||||
if itemName == SPATULA and clickedName == OIL_CAN_ITEM:
|
||||
return self._dipOil(playerId, key, dim, pos)
|
||||
# 19a: 带油锅铲 还油罐
|
||||
if itemName == SPATULA_OIL and clickedName == OIL_CAN_ITEM:
|
||||
return self._returnOil(playerId, key, dim, pos)
|
||||
# 20: 带油锅铲 给炒锅上油
|
||||
if itemName == SPATULA_OIL and clickedName == WOK:
|
||||
return self._oilWok(playerId, key, dim, pos)
|
||||
return False
|
||||
|
||||
def handleBlockUse(self, args):
|
||||
"""
|
||||
@@ -157,13 +191,101 @@ class ChujuService(BlueFoxServerSystem):
|
||||
self.handleSwitch(recipe, playerId, pos, dim, itemDict, key)
|
||||
return True
|
||||
|
||||
def _dipOil(self, playerId, key, dim, pos):
|
||||
"""19. 锅铲蘸油罐: 变带油锅铲(附魔光效), 油罐次数-1; 用完(0次)油罐变玻璃罐"""
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
uses = self._readOilUses(dim, pos)
|
||||
if uses <= 0:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(playerId, "§c油罐没油了, 无法蘸油")
|
||||
return True
|
||||
self._setCarriedItem(playerId, SPATULA_OIL, True) # 替换手持为带油锅铲(附魔光效)
|
||||
uses -= 1
|
||||
if uses <= 0:
|
||||
self._clearOilUses(dim, pos)
|
||||
self.replaceBlock(pos, dim, GLASS_TANK_ITEM, playerId) # 油罐用完变玻璃罐
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, "§a锅铲蘸了油, 变成带油锅铲; 油罐用完了, 变成了玻璃罐")
|
||||
else:
|
||||
self._writeOilUses(dim, pos, uses)
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, "§a锅铲蘸了油, 变成带油锅铲; 油罐剩余 %d 次" % uses)
|
||||
return True
|
||||
|
||||
def _returnOil(self, playerId, key, dim, pos):
|
||||
"""19a. 带油锅铲还油罐: 变回锅铲, 油罐次数+1"""
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
uses = self._readOilUses(dim, pos)
|
||||
if uses >= OIL_CAN_USES:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(playerId, "§e油罐是满的, 不用还油")
|
||||
return True
|
||||
self._setCarriedItem(playerId, SPATULA, False) # 替换手持为锅铲(去附魔)
|
||||
uses += 1
|
||||
self._writeOilUses(dim, pos, uses)
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, "§a油还回油罐, 变回锅铲; 油罐剩余 %d 次" % uses)
|
||||
return True
|
||||
|
||||
def _oilWok(self, playerId, key, dim, pos):
|
||||
"""20. 带油锅铲给炒锅上油: 炒锅变炒锅(添油), 油铲变回锅铲(不消耗油铲)"""
|
||||
if not self.checkCooldown(key, 0.4):
|
||||
return True
|
||||
self._setCarriedItem(playerId, SPATULA, False) # 替换手持为锅铲
|
||||
self.replaceBlock(pos, dim, OIL_PAN, playerId)
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, "§a炒锅添了油, 变成 炒锅(添油); 带油锅铲变回锅铲")
|
||||
return True
|
||||
|
||||
def _setCarriedItem(self, playerId, itemName, enchanted):
|
||||
"""直接替换玩家手持物品(不掉落物); 带油锅铲时附加魔光效(效率I)"""
|
||||
itemDict = {"itemName": itemName, "count": 1, "auxValue": 0}
|
||||
if enchanted:
|
||||
itemDict["userData"] = {"ench": [
|
||||
{"id": {"__type__": 2, "__value__": 15},
|
||||
"lvl": {"__type__": 2, "__value__": 1},
|
||||
"modEnchant": {"__type__": 8, "__value__": ""}},
|
||||
]}
|
||||
comp.CreateItem(playerId).SetEntityItem(
|
||||
serverApi.GetMinecraftEnum().ItemPosType.CARRIED, itemDict)
|
||||
|
||||
def _readOilUses(self, dim, pos):
|
||||
"""油罐方块剩余次数(未记录过/新放置 = 满16次)"""
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data is None:
|
||||
return OIL_CAN_USES
|
||||
v = data["rtdd_oc"]
|
||||
if v is None:
|
||||
return OIL_CAN_USES
|
||||
return int(v)
|
||||
except Exception:
|
||||
return OIL_CAN_USES
|
||||
|
||||
def _writeOilUses(self, dim, pos, uses):
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data is not None:
|
||||
data["rtdd_oc"] = int(uses)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _clearOilUses(self, dim, pos):
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data is not None:
|
||||
data["rtdd_oc"] = 0
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _handleStartTimer(self, blockName, playerId, pos, dim):
|
||||
"""空手右键丸子机计时源(meatballmaker_3/4): 已在计时中 -> 提示;
|
||||
"""空手右键丸子机计时源(meatballmaker_3/4): 已在计时中 -> 提示总时长;
|
||||
否则转发计时服务开始(下方需点燃的炉灶 stove_2)"""
|
||||
try:
|
||||
data = blockEntityDataComp.GetBlockEntityData(dim, pos)
|
||||
if data and data["rtdd_tid"] == blockName:
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(playerId, "§e已经在计时中")
|
||||
comp.CreateMsg(playerId).NotifyOneMessage(
|
||||
playerId, self.timingTips.get(blockName, "§e已经在计时中"))
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in new issue
Block a user