Zentutorial
  • 首页
  • Zenscript
  • 简单运用
    • 局部变量
    • 尖括号调用
    • 工作台合成
      • 添加配方
      • 移除配方
      • Metadata
      • NBT
    • 熔炉配方
    • 矿物词典(Ore Dictionaries)
    • 物品名称修改
    • tooltips
      • 样式代码
    • 物品条件
    • 物品转换器
    • 掉落物
      • 打草掉落物
      • 生物掉落物
      • Dropt - 导言
        • Dropt - 方法速查
        • Dropt - 使用示例
    • 战利品表 : 导论
      • 战利品表修改(LootTableTweaker)
      • 战利品表修改(LootTweaker-基础)
    • 循环语句(foreach循环) / 普通数组
  • 高级运用
    • 概论
      • 基本类
      • ZenGetter
      • ZenSetter
      • ZenMethod(方法)
    • 常见错误
    • 基本运算
    • 数组与集合
    • 循环与遍历
    • 全局函数
    • Math包
    • if
    • in/has 操作符
    • 战利品表修改(LootTweaker-进阶)
    • 三元操作符
    • 预处理器
    • 全局和静态变量
    • 跨脚本引用
    • 关联数组(映射)
    • IItemStack类型的重新认识
    • IIngredient接口
    • IItemDefinition & IBlockDefinition
    • IData 类型
      • DataMap
    • 穷举与遍历
    • 自定义函数
    • 配方函数与配方事件
      • 配方函数
      • 配方事件
    • 事件概论
      • 一些忠告
    • ZenClass
  • ContentTweaker
    • ContentTweaker
    • 指令
    • 原版加工厂
      • 概论
      • 物品
      • 方块
      • 流体
      • 创造标签
      • 食物
    • 材料系统
      • 基础用法
        • 材料
        • 部件
        • 注册材料部件
        • 材料部件信息
      • 高级运用
        • 自定义部件类型
        • 注册自定义部件
        • 自定义材料部件信息
    • 高级运用
    • 更多鸡联动
    • 匠魂联动
      • 材料引导
        • 材料
        • 构建材料
      • 特性引导
        • 特性
        • 构建特性
        • 特性数据
      • 高级运用
  • 实战
    • 配方
      • 数据驱动合成修改
    • 事件
      • 修改方块掉落物
      • 禁止开创造
由 GitBook 提供支持
在本页
  • 更多实例
  • 运用于 MaterialBuilder 对象的函数
  • ItemLocalizer 函数
  • 运用于 TraitBuilder 对象的函数
  • CanApplyTogether 函数
  • ExtraInfo 函数
  • getMiningSpeed 函数
  • beforeBlockBreak 函数
  • afterBlockBreak 函数
  • onBlockHarvestDrops 函数
  • onUpdate 函数
  • afterHit 函数
  • onHit 函数
  • onBlock 函数
  • onPlayerHurt 函数
  • calcCrit 函数
  • calcDamage 函数
  • calcKnockBack 函数
  • onToolDamage 函数
  • calcToolHeal 函数
  • onToolRepair 函数

这有帮助吗?

  1. ContentTweaker
  2. 匠魂联动

高级运用

上一页特性数据下一页配方

最后更新于3年前

这有帮助吗?

更多实例

请看 虽然咕咕咕了

运用于 MaterialBuilder 对象的函数

ItemLocalizer 函数

导包

import mods.tconstruct.materials.ItemLocalizer;

该函数用于计算材料名称

此函数需要返回 string

  • 类的 thisMaterial

  • String 类型的 itemName

例子

myMat.itemLocalizer = function(thisMaterial, itemName) {
    return "Cool " + itemName;
};

游戏中 :

运用于 TraitBuilder 对象的函数

CanApplyTogether 函数

导包

import mods.tconstruct.traits.CanApplyTogetherTrait;
import mods.tconstruct.traits.CanApplyTogetherEnchantment;

此函数可以使特性或附魔不能同存

此函数需要返回 bool

  • String 类型的 otherTrait

例子1

myTrait.canApplyTogetherTrait = function(thisTrait, otherTrait) {
    return otherTrait != 特性名称(也就是 identifier)
};
  • String 类型的 enchantmentDefinition

例子2

