Jump to content

Recommended Posts

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

Posted

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?

Posted

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.

Posted

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);
        }
    }
}

Posted

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);

        }

    }

 

 

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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