Chapter 5. Movement

Most entities in Minecraft—such as creepers, pigs, and zombies—move in the game. But they don’t have the capability to jump or get damaged when they fall. Also, none of the entities except spiders can climb up walls, and spiders can climb only up to three blocks high. In this chapter, you’ll learn how to change all this by modding the movement of the player.

First, you will make the player jump much higher; then you will add a parachute so that the player can avoid fall damage. Finally, you will make a mod that lets snow golems and iron golems climb up walls to reach hostile mobs that they can kill.

Super Jump

A Minecraft player can normally jump up to 1.252 blocks. This is typically done to jump over a block or get out of a cave. But what if you were to jump over a cliff that is much higher or a cave that is much deeper? This mod will give you the ability to jump much higher and reach new heights.

First, make a new class and call it SuperJump. Register it in the main file to activate the mod. The event handler method code that needs to be added to this class is shown in Example 5-1.

Example 5-1. Super jump method code
@SubscribeEvent
public void makeJumpHigher(LivingJumpEvent event){ 1
	if (!(event.entity instanceof EntityPlayer)) { 2
		return;
	}

	event.entity.motionY ...

Get Minecraft Modding with Forge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.