158 lines
4.5 KiB
Python
158 lines
4.5 KiB
Python
# coding=utf-8
|
|
import logging
|
|
|
|
import mod.client.extraClientApi as clientApi
|
|
import mod.server.extraServerApi as serverApi
|
|
|
|
if False:
|
|
pass
|
|
IsDebug = 1
|
|
|
|
|
|
def modDebug(msg):
|
|
"""输出debug信息"""
|
|
if IsDebug: logging.debug('[DN-MJ] {}'.format(msg))
|
|
|
|
|
|
def modInfo(msg):
|
|
"""输出信息Log"""
|
|
logging.info('[DN-MJ] {}'.format(msg))
|
|
|
|
|
|
def modWarning(msg):
|
|
"""输出警告Log"""
|
|
logging.warning('[DN-MJ] {}'.format(msg))
|
|
|
|
|
|
class ButtonTouchTypeEnum(object):
|
|
TouchDown = 0
|
|
TouchUp = 1
|
|
TouchCancel = 2
|
|
MoveOut = 3
|
|
|
|
|
|
class ItemOperate(object):
|
|
"""服务端操作用数据集"""
|
|
EXCHANGE_FLYING = 0
|
|
EXCHANGE = 1
|
|
MERGE = 2
|
|
DROP = 3
|
|
DROP_FLYING = 4
|
|
|
|
@staticmethod
|
|
def DropFlying():
|
|
"""
|
|
丢弃飞行物品
|
|
:return:
|
|
"""
|
|
return {'type': ItemOperate.DROP_FLYING}
|
|
|
|
@staticmethod
|
|
def ExchangeFlying(slot, slotName):
|
|
"""
|
|
和飞行物交换物品
|
|
:param slot: 槽位索引
|
|
:param slotName: 槽位名称
|
|
:return:
|
|
"""
|
|
return {
|
|
'slot': slot, 'slotName': slotName, 'type': ItemOperate.EXCHANGE_FLYING
|
|
}
|
|
|
|
@staticmethod
|
|
def Exchange(fromSlot, fromSlotName, toSlot, toSlotName):
|
|
"""
|
|
交换槽位物品
|
|
:param fromSlot: 交换起点槽位相对索引
|
|
:param fromSlotName: 交换起点槽位名称
|
|
:param toSlot:交换重点槽位相对索引
|
|
:param toSlotName:交换终点槽位名称
|
|
:return:
|
|
"""
|
|
return {
|
|
'fromSlot': fromSlot, 'fromSlotName': fromSlotName, 'toSlot': toSlot, 'toSlotName': toSlotName,
|
|
'type': ItemOperate.EXCHANGE
|
|
}
|
|
|
|
@staticmethod
|
|
def Drop(slot, slotName):
|
|
"""
|
|
丢弃槽位物品
|
|
:param slot:槽位相对索引
|
|
:param slotName:槽位名称
|
|
:return:
|
|
"""
|
|
return {
|
|
'slot': slot, 'slotName': slotName, 'type': ItemOperate.DROP
|
|
}
|
|
|
|
@staticmethod
|
|
def Merge(fromSlot, fromSlotName, toSlot, toSlotName):
|
|
"""
|
|
合并槽位物品
|
|
:param fromSlot: 合并起点槽位相对索引
|
|
:param fromSlotName: 合并起点槽位名称
|
|
:param toSlot:合并重点槽位相对索引
|
|
:param toSlotName:合并终点槽位名称
|
|
:return:
|
|
"""
|
|
return {
|
|
'fromSlot': fromSlot, 'fromSlotName': fromSlotName, 'toSlot': toSlot, 'toSlotName': toSlotName,
|
|
'type': ItemOperate.MERGE
|
|
}
|
|
|
|
|
|
class PlayerBehaviorTree(object):
|
|
Sleep = 0b00000001
|
|
Sprinting = 0b00000010
|
|
Sneaking = 0b00000100
|
|
Gliding = 0b00001000
|
|
Swimming = 0b00010000
|
|
Crawling = 0b00100000
|
|
Flying = 0b01000000
|
|
SpinAttack = 0b10000000
|
|
__pat = clientApi.GetMinecraftEnum().PlayerActionType
|
|
PlayerBehaviors = {
|
|
__pat.StartSleeping: (Sleep, True),
|
|
__pat.StopSleeping: (Sleep, False),
|
|
__pat.StartSprinting: (Sprinting, True),
|
|
__pat.StopSprinting: (Sprinting, False),
|
|
__pat.StartSneaking: (Sneaking, True),
|
|
__pat.StopSneaking: (Sneaking, False),
|
|
__pat.StartGliding: (Gliding, True),
|
|
__pat.StopGliding: (Gliding, False),
|
|
__pat.StartSwimming: (Swimming, True),
|
|
__pat.StopSwimming: (Swimming, False),
|
|
__pat.StartCrawling: (Crawling, True),
|
|
__pat.StopCrawling: (Crawling, False),
|
|
__pat.StartFlying: (Flying, True),
|
|
__pat.StopFlying: (Flying, False),
|
|
__pat.StartSpinAttack: (SpinAttack, True),
|
|
__pat.StopSpinAttack: (SpinAttack, False)
|
|
}
|
|
|
|
|
|
from .ModConfig import MOD_NAME, MOD_VERSION
|
|
|
|
LevelId = serverApi.GetLevelId() or clientApi.GetLevelId()
|
|
Platform = serverApi.GetPlatform() or clientApi.GetPlatform()
|
|
# Platform = 1 # 测试用
|
|
|
|
MC_SYSTEM_NAME = serverApi.GetEngineSystemName()
|
|
MC_SYSTEM_NAMESPACE = serverApi.GetEngineNamespace()
|
|
# ToolsConfig
|
|
CREATED_TOOLS = {}
|
|
CREATED_SCREEN_TOOLS = {}
|
|
# CompFactory
|
|
clientCompFactory = clientApi.GetEngineCompFactory()
|
|
serverCompFactory = serverApi.GetEngineCompFactory()
|
|
# System
|
|
serverBaseSystem = serverApi.GetServerSystemCls()
|
|
clientBaseSystem = clientApi.GetClientSystemCls()
|
|
# UI
|
|
if not serverApi.IsInServer():
|
|
bookManager = clientApi.GetBookManager()
|
|
nativeScreenManager = clientApi.GetNativeScreenManagerCls().instance() # type:clientApi.GetNativeScreenManagerCls()
|
|
viewBinder = clientApi.GetViewBinderCls()
|
|
baseScreen = clientApi.GetScreenNodeCls()
|
|
customUIScreenProxy = clientApi.GetUIScreenProxyCls() |