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

Hey so I was board and decided to work on my mod pack. So after trying to tweak the boat drops and failing I decided to see if I could make a fly mod. However I don't know if what I tried to de will work and I ran in to a problem with my code and I am not sure what eclips is wanting me to do do fix it it says to insert } but I can't find where it wants me to put the }. Anyways, am I on the right track for making a fly mod with what I have done here?

 

package net.boatDrops.mod;

 

import java.util.Random;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraftforge.event.entity.living.LivingEvent;

 

 

 

public class boatDrop  {

 

@SubscribeEvent

public void giveLeather(LivingEvent evt){

 

if (evt.entity instanceof EntityPlayer){

EntityPlayer player = getPlayer();

 

if(!player.capabilities.isCreativeMode){

 

player.capabilities.allowFlying true

 

 

}

 

 

 

 

 

}

 

}

 

private EntityPlayer getPlayer() {

// TODO Auto-generated method stub

return null;

}}

 

it should be player.capabilities.allowFlying = true. That's basic java (basic programming in general). I'd use a PlayerTickEvent instead

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

And make sure it doesn't work if you're on a multiplayer server (don't make hacks).

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

it should be player.capabilities.allowFlying = true. That's basic java (basic programming in general). I'd use a PlayerTickEvent instead

 

I made the changes that you told me to make and I have no errors but I still can't fly in survival mode.

Did you put ; at the end at your statement?

allowFlying means you still have to double jump to enable fly.

 

You can also use player.capabilities.isFlying = true;

which makes you fly directly.

 

Example from one of my mod that works (it's an item that makes you fly when used).

Just remove the lines with DebugTools.debugMessage (it's custom debugging) :

 

public class obsidianWings extends Item
{
public obsidianWings()
{
	super();
	this.setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
	DebugTools.debugMessage(world.isRemote, "obsidianWings used (onItemUse function)");
	fly(player);
	return true;
}

@Override
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
{
	DebugTools.debugMessage(world.isRemote, "obsidianWings used (onItemRightClick function)");
	fly(player);
	return item;
}

void fly(EntityPlayer player)
{
	player.capabilities.isFlying = !player.capabilities.isFlying;
}	

getPlayer is returning null. Use evt.player in the playertickevent. And how are you registering the event?

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

getPlayer is returning null. Use evt.player in the playertickevent. And how are you registering the event?

 

This is what the code for the fly event looks like(by the way the reason the name is boatDrop is because I was working on a diffrent mod befor trying to make this one and I didn't rename the files.)

package net.boatDrops.mod;

 

import java.util.Random;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

 

 

 

public class boatDrop  {

 

  @SubscribeEvent

  public void giveLeather(PlayerTickEvent evt){

     

      if (evt.player instanceof EntityPlayer){

       

        if(!evt.player.capabilities.isCreativeMode){

           

            evt.player.capabilities.allowFlying = true;

           

       

        }

       

       

       

       

       

      }

     

  }

 

 

  }

 

 

And I have it registered  like this in my main class.

boatDrop eventFly = new boatDrop();

@EventHandler
public void PreInit(FMLPreInitializationEvent preEvent){

	MinecraftForge.EVENT_BUS.register(new boatDrop());

}

Register it with FMLCommonHandler.instance().bus().register() since its an FML event. Also, you don't need to check it evt.player is an instance of EntityPlayer since it always is.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

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.