Jump to content

Trouble with @Optional.Interface


RealTheUnderTaker11

Recommended Posts

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 by RealTheUnderTaker11
Resolved thread

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.

Link to comment
Share on other sites

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

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

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 by RealTheUnderTaker11

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.

Link to comment
Share on other sites

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 by RealTheUnderTaker11

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.

Link to comment
Share on other sites

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

WithoutClass.JPG.fe6d67c81099585c61412362fa04fdb6.JPG


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

WithClass.JPG.7cbf124c37f4db72dfdcbdc10d692dff.JPG


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?

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.

Link to comment
Share on other sites

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 by RealTheUnderTaker11
Adding 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.

Link to comment
Share on other sites

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 by RealTheUnderTaker11

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.

Link to comment
Share on other sites

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 by RealTheUnderTaker11

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.

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • In the rapidly evolving landscape of cryptocurrency, scams are on the rise, leaving many investors vulnerable to fraudulent schemes. If you've found yourself a victim of a crypto scam, navigating the complex process of recovering your lost funds can be daunting and overwhelming. However, there are some professionals in cryptocurrency recovery, such as Captain WebGenesis, who have specific knowledge and experience in handling complex blockchain technology and comprehending how scammers function in the cryptocurrency space. Captain WebGenesis has extensive expertise helping people who have been duped by investment scams to effectively retrieve their stolen or lost cryptocurrency.  
    • Looking for a semi-vanilla Minecraft server? Maybe one with keep inventory and land claims? I have one for you! Let me introduce you to Safe Survival! Come on and join us at mc.safesurvival.net. It is bedrock supported too!
    • Hi. I'm trying to play RLCraft with Optifine but my game keeps crashing on startup with Exit Code 1. The modpack was working fine yesterday, not sure what changed to make it not wanna work anymore. I was hoping someone here could help me figure out what's going wrong. If I remove Optifine, nothing changes, I still get the same errors. Thanks in advance. Crash Report (I only included the errors+fatal, I’m not sure if more is needed, please let me know): https://pastebin.ai/66ivknz0f4  
    • I am trying to port my mod from 1.20.2 to 1.21, but I am encountering difficulties regarding the classes for rendering the GUI and related events. What are the equivalents of the following classes? net.minecraftforge.client.event.RenderGuiOverlayEvent net.minecraftforge.client.gui.overlay.NamedGuiOverlay net.minecraftforge.client.gui.overlay.ForgeGui net.minecraftforge.client.gui.overlay.GuiOverlayManager net.minecraftforge.client.gui.overlay.IGuiOverlay   thx
    • Hi all! Love the Custom npc mod, it is my favorite mod! That said, I have been using this mod since finding it a few years ago (I only play on 1.12.2) and instantly loved that I caould reskin all of the npc's I created. That worked great until recently. I got locked out of my outlook account, which is what I was logged into windows with at the time, and they locked me out of Windows 10. So, I had to reinstall, and since I have digital entitlements to Windows 10 ( I am part of the insider program) on all three of my outlook accounts, I ust swapped to the one I bought Minecraft for. Reinstalled everything, started MC, crerated my favorite fighter (set to kill everything) to clear an area) set up the stats, went back to the main screen, clicked skin so I can give him the grim reaper skin and crash . . . wtf? Thought it was another mod, so, over the course of the last 2 days, I removed every single mod, reinstalled forge 2860 and then 2859, replaced optifine G5 with G6 and vice versa, all with the same result. So, I created a new world, with only the two mods, and same thing. https://pastebin.com/8raJVHq1 That is the log, I have been through the visual settings and all sorts of stuff and can not figure this out, and being that I only just started a bachelors in software engineer / computer programming, I have no idea what I am looking at, so please, and thank you!  If any one of you know what is causing this, I will be forever grateful for the help! Mor9heus
  • Topics

×
×
  • Create New...

Important Information

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