📔
TerraCraft
  • TerraCraft
  • English
    • Mod Document
      • Mod Dev Official Tutorial
      • Mod API Document
        • Data Types and Enums
        • JSON
        • Entity
        • NPC
  • 简体中文(旧版教程)
    • 模组文档
      • Engine API
        • App
        • AssetBundle
        • AtlasInfo
        • AtlasTextureManager
        • Audio
        • Bytes
        • File
        • GameObject
        • GlobalHook
        • Graphics
        • Hotfix
        • Image
        • ImageInfo
        • IntegratedClient : IntegratedEnv
        • IntegratedEnv
        • JsonUtil
        • Log
        • MathHelper
        • Matrix
        • Path
        • Random
        • Rect
        • Rigidbody
        • TextureLocation
        • TextureManager
        • Transform
        • Vector2
        • Vector3
        • Vector4
      • Game API
        • Attack
        • ArrayList<T>
        • EffectUtils
        • Entity
        • LightingUtils
        • ModNpc
        • ModProjectile
        • Npc : Entity
        • NpcUtils
        • Projectile : Entity
        • ProjectileUtils
        • Reg
        • SoundUtils
        • Utils
      • 模组API文档
        • 数据类型、枚举类型
        • JSON API
        • 引用API
        • 注册信息API
        • 语言API
        • 通用API
        • 物品API
        • 实体API
        • 特效API
        • 抛射物API
        • 状态效果API
        • 附魔API
        • 玩家API
        • NPC API
        • 骨骼模型API
        • 光照API
        • 音效API
        • 方块API
        • 方块实体API
        • 地图API
        • 渲染API
        • 指令API
        • 用户图形界面UI
        • 其他API
      • 模组开发官方教程
        • ExampleMod源代码仓库
        • 1.0 教程对应游戏版本(Indev 1.1)
        • 1.1 开始
        • 1.2 安装Visual Studio Code
        • 1.3 配置模组环境
        • 1.4 认识模组路径
        • 1.5 认识JSON数据表
        • 1.6 第一个物品
        • 1.7 认识地图元素
        • 1.8 第一个图块TODO
        • 1.9 第一个家具TODO
        • 1.10 加入合成表TODO
        • 未完待续……
      • 模组数据表文档
        • 基本JSON类型
        • 模组配置表(tcmod.json)
        • 物品表(contents/items/...)
        • 物品配置表
        • 弹药表(ammos.json)
        • 状态效果表(buffs.json)
        • 音效配置表(sound_config.json)
        • 音效表(sounds.json)
        • 背景表(backgrounds.json)
        • 皮肤表(skins.json)
        • 着色器表(shaders.json)
  • 新版教程
    • 1 基础部分
      • 1.1 安装集成开发环境
      • 1.2 获取TerraCraft源码
      • 1.3 认识Lua
      • 1.4 Mod架构
      • 1.5 游戏主生命周期和主状态机
      • 1.6 Lua实战
      • 1.7 第一个物品
      • 1.8 本地化翻译
      • 1.9 配方系统初探和矿物字典
Powered by GitBook
On this page
  • 杂项通用模块(MiscUtils)
  • 客户端通用变量
  • 通用函数

Was this helpful?

  1. 简体中文(旧版教程)
  2. 模组文档
  3. 模组API文档

其他API

杂项通用模块(MiscUtils)

客户端通用变量

变量名

类型

描述

MiscUtils.screenX

double

【只读】当前客户端屏幕左上角横坐标。

MiscUtils.screenY

double

【只读】当前客户端屏幕左上角纵坐标。

MiscUtils.screenWidth

int

【只读】当前客户端屏幕宽度(像素)。

MiscUtils.screenHeight

int

【只读】当前客户端屏幕高度(像素)。

通用函数

文本传输相关函数

注意:若使用了UTF8文本,请使用UTF8文本传输函数。

函数

返回值

描述

MiscUtils.Unicast(Player player, string message)

void

向指定玩家的客户端单播ASCII字符串。

MiscUtils.Broadcast(string message)

void

广播ASCII字符串到所有客户端。

MiscUtils.UnicastUTF8(Player player, string message)

void

向指定玩家的客户端单播UTF8字符串。

