Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
events.damage(function(event) {
// Wearing a pumpkin on your head protects you from fall damage
var src = event.getDamageSource();
if (src.getDamagetype() == Packages.net.canarymod.api.DamageType.FALL) {
var def = event.getDefender()
var isPlayer = (def instanceof Packages.net.canarymod.api.entity.living.humanoid.Player);
if (isPlayer) {
var inv = def.getInventory();
var head = inv.getSlot(39);
if (head) {
if (head.id == 86) {
console.log("Pumpkin on your head. Nothing to worry about.");
event.setCanceled();
}
} else {
console.log("Nothing on your head. This hurts.");
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.