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();
}
}
}
}
});
|
最佳答案
查看完整内容
maxHealth不能直接=,试下通过Attributes来改变最大生命值
import crafttweaker.entity.AttributeInstance;
var attribute as AttributeInstance = entityLiving.getAttribute("generic.maxHealth") as AttributeInstance;
attribute.removeAllModifiers();
attribute.setBaseValue(1.0 as double);
|