MiscUtils.BroadcastUTF8(string message)

void

广播UTF8字符串到所有客户端。

特殊效果相关函数

函数

返回值

描述

MiscUtils.RayDistance(double fromX, double fromY, double shootAngle, int maxDistance = 1000)

int

从一个点发射射线,返回碰到固体时射线经过的距离。maxDistance表示最远检测距离。

MiscUtils.RayReach(double fromX, double fromY, double toX, double toY)

bool

从一个点朝另外一个点发射射线,返回射线是否未与任何固体发生碰撞。

MiscUtils.CreateExplosion(int xi, int yi, double power, bool hurtNpc, bool hurtPlayer, bool killTiles = true, bool killWalls = false, bool makeSound = true, int tileLimit = -1)

void

在指定格子位置发生一个爆炸。power表示爆炸攻击力。hurtNpc表示是否对NPC有效。hurtPlayer表示是否对玩家有效。killTiles表示是否破坏前景。killWalls表示是否破坏背景墙。makeSound表示是否发出爆炸音效。tileLimit为正数时表示爆炸作用的最小方块硬度,为负数表示作用全部方块。

世界数据相关函数

函数

返回值

描述

MiscUtils.SetDayTime(int dayTime)

void

设置当日时间。一天的时间为0-86400,对应早上6:00到次日早上6:00。

MiscUtils.SetDayTimeFormat(int hours, int minutes, int seconds)

void

设置当日时间。hours表示小时数,minutes表示分钟数,seconds表示秒数。

MiscUtils.GetDayTime()

int

获取当日时间。

MiscUtils.GetDayTimeFormat()

int, int, int

获取当日时间,依次返回小时数、分钟数、秒数。

MiscUtils.SetDaySpeed(double daySpeed)

void

设置时间流逝速度比率。

MiscUtils.GetDaySpeed()

double

获取时间流逝速度比率。

MiscUtils.SetWeatherTime(int weatherTime)

void

设置天气事件进行时间。总时间为216000。

MiscUtils.GetWeatherTime()

int

获取天气事件进行时间。

服务端相关函数

函数

返回值

描述

MiscUtils.SaveAll()

void

立即保存全部数据。若服务端当前正在执行保存任务,则结束任务后立即执行当前请求。

MiscUtils.SetAutoSaveEnabled(bool enabled)

void

决定是否开启自动保存模式。enabled为true时开启自动保存,为false时关闭自动保存。

MiscUtils.GetAutoSaveEnabled()

bool

返回是否开启了自动保存模式。

MiscUtils.GetPortNumber()

int

返回服务器的端口号。如果是客户端调用,总是返回0。

MiscUtils.SetPVP(bool enabled)

void

决定是否开启玩家对战模式。enabled为true时开启玩家对战,为false时关闭玩家对战。

MiscUtils.GetPVP()

bool

返回是否开启了玩家对战模式。

MiscUtils.SetSafeBlow(bool enabled)

void

决定是否开启爆炸保护模式。enabled为true时开启爆炸保护模式,为false时关闭爆炸保护模式。爆炸保护在开启状态下所有爆炸均不会破坏方块。

MiscUtils.GetSafeBlow()

bool

返回是否开启了爆炸保护模式。

MiscUtils.SetGameMode(GameMode gameMode)

void

设置世界游戏模式。

MiscUtils.GetGameMode()

GameMode

获取世界游戏模式。

MiscUtils.GetOnlinePlayerList()

ArrayList<Player>

获取所有在线玩家。

MiscUtils.KickPlayer(string playerName)

bool

将指定名称的玩家踢出服务器,返回是否踢出成功。

MiscUtils.KickAllPlayers()

int

将所有玩家踢出服务器,返回踢出玩家的个数。

MiscUtils.Ban(string ip)

void

封禁指定IP,并将该IP加入服务器黑名单。

MiscUtils.RemoveBan(string ip)

bool

从服务器黑名单中移除指定IP。

MiscUtils.GetBlackList()

ArrayList<string>

获取服务器IP黑名单,返回封禁的IP列表。

Previous用户图形界面UINext模组开发官方教程

Last updated 4 years ago

Was this helpful?