Skip to content

Instantly share code, notes, and snippets.

@jmbjorndalen
Created March 22, 2015 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmbjorndalen/7bfaefe59fb4ee312549 to your computer and use it in GitHub Desktop.
Save jmbjorndalen/7bfaefe59fb4ee312549 to your computer and use it in GitHub Desktop.
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