Files
meatballcraft/scripts/CustomDamagerDemonShard2.zs
2026-07-25 16:20:42 -05:00

59 lines
1.8 KiB
Plaintext

#modloaded thaumcraft
import crafttweaker.damage.IDamageSource;
import crafttweaker.entity.IEntityLivingBase;
import crafttweaker.event.PlayerInteractEntityEvent;
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;
import mods.contenttweaker.ItemFood;
import mods.contenttweaker.IItemFoodEaten;
import mods.contenttweaker.MutableItemStack;
import mods.contenttweaker.Hand;
import mods.contenttweaker.World;
import mods.contenttweaker.IItemUpdate;
import mods.contenttweaker.Player;
import crafttweaker.player.IPlayer;
import crafttweaker.block.IBlock;
import crafttweaker.data.IData;
events.onPlayerInteractEntity(function(event as PlayerInteractEntityEvent) {
if (event.world.isRemote()) {
return;
}
val heldItem = event.item;
// [edit item name in the bracket handler]
if (!isNull(heldItem) && heldItem.definition.id.matches(<bloodarsenal:bound_stick>.definition.id)) {
if (!event.target instanceof IEntityLivingBase) {
return;
}
val target as IEntityLivingBase = event.target;
if (target.definition.id != "bewitchment:demoness" || !target.isAlive()) {
return;
}
// [edit damage here]
val DAMAGE = 10.0f;
// [can remove this var if reusuable]
val oldHealth = target.health;
// Handle kill as if by player
if (target.health <= DAMAGE) {
target.onDeath(IDamageSource.createPlayerDamage(event.player));
// give custom drop
// Allows for proper death
target.health = 0;
} else {
target.attackEntityFrom(<damagesource:OUT_OF_WORLD>, DAMAGE);
Commands.call("summon Item ~ ~ ~ {Item:{id:\"bloodmagic:blood_shard\",Count:1b,Damage:1b}}", event.player, event.world, true, true);
}
}
});