myTrait.canApplyTogetherEnchantment = function(thisTrait, enchantmentDefinition) {
    return enchant != 附魔名称(不要傻傻的填个 "附魔名称")
};

ExtraInfo 函数

导包

import mods.tconstruct.traits.ExtraInfo;

可以在工具装配台看到额外信息

此函数需要返回 string[]

例子 :

myTrait.extraInfo = function(thisTrait, item, tag){
    var infos as string[] = ["Cool1", "Cool2"];
    return infos;
};

getMiningSpeed 函数

导包

import mods.tconstruct.traits.MiningSpeed;

破坏方块时调用

此函数不需要返回值

函数写法 :

myTrait.getMiningSpeed = function(thisTrait, tool, event) {
    //Code
};

beforeBlockBreak 函数

导包

import mods.tconstruct.traits.BeforeBlockBreak;

方块被破坏之前调用

此函数不需要返回值

函数写法 :

myTrait.beforeBlockBreak = function(thisTrait, tool, event) {
    //Code
};

afterBlockBreak 函数

导包

import mods.tconstruct.traits.AfterBlockBreak;

方块被破坏之后调用

此函数不需要返回值

  • boolean 类型的 wasEffective

函数写法 :

myTrait.afterBlockBreak = function(thisTrait, tool, world, blockstate, pos, miner, wasEffective) {
    //Code
};

onBlockHarvestDrops 函数

导包

import mods.tconstruct.traits.BlockHarvestDrops;

方块被破坏且将要生成掉落物时调用

此函数不需要返回值

函数写法 :

myTrait.onBlockHarvestDrops = function(thisTrait, tool, event) {
    //Code
};

onUpdate 函数

导包

import mods.tconstruct.traits.Update;

此函数每 Tick 都会调用

此函数不需要返回值

  • int 类型的 itemSlot

  • boolean 类型的 isSelected

函数写法 :

myTrait.onUpdate = function(thisTrait, tool, world, entity, itemSlot, isSelected) {
    //Code
};

afterHit 函数

导包

import mods.tconstruct.traits.AfterHit;

实体受到伤害后调用

此函数不需要返回值

  • float 类型的 damageDealt

  • boolean 类型的 wasCritical

  • boolean 类型的 wasHit

函数写法 :

mytrait.afterHit = function(trait, tool, attacker, target, damageDealt, wasCritical, wasHit) {
    //Code
};

onHit 函数

导包

import mods.tconstruct.traits.OnHit;

即将对实体造成伤害之前调用, 在此函数调用时所有的伤害都计算完毕 (简单来说就是最后一步)

此函数不需要返回值

  • float 类型的 damage

  • boolean 类型的 isCritical

函数写法 :

myTrait.onHit = function(thisTrait, tool, attacker, target, damage, isCritical) {
    //Code
};

onBlock 函数

导包

import mods.tconstruct.traits.OnBlock;

此函数不需要返回值

函数写法 :

myTrait.onBlock = function(thisTrait, tool, attacker, event) {
    //Code
};

onPlayerHurt 函数

导包

import mods.tconstruct.traits.OnPlayerHurt;

此函数不需要返回值

函数写法 :

myTrait.onPlayerHurt = function(thisTrait, tool, player, attacker, event) {
    //Code
};

calcCrit 函数

导包

import mods.tconstruct.traits.IsCriticalHit;

对实体造成伤害之前调用以确定此次攻击是否暴击,返回值为 false 并不会取消已经是暴击的伤害

此函数需要返回一个 bool

函数写法 :

myTrait.calcCrit = function(thisTrait, tool, attacker, target) {
    //Code 
    return true; //或 false
};

calcDamage 函数

导包

import mods.tconstruct.traits.Damage;

攻击一个实体时调用,但在造成伤害和计算暴击加成之前调用, 此函数用于计算暴击伤害的加成

此函数需要返回一个 float 以确定伤害加成

  • float 类型的 originalDamage

  • float 类型的 currentDamage

  • boolean 类型的 isCritical

函数写法 :

myTrait.calcDamage = function(thisTrait, tool, attacker, target, originalDamage, currentDamage, isCritical) {
    //Code 
    return currentDamage; //或者修改后的值
};

calcKnockBack 函数

