RealTheUnderTaker11 Posted February 3, 2017 Posted February 3, 2017 (edited) FIX: So there was three problems, one was the mod ID for baubles is actually Baubles, and 2 is I needed to removed the .class. The third is I needed an @Optional.Method above the method. Hope this helps anyone who finds it! So I'm trying to figure out how to use the @Optional annotation and it is not going well. The class code is below. On the line that says @Optional.Interface(iface="IBauble",modid="baubles") I have also tried @Optional.Interface(iface="baubles.api.IBauble.class",modid="baubles") and got the same crash.(The crash report is a classNotFound blah blah error, file attached.) import java.util.List; import com.theundertaker11.kitchensink.KitchenSink; import com.theundertaker11.kitchensink.event.WorldTick; import baubles.api.BaubleType; import baubles.api.IBauble; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Optional.Interface(iface="IBauble",modid="baubles") public class blessedRock extends ItemBase implements IBauble{ public blessedRock(String name){ super(name, true); this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("What could a rock ever... Oh!"); } @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; String username = player.getGameProfile().getName(); if(!WorldTick.PlayersWithFlight.contains(username)) WorldTick.PlayersWithFlight.add(username); player.capabilities.allowFlying = true; } } @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.TRINKET; } } crash-2017-02-03_17.09.11-client.txt Edited February 5, 2017 by RealTheUnderTaker11 Resolved thread Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
shadowfacts Posted February 3, 2017 Posted February 3, 2017 To expand a bit on what diesieben said, @Optional.Interface takes the fully qualified name, as in some.package.Interface not Interface. A side note: You'll also need @Optional.Method on any methods from IBauble that you implement. If you don't include @Optional.Method on the IBauble methods whose signatures contain types from the Baubles API, there will be a crash when the mod isn't present. (This is due to how the JVM works. When a class is loaded, it looks at all the method signatures and tries to load all the types that they contain if they haven't been loaded already. ) Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 (edited) 57 minutes ago, diesieben07 said: The interface is called "baubles.api.IBauble", not "IBauble". As I stated above the code, I had already done that and it has to be "baubles.api.IBauble.class", it didn't work at all unless I had the .class there. Even with baubles installed. I tested it again just now and I can confirm it won't work at all (as a bauble) without the .class.(By that I mean it works fine as an item with no errors or crashes, but just doesn't work as a bauble.) 24 minutes ago, shadowfacts said: To expand a bit on what diesieben said, @Optional.Interface takes the fully qualified name, as in some.package.Interface not Interface. A side note: You'll also need @Optional.Method on any methods from IBauble that you implement. If you don't include @Optional.Method on the IBauble methods whose signatures contain types from the Baubles API, there will be a crash when the mod isn't present. (This is due to how the JVM works. When a class is loaded, it looks at all the method signatures and tries to load all the types that they contain if they haven't been loaded already. ) Everywhere I read said it removed all related methods if it removed the interface. Regardless when I use the code below it crashes my game with the attached crash report(when I mouse the item in my inventory), but when I removed the @Optional.Method() it doesn't crash. Also read what I replied to diesieben07 above. import java.util.List; import com.theundertaker11.kitchensink.KitchenSink; import com.theundertaker11.kitchensink.event.WorldTick; import baubles.api.BaubleType; import baubles.api.IBauble; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Optional.Interface(iface="baubles.api.IBauble.class",modid="baubles") public class blessedRock extends ItemBase implements IBauble{ public blessedRock(String name){ super(name, true); this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("What could a rock ever... Oh!"); } @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; String username = player.getGameProfile().getName(); if(!WorldTick.PlayersWithFlight.contains(username)) WorldTick.PlayersWithFlight.add(username); player.capabilities.allowFlying = true; } } @Optional.Method(modid="baubles") @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.TRINKET; } } crash-2017-02-03_18.05.29-client.txt Edited February 4, 2017 by RealTheUnderTaker11 Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 No I hadn't seen anything about that in my searches on adding Optional interfaces and methods, how would I do that? Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
shadowfacts Posted February 4, 2017 Posted February 4, 2017 Set the dependencies field of your @Mod annotation to include "after:baubles;". This will tell Forge that, if Baubles is present, then your mod can't be loaded until after Baubles is. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 (edited) Now my @Mod looks like this- @Mod(modid = Refernce.MODID, version = Refernce.VERSION, name = Refernce.NAME, dependencies="after:baubles;") but it still crashes if I try and use the @Optional.Method, same report as before. Also tried removing the @Optional.method, then compiling and running without baubles, crashed.(Same report as original crash) EDIT:Leaving now so it will be a bit before I reply to this one, 2 hours probably. Edited February 4, 2017 by RealTheUnderTaker11 Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
shadowfacts Posted February 4, 2017 Posted February 4, 2017 You're still using the wrong interface name in the @Optional.Interface. The fully qualified name of the interface does not include the .class at the end. It's just baubles.api.IBauble, literally exactly what's in the import. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 1 hour ago, shadowfacts said: You're still using the wrong interface name in the @Optional.Interface. The fully qualified name of the interface does not include the .class at the end. It's just baubles.api.IBauble, literally exactly what's in the import. Like I said before it doesn't work if I do that though. I'll give you 2 screenshots that go with 2 sets of code to give you an idea of what is happening. This is WITH the baubles mod running. First set, without the .class. Notice it also has the Optional.Method Spoiler import java.util.List; import com.theundertaker11.kitchensink.KitchenSink; import com.theundertaker11.kitchensink.event.WorldTick; import baubles.api.BaubleType; import baubles.api.IBauble; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Optional.Interface(iface="baubles.api.IBauble",modid="baubles") public class blessedRock extends ItemBase implements IBauble{ public blessedRock(String name){ super(name, true); this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("What could a rock ever... Oh!"); } @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; String username = player.getGameProfile().getName(); if(!WorldTick.PlayersWithFlight.contains(username)) WorldTick.PlayersWithFlight.add(username); player.capabilities.allowFlying = true; } } @Optional.Method(modid="baubles") @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.TRINKET; } } Second set, with the .class, as said before I had to comment out the Optional.Method due to it causing a crash. Spoiler import java.util.List; import com.theundertaker11.kitchensink.KitchenSink; import com.theundertaker11.kitchensink.event.WorldTick; import baubles.api.BaubleType; import baubles.api.IBauble; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @Optional.Interface(iface="baubles.api.IBauble.class",modid="baubles") public class blessedRock extends ItemBase implements IBauble{ public blessedRock(String name){ super(name, true); this.setMaxStackSize(1); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) { tooltip.add("What could a rock ever... Oh!"); } @Override public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int metadata, boolean bool) { if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; String username = player.getGameProfile().getName(); if(!WorldTick.PlayersWithFlight.contains(username)) WorldTick.PlayersWithFlight.add(username); player.capabilities.allowFlying = true; } } //@Optional.Method(modid="baubles") @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.TRINKET; } } And yes, for both I tried to put them into my baubles inventory, and only the one with the tooltip worked. Why would it not load at all if I don't have the .class there? Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
Guest Posted February 4, 2017 Posted February 4, 2017 This could be caused by the mod id in the @Optional.Interface and/or @Optional.Method being wrong. Quote
shadowfacts Posted February 4, 2017 Posted February 4, 2017 Then something else is wrong as well, because the @Optional.Interface iface field does not include .class. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
Guest Posted February 4, 2017 Posted February 4, 2017 This does not make any sense whatsoever. I just took a look at the GitHub repository of Baubles. The modid is actually correct. I can't make anymore assumptions because the link to the crash log is broken. Quote
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 (edited) Original crash log in spoiler Spoiler ---- Minecraft Crash Report ---- // Don't do that. Time: 2/3/17 6:41 PM Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Kitchen Sink Mod (kitchensink) Caused by: java.lang.NoClassDefFoundError: com/theundertaker11/kitchensink/ksitems/blessedRock at com.theundertaker11.kitchensink.KitchenSink.preInit(KitchenSink.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:600) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:614) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:257) at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:439) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:351) at net.minecraft.client.main.Main.main(SourceFile:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.ClassNotFoundException: com.theundertaker11.kitchensink.ksitems.blessedRock at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 38 more Caused by: java.lang.NoClassDefFoundError: baubles/api/IBauble at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ... 40 more Caused by: java.lang.ClassNotFoundException: baubles.api.IBauble at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 44 more Caused by: java.lang.NullPointerException at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ... 46 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.10.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_25, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 842438480 bytes (803 MB) / 1060372480 bytes (1011 MB) up to 8576565248 bytes (8179 MB) JVM Flags: 7 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx8G -Xms1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.32 Powered by Forge 12.18.3.2185 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCH mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forge-1.10.2-12.18.3.2185.jar) UCH Forge{12.18.3.2185} [Minecraft Forge] (forge-1.10.2-12.18.3.2185.jar) UCH mercurius_updater{1.0} [mercurius_updater] (MercuriusUpdater-1.10.2.jar) UCE kitchensink{0.01} [Kitchen Sink Mod] (kitchensink-1.14.jar) Loaded coremods (and transformers): GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 20.19.15.4531' Renderer: 'Intel(R) HD Graphics 5600' and shadowfacts, don't worry, every step of the way I will do it without the .class, I was just explaining the situation to you Edited February 4, 2017 by RealTheUnderTaker11 Adding quote Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
Guest Posted February 4, 2017 Posted February 4, 2017 I think there is a boolean in @Optional.Interface called striprefs. If that still exists, try setting it to true. Quote
RealTheUnderTaker11 Posted February 4, 2017 Author Posted February 4, 2017 (edited) 24 minutes ago, XFactHD said: I think there is a boolean in @Optional.Interface called striprefs. If that still exists, try setting it to true. I did that and it didn't change any of the circumstances. (AKA without the .class it doesn't load as a bauble at all, with the .class and @Optional.Method it crashes when I mouse over it, and with the .class but without Optional.Method it runs as a bauble without a crash. I'm about to compile it and test without Baubles but I bet it will be the same class missing error) EDIT: I can confirm it still crashed with this error when run without baubles. Caused by: java.lang.NoClassDefFoundError: com/theundertaker11/kitchensink/ksitems/blessedRock Edited February 4, 2017 by RealTheUnderTaker11 Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
RealTheUnderTaker11 Posted February 5, 2017 Author Posted February 5, 2017 (edited) To early for a bump? Along with saying I tested putting blahblah in the iface and it loaded the as a Bauble, so I feel like it somehow thinks baubles isn't there and removes the interface. (When I do the iface without the .class like it should be) Edited February 5, 2017 by RealTheUnderTaker11 Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
RealTheUnderTaker11 Posted February 5, 2017 Author Posted February 5, 2017 Oh my god I'm going to set this as resolved, I just figured out the 1.10.2 mod ID of baubles is actually Baubles... Quote My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.
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.