I am trying to make a jetpack thing, when the player goes up only when he presses the spacebar and he has certain armor set on him, else, he just falls down.
Simply like a jetpack
Try this post. Instead of printing a chat message, set player.capabilities.allowFlying = true;
However, when you unequip your armor, you will most likely still be able to fly. To get around that, do a similar thing but use Events. Check this tutorial for setting up events.
Then, in LivingUpdateEvent, check if the player is wearing your armor and if so, do the above; else, player.capabilities.allowFlying = false.
Try this post. Instead of printing a chat message, set player.capabilities.allowFlying = true;
However, when you unequip your armor, you will most likely still be able to fly. To get around that, do a similar thing but use Events. Check this tutorial for setting up events.
Then, in LivingUpdateEvent, check if the player is wearing your armor and if so, do the above; else, player.capabilities.allowFlying = false.
I know how to do that, but that is creative mod style flying, I want to make it like a jetpack.
You only have to press jump twice and you're flying... think of it like a take-off bump... once you're in the air, it's space for up and shift for down, is that not what you wanted?
If you want to make the player fall, where you check for wearing your armor and if the spacebar is pressed, make an else statement that sets flying to false if any of those conditions are not met.
You only have to press jump twice and you're flying... think of it like a take-off bump... once you're in the air, it's space for up and shift for down, is that not what you wanted?
If you want to make the player fall, where you check for wearing your armor and if the spacebar is pressed, make an else statement that sets flying to false if any of those conditions are not met.
I don't want to make it the normal flying, forget the normal flying, I want the player to go up only when he presses the space bar and it should be like jumping constantly I guess.
Ah, I get it, so the player can't move horizontally, only vertically. My mistake, I was picturing a jetpack with more maneuverability.
What was the code you tried before for adding motionY?
You could register a keybinding for spacebar and when pressed, add motionY to the player from there but you'll have to send a packet, as keyboard stuff is all client-side only.
Ah, I get it, so the player can't move horizontally, only vertically. My mistake, I was picturing a jetpack with more maneuverability.
What was the code you tried before for adding motionY?
You could register a keybinding for spacebar and when pressed, add motionY to the player from there but you'll have to send a packet, as keyboard stuff is all client-side only.
I made a new key already and I deleted the old motion code, because I just moved up as you said with no ability to move to the sides.
Minecraft mc = FMLClientHandler.instance().getClient();
if (mc.currentScreen == null) { //Detects whether or not a GUI is open. Remove this and you will crash once you reach the main screen
Minecraft minecraft = Minecraft.getMinecraft();
ItemStack chest = ((EntityPlayer) minecraft.thePlayer).inventory.armorInventory[2];
if(chest != null && chest.getItem() == ItemArmor.plateDiamond && Keyboard.isKeyDown(Keyboard.KEY_SPACE))
{
minecraft.thePlayer.setPositionAndUpdate(minecraft.thePlayer.posX, minecraft.thePlayer.posY += 0.3F, minecraft.thePlayer.posZ); //Edit the float being added to the yPos to edit flight speed.
}
}
import org.lwjgl.input.Keyboard, not the minecraft Keyboard.
Put this in the onTickStart() method in your CLIENT handler. If you put it in any other method in the tick handler, the ticks will not occur fast enough and you will go up, fall for about a second, and then go up again. (onTickInGame will do this, so do not even try )
If this solved your problem, I'd appreciate it if you would hit that nice little reputation button down there
I am trying to make a jetpack thing, when the player goes up only when he presses the spacebar and he has certain armor set on him, else, he just falls down.
Simply like a jetpack
Please help!
thanks ahead!
However, when you unequip your armor, you will most likely still be able to fly. To get around that, do a similar thing but use Events. Check this tutorial for setting up events.
Then, in LivingUpdateEvent, check if the player is wearing your armor and if so, do the above; else, player.capabilities.allowFlying = false.
I know how to do that, but that is creative mod style flying, I want to make it like a jetpack.
If you want to make the player fall, where you check for wearing your armor and if the spacebar is pressed, make an else statement that sets flying to false if any of those conditions are not met.
I don't want to make it the normal flying, forget the normal flying, I want the player to go up only when he presses the space bar and it should be like jumping constantly I guess.
I tried it before, didn't work for me, if you could give me a code for this that works it will be awesome, thanks anyway.
What was the code you tried before for adding motionY?
You could register a keybinding for spacebar and when pressed, add motionY to the player from there but you'll have to send a packet, as keyboard stuff is all client-side only.
I made a new key already and I deleted the old motion code, because I just moved up as you said with no ability to move to the sides.
import org.lwjgl.input.Keyboard, not the minecraft Keyboard.
Put this in the onTickStart() method in your CLIENT handler. If you put it in any other method in the tick handler, the ticks will not occur fast enough and you will go up, fall for about a second, and then go up again. (onTickInGame will do this, so do not even try )
If this solved your problem, I'd appreciate it if you would hit that nice little reputation button down there
http://www.minecraftforum.net/topic/881211-124-modding-tutorial-jamolnngs-modding-tutorials-beginner-advanced/