Created
March 22, 2015 15:42
-
-
Save jmbjorndalen/7bfaefe59fb4ee312549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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