SirJshreder Posted January 21, 2013 Posted January 21, 2013 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: Thanks, jshreder Quote
SirJshreder Posted January 21, 2013 Author Posted January 21, 2013 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? Quote
SirJshreder Posted January 21, 2013 Author Posted January 21, 2013 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. Quote
SirJshreder Posted January 21, 2013 Author Posted January 21, 2013 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. Quote
SirJshreder Posted January 21, 2013 Author Posted January 21, 2013 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); } } } Quote
opssemnik Posted January 21, 2013 Posted January 21, 2013 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); } } Quote
SirJshreder Posted January 21, 2013 Author Posted January 21, 2013 Thank you so much! It seems to be working now . 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 Quote
Recommended Posts
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.