Skip to content

Instantly share code, notes, and snippets.

Last active Mar 27, 2016
Embed
What would you like to do?
package com.koopamillion.Main;
import com.koopamillion.item.Mitems;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class JetpackHandler {
public IMessage handleServerMessage(EntityPlayer player, JetpackMessage message, MessageContext ctx) {
ItemStack stack;
int yaw = (int)player.rotationYaw;
if (yaw<0)
yaw+=360;
yaw+=22;
yaw%=360;
int facing = yaw/45; // 360degrees divided by 45 == 8 zones
if(facing == 0){
player.motionZ = 0.5;
}
if(facing == 1){
player.motionZ = 0.5;
player.motionX = -0.5;
}
if(facing == 2){
player.motionX = -0.5;
}
if(facing == 3){
player.motionX = -0.5;
player.motionZ = -0.5;
}
if(facing == 4){
player.motionZ = -0.5;
}
if(facing == 5){
player.motionZ = -0.5;
player.motionX = 0.5;
}
if(facing == 6){
player.motionX = 0.5;
}
if(facing == 7){
player.motionZ = 0.5;
player.motionX = 0.5;
}
player.motionY = 0.5;
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment