Skip to content

Instantly share code, notes, and snippets.

@walterhiggins
Last active August 29, 2015 14:15
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 walterhiggins/260a5fd9c2032386b70b to your computer and use it in GitHub Desktop.
Save walterhiggins/260a5fd9c2032386b70b to your computer and use it in GitHub Desktop.
Javascript Code to make Players bounce when they step on sponge
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