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 have a mod that makes a flying ring. I think it should be SMP compatible, but I get this error upon loading a forge server:

java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
        at in.joegold.flyingring.FlyingRingItem.<init>(FlyingRingItem.java:24)
        at in.joegold.flyingring.FlyingRing.<clinit>(FlyingRing.java:36)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:416)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
        at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
        at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
        at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
        at com.google.common.eventbus.EventBus.post(EventBus.java:268)

 

Anyone have any suggestions? I'll post any code if requested, but here's a list of my classes:

xRABTVw.png

 

Thanks,

jshreder

  • Author

I have this line

private Minecraft mc = Minecraft.getMinecraft();

in my main class, because I use

mc.thePlayer.capabilities.isFlying == true

to check whether the player is flying, among other things. How would I change this?

  • Author

I'm still having some trouble, would you mind being a bit more specific? I understand what you're saying, just not how to implement it, considering the ring that makes you fly affects only one player. Thanks.

  • Author

No, the idea is that you can craft a ring that lets only you fly. It fully works in SSP, but it crashes, as I said, in SMP.

  • Author

That's the problem. That is what I do, but I use the Minecraft class to get the player. How else would I do it?

 

Here is my code for the item class:

package in.joegold.flyingring;

import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class FlyingRingItem extends Item {

    private Minecraft mc = Minecraft.getMinecraft();

    public FlyingRingItem(int id) {
        super(id);

        // Constructor Configuration
        setMaxStackSize(1);
        setCreativeTab(CreativeTabs.tabTools);
        setIconIndex(0);
        setItemName("flyingRingItem");
    }

    @Override
    public String getTextureFile() {
        return CommonProxy.ITEMS_PNG;
    }

    @Override
    public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
        super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);

        if (mc.thePlayer.inventory.hasItem(24537)) {
            mc.thePlayer.capabilities.allowFlying = true;
        }

        if (mc.thePlayer.capabilities.isFlying == true) {
            this.setIconIndex(1);
        } else {
            this.setIconIndex(0);
        }
    }
}

to make isFlying true try this

@Override

    public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {

        super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);

      if(par3Entity instanceof EntityPlayer){

        EntityPlayer player = (EntityPlayer)par3Entity;

        if (player .inventory.hasItem(24537)) {

            player .capabilities.allowFlying = true;

        }

 

        if (player.capabilities.isFlying == true) {

            this.setIconIndex(1);

        }} else {

            this.setIconIndex(0);

        }

    }

 

 

  • Author

Thank you so much! It seems to be working now :D. I'll pm you a link to the mod on mcforums when I have it up, if you wouldn't mind taking a look at it.

 

Thanks again,

jshreder

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.