Last active
August 29, 2015 14:15
-
-
Save walterhiggins/260a5fd9c2032386b70b to your computer and use it in GitHub Desktop.
Javascript Code to make Players bounce when they step on sponge
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
function bounceOnSponge(event){ | |
var player = event.player; | |
var location = player.location; | |
// need to convert coordinates to integers | |
var x = Math.floor(location.x); | |
var y = Math.floor(location.y - 1 ); // what's underfoot? | |
var z = Math.floor(location.z); | |
var block = location.world.getBlockAt(x, y, z); | |
if (block.typeId === blocks.sponge){ | |
player.motionY = 2; // springs player high into air | |
} | |
} | |
events.playerMove( bounceOnSponge ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment