O'Reilly logo

Minecraft Modding with Forge by Arun Gupta, Aditya Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required