Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

i am trying to make afree flight jetpack but on landong i get fall damage why?

 

package enderCraft;

import java.util.EnumSet;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

import org.lwjgl.input.Keyboard;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class Tickjetpack implements ITickHandler{
public int tickpnumber = 0;
public int isjactive = 0;
public int isfull = 0;
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
if(type.equals(EnumSet.of(TickType.RENDER)))
{
onRenderTick();
}
else
if(type.equals(EnumSet.of(TickType.CLIENT)))
{
Minecraft mc = Minecraft.getMinecraft();
GuiScreen gui = mc.currentScreen;
if(gui != null)
{
onTickInGui(mc, gui);
}
else
{
onTickInGame(mc);
}
}
}
private void onTickInGame(Minecraft minecraft)
{	

	tickpnumber++;
	if (minecraft.thePlayer.inventory.armorItemInSlot(2) != null)
    {
		System.out.println("Armor ON");
        	System.out.println(tickpnumber);
		minecraft.thePlayer.fallDistance = 0.0F;





        ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(2);
        
        if (itemstack.itemID == Main.enderjetpack.shiftedIndex)
        {
        	
        	isjactive = tickpnumber;
        	
        	
        	if(minecraft.thePlayer.inventory.hasItem(Item.coal.shiftedIndex)){
        		
        		
        		
        			if(minecraft.theWorld.isRemote){
        				if(isjactive == 200 && isfull == 0){
        		minecraft.thePlayer.addChatMessage("Jetpack at full power");
        		isfull++;
        				}
        		}
        		
        			
        		if(isjactive == 200 && minecraft.thePlayer.capabilities.allowFlying == false){
        			
	        		minecraft.thePlayer.capabilities.allowFlying = true;
	        		minecraft.thePlayer.capabilities.isFlying = true;
	        		tickpnumber = 0;
        		}
        		
        		
        	}else{
        		if(tickpnumber == 200){
        		if(minecraft.theWorld.isRemote){
        		minecraft.thePlayer.addChatMessage("Unexpected error!!Do you have fuel?");
        		}
        		}
        		minecraft.thePlayer.capabilities.allowFlying = false;
        		minecraft.thePlayer.capabilities.isFlying = false;
        		if(isjactive == 400){
        		isjactive = 0;
        		tickpnumber = 0;
        	}
        	}
        	
        	
        }else{
        		if(minecraft.theWorld.isRemote && tickpnumber == 160){
        		minecraft.thePlayer.addChatMessage("You took off your jetpack");
        		}
        		minecraft.thePlayer.capabilities.allowFlying = false;
        		minecraft.thePlayer.capabilities.isFlying = false;
        		tickpnumber = 0;
        }
        
        
    }
}

private void onTickInGui(Minecraft minecraft, GuiScreen gui)
{

}
private void onRenderTick()
{

}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.CLIENT, TickType.RENDER);
}
@Override
public String getLabel()
{
return "TickHandler.CLIENT";
}
}

I am new at moding but maybe you could make your Jetpack add feather falling to the player.

@ForgeSubscribe
public void onEntityDammage(LivingHurtEvent event)
{
    if (event.entity instanceof EntityPlayer && event.source == DamageSource.fall && event.isCancelable())
    {
        if(((EntityPlayer)event.entity).inventory.armorInventory[1] instanceof YourJetpack)
        {
            if(((YourJetpack)((EntityPlayer)event.entity).inventory.armorInventory[1]).getIsOn())
            {
                event.setCanceled(true)
            }
        }
    }
}

this assumes that the jetpack is worn on the chest, that the Class<? extends Item> has a method called getIsOn() that returns true if the jetpack is on, and that the Class<? extends Item>.class== YourJetpack.class

 

Edit: Chibill: FeatherFall only goes on boots

  • Author

@ForgeSubscribe
public void onEntityDammage(LivingHurtEvent event)
{
    if (event.entity instanceof EntityPlayer && event.source == DamageSource.fall && event.isCancelable())
    {
        if(((EntityPlayer)event.entity).inventory.armorInventory[1] instanceof YourJetpack)
        {
            if(((YourJetpack)((EntityPlayer)event.entity).inventory.armorInventory[1]).getIsOn())
            {
                event.setCanceled(true)
            }
        }
    }
}

this assumes that the jetpack is worn on the chest, that the Class<? extends Item> has a method called getIsOn() that returns true if the jetpack is on, and that the Class<? extends Item>.class== YourJetpack.class

in which class do i put this in the tick handler or in a new class?

a simple way would be to add a crafting manager and when the jetpack is crafted it is given the enchant featherfalling X

The Korecraft Mod

or you could do

while(ForgeHooks.onLivingUpdate(player)){

        player.fallDistance=0;

}

The Korecraft Mod

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.