MC百科社群

标题: 1.12.2Crt脚本错误 [打印本页]

作者: QQ酱19442    时间: 2020-11-16 14:14
标题: 1.12.2Crt脚本错误
代码: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

错误报告


作者: TCreopargh    时间: 2020-11-16 14:14
maxHealth不能直接=,试下通过Attributes来改变最大生命值

import crafttweaker.entity.AttributeInstance;

                var attribute as AttributeInstance = entityLiving.getAttribute("generic.maxHealth") as AttributeInstance;
                attribute.removeAllModifiers();
                attribute.setBaseValue(1.0 as double);




欢迎光临 MC百科社群 (https://bbs.mcmod.cn/) MC百科|最大的MineCraft中文模组百科