导包

import mods.tconstruct.traits.KnockBack;

攻击实体后调用, 以修改实体受到的击退

此函数需要返回一个 float 以确定击退距离

  • float 类型的 damage

  • float 类型的 knockback

  • float 类型的 newKnockback

  • boolean 类型的 isCritical

函数写法 :

myTrait.calcKnockBack = function(thisTrait, tool, attacker, target, damage, knockback, newKnockback, isCritical) {
    //Code  
    return newKnockback; //或者修改后的值
};

onToolDamage 函数

导包

import mods.tconstruct.traits.OnToolDamage;

工具降低耐久度之前调用

此函数需要返回一个 int 以确定工具耐久

  • int 类型的 damage

  • int 类型的 newDamage

函数写法 :

myTrait.onToolDamage = function(thisTrait, tool, damage, newDamage, entity) {
    //Code  
    return newDamage; //或者修改后的值
};

calcToolHeal 函数

导包

import mods.tconstruct.traits.OnToolHeal;

工具提高耐久度之前调用

此函数需要返回一个 int 以确定工具耐久

  • int 类型的 damage

  • int 类型的 newDamage

函数写法 :

myTrait.calcToolHeal = function(thisTrait, tool, damage, newDamage, entity) {
    //Code  
    return newDamage; //或者修改后的值
};

onToolRepair 函数

导包

import mods.tconstruct.traits.OnToolRepair;

此函数不需要返回值

  • int 类型的 amount

函数写法 :

myTrait.onToolRepair = function(thisTrait, tool, amount) {
    //Code
};

类的 thisTrait

类的 thisTrait

类的 thisTrait

类的 item

类的 tag

游戏中 :

类的 thisTrait

类的 tool

类型的 event

类的 thisTrait

类的 tool

类型的 event

类的 thisTrait

类的 tool

类的 world

类的 blockstate

类的 pos

类的 miner

类的 thisTrait

类的 tool

类型的 event

类的 thisTrait

类的 tool

类的 world

类的 entity (实际使用时这个对象可能是为 , , 只是被自动转型为 , 可以 instanceof 判断之后就向下强转)

类的 thisTrait

类的 tool

类的 attacker

类的 target

类的 thisTrait

类的 tool

类的 attacker

类的 target

玩家阻挡攻击时调用, 否则调用 函数

类的 thisTrait

类的 tool

类的 attacker

类型的 event

玩家未阻挡攻击时调用, 否则调用 函数

类的 thisTrait

类的 tool

类的 player

类的 attacker

类型的 event

类的 thisTrait

类的 tool

类的 attacker

类的 target

类的 thisTrait

类的 tool

类的 attacker

类的 target

类的 thisTrait

类的 tool

类的 attacker

类的 target

类的 thisTrait

类的 tool

类的 entity

类的 thisTrait

类的 tool

类的 entity

使用材料修复工具前调用, 请勿与 函数混淆, 如果不止一次修复这个物品,此函数将被调用多次

类的 thisTrait

类的 tool

Trait
IEnchantmentDefinition
Trait
IItemStack
IData
Trait
IItemStack
PlayerBreakSpeedEvent
Trait
IItemStack
BlockBreakEvent
Trait
IItemStack
IWorld
IBlockState
IBlockPos
IEntityLivingBase
Trait
IItemStack
BlockHarvestDropsEvent
Trait
IItemStack
IWorld
IEntity
IPlayer
IEntityLivingBase
IEntity
Trait
IItemStack
IEntityLivingBase
IEntityLivingBase
Trait
IItemStack
IEntityLivingBase
IEntityLivingBase
Trait
IItemStack
IPlayer
EntityLivingHurtEvent
Trait
IItemStack
IPlayer
IEntityLivingBase
EntityLivingHurtEvent
Trait
IItemStack
IEntityLivingBase
IEntityLivingBase
Trait
IItemStack
IEntityLivingBase
IEntityLivingBase
Trait
IItemStack
IEntityLivingBase
IEntityLivingBase
Trait
IItemStack
IEntityLivingBase
Trait
IItemStack
IEntityLivingBase
Trait
IItemStack
onPlayerHurt
onBlock
calcToolHeal
CrT 高级运用
Material
icon
iron