Skip to content

Instantly share code, notes, and snippets.

Last active March 27, 2016 21:42
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 anonymous/ad453cbe13f3b9f92c2a to your computer and use it in GitHub Desktop.
Save anonymous/ad453cbe13f3b9f92c2a to your computer and use it in GitHub Desktop.
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