= 创作分享 =
崩溃解答
1.12.2Crt脚本错误
Rhodium

1.12.2Crt脚本错误

Rhodium 于 2020-11-16 14:14 ( 4年前 ) [复制链接] [只看楼主] [打印]
1103 1
10RF
代码:import mods.contenttweaker.VanillaFactory;import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;
import mods.contenttweaker.Fluid;
import mods.contenttweaker.Color;
import mods.contenttweaker.MaterialSystem;
import mods.contenttweaker.Material;
import crafttweaker.entity.IEntityLivingBase;
import crafttweaker.entity.IEntity;
import crafttweaker.event.IEventCancelable;
import crafttweaker.event.EntityLivingDeathEvent;
import crafttweaker.player.IPlayer;
import crafttweaker.events.IEventManager;
import crafttweaker.item.IItemStack;
import crafttweaker.item.IIngredient;




events.onPlayerAttackEntity(function(event as crafttweaker.event.PlayerAttackEntityEvent) {
    if(!isNull(event.player.currentItem) && event.player.currentItem.definition.id == "contenttweaker:test") {
        if (!isNull(event.target)) {
                    if(!event.target.world.remote && (event.target instanceof IEntityLivingBase)) {
                            var entityLiving as IEntityLivingBase = event.target;
                            if (!isNull(entityLiving)) {
entityLiving.maxHealth = 1;
entityLiving.attackEntityFrom(<damageSource:OUT_OF_WORLD>, 1000000000.0f);
entityLiving.attackEntityFrom(<damageSource:IN_WALL>, 1000000000.0f);
entityLiving.attackEntityFrom(<damageSource:MAGIC>, 1000000000.0f);
entityLiving.attackEntityFrom(<damageSource:DRAGON_BREATH>, 1000000000.0f);
entityLiving.attackEntityFrom(<damageSource:LAVA>, 1000000000.0f);
entityLiving.health = 0;
entityLiving.setDead();
}
        }
        }
    }
});



crafttweaker.log.txt

4.15 KB, 下载次数: 7

错误报告

最佳答案

查看完整内容

maxHealth不能直接=,试下通过Attributes来改变最大生命值 import crafttweaker.entity.AttributeInstance; var attribute as AttributeInstance = entityLiving.getAttribute("generic.maxHealth") as AttributeInstance; attribute.removeAllModifiers(); attribute.setBaseValue(1.0 as double);
发表于 2020-11-16 14:14:42 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

回复 | 举报

该帖共收到 1 条回复!
TCreopargh
maxHealth不能直接=,试下通过Attributes来改变最大生命值

import crafttweaker.entity.AttributeInstance;

                var attribute as AttributeInstance = entityLiving.getAttribute("generic.maxHealth") as AttributeInstance;
                attribute.removeAllModifiers();
                attribute.setBaseValue(1.0 as double);
发表于 2020-11-16 14:14:43 | 只看该作者

回复 | 举报

百科目前不允许匿名发帖哦~ 请先 [ 登陆 ][ 注册 ] 吧~

本版积分规则

发新帖
  • 回复
  • 点评
  • 评分

[ MC百科(mcmod.cn) 除另有声明,所有开放公共编辑的内容均使用 BY-NC-SA 3.0 协议 ]

Minecraft百科CC协议
快速回复 返回顶部 返回列表