Jump to content

Recommended Posts

Posted (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.txtFetching info...

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.

Posted

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

Posted (edited)
  On 2/3/2017 at 11:19 PM, diesieben07 said:

The interface is called "baubles.api.IBauble", not "IBauble".

Expand  

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

  On 2/3/2017 at 11:52 PM, 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. )

Expand  

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

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.

Posted

No I hadn't seen anything about that in my searches on adding Optional interfaces and methods, how would I do that?

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.

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

Posted
  On 2/4/2017 at 1:54 AM, 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.

Expand  

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

  Reveal hidden contents

 

Second set, with the .class, as said before I had to comment out the Optional.Method due to it causing a crash.

  Reveal hidden contents

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.

Posted

This could be caused by the mod id in the @Optional.Interface and/or @Optional.Method being wrong.

Posted

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.

Posted (edited)

Original crash log in spoiler

  Reveal hidden contents

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.

Posted

I think there is a boolean in @Optional.Interface called striprefs. If that still exists, try setting it to true.

Posted (edited)
  On 2/4/2017 at 5:05 PM, XFactHD said:

I think there is a boolean in @Optional.Interface called striprefs. If that still exists, try setting it to true.

Expand  

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.

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

Posted

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

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.

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

    • Add crash-reports with sites like https://mclo.gs/ Make a test without createaddition
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • my server is running perfectly fine but the problem is I can't connect to it. https://drive.google.com/file/d/1pn3oyAoS6J9mYVQlTJs7nKSSOHRo-9NX/view?usp=sharing. Here is the bug report when I tried to join the server.  
    • I'm trying to create split out some common code from my current mod project into a new library. For dependency management, I'm attempting to use AWS S3 as a Maven repo. I've done this successfully with other projects in the past, but ForgeGradle doesn't seem to like the s3:// URL for my repository. Specifically, it's throwing the following exception when trying to resolve the net.minecraftforge:forge:1.21.1-52.1.0:userdev dependency:   My understanding is that modern versions of Gradle support this use case. Does ForgeGradle not? Is there a way that I can make this work? Thank you for any help you can offer.
    • Codice Sconto Temu 100$ DI SCONTO → [acu639380] per Clienti Esistenti   Ottieni  100$ di sconto con il Codice Promozionale Temu (acu639380) Temu continua a dominare il mondo dell’e-commerce con sconti imbattibili e prodotti di tendenza – e giugno 2025 non fa eccezione. Con il codice sconto Temu (acu639380), puoi ottenere fino a  100$ di sconto, sia che tu sia un nuovo cliente sia che tu stia tornando a fare acquisti. Grazie alla consegna ultra-rapida, spedizione gratuita in 67 paesi e sconti fino al 90%, Temu propone pacchetti esclusivi e codici promozionali imperdibili questo giugno. Ecco come sfruttare al meglio il codice (acu639380) e iniziare subito a risparmiare. Perché Giugno 2025 è il Momento Migliore per Acquistare su Temu Giugno è ricco di offerte a tempo limitato, nuovi arrivi di tendenza e sconti nascosti in tutte le categorie. Dalla moda all’elettronica, dalla bellezza agli articoli per la casa, Temu offre prodotti indispensabili a prezzi imbattibili. Usa il codice (acu639380) per accedere a:  100$ di sconto per nuovi utenti  100$ di sconto per clienti esistenti 40% di sconto extra su categorie selezionate Pacchetto di buoni da  100$ per nuovi e vecchi clienti Regalo di benvenuto gratuito per chi acquista per la prima volta Vantaggi Esclusivi dei Codici Sconto Temu Questi sconti sono pensati per ogni tipo di acquirente. Ottieni il massimo con: Codice Temu (acu639380)  100$ di sconto – Riduci il totale sui tuoi acquisti in blocco Codice Temu per utenti esistenti – Offerte premium riservate ai clienti fedeli Codice Temu per nuovi utenti – Grandi risparmi sul primo ordine Codice Temu 40% di sconto – Perfetto per moda e prodotti stagionali Pacchetto coupon da  100$ Temu – Risparmia su più ordini Coupon per nuovi utenti Temu – Inizia con un regalo + sconto Offerte Localizzate con il Codice Temu (acu639380) Grazie alla presenza globale di Temu, puoi accedere a offerte personalizzate ovunque ti trovi: Codice Temu  100$ di sconto – USA Codice Temu  100$ di sconto – Canada Codice Temu  100$ di sconto – Regno Unito Codice Temu  100$ di sconto – Giappone Codice Temu 40% di sconto – Messico Codice Temu 40% di sconto – Brasile Codice Temu  100$ di sconto – Germania Codice Temu  100$ di sconto – Francia Codice Temu per nuovi utenti – Argentina Coupon Temu per utenti esistenti – Italia Codice promozionale Temu (acu639380) – Spagna, giugno 2025 Cosa Comprare su Temu a Giugno 2025 L’ampio catalogo Temu include migliaia di categorie. Ecco alcuni articoli su cui usare il codice sconto (acu639380): Gadget intelligenti e accessori Moda per tutte le età Decorazioni per la casa e soluzioni salvaspazio Prodotti per il benessere, fitness e bellezza Utensili da cucina e pentolame Articoli per ufficio, giochi e regali La Mia Esperienza Risparmiando  100$ con il Codice Temu (acu639380) Quando ho usato il codice (acu639380) da cliente abituale, ho ricevuto immediatamente  100$ di sconto. Combinandolo con la promozione del 40% e il pacchetto da  100$, ho ottenuto oltre 200 $ di valore per meno di 80 $. Anche tu puoi farlo. Ti basta inserire (acu639380) al checkout, e lo sconto si applica automaticamente – con spedizione gratuita in tutto il mondo inclusa. Altri Sconti Temu per Giugno 2025 Questo mese è pieno di offerte a rotazione, pacchetti a sorpresa e vendite flash giornaliere. Resta aggiornato su: Nuove uscite con il coupon per nuovi utenti Temu Aggiornamenti settimanali dei codici per clienti esistenti Promozioni regionali con il codice (acu639380) per giugno 2025 Conclusione Ovunque ti trovi – in Nord America, Europa o Sud America – il codice Temu (acu639380) è la chiave per risparmiare alla grande. Con offerte per nuovi utenti e clienti fedeli, questo è il momento perfetto per approfittare dei prezzi imbattibili di Temu. Usa il codice acu639380 oggi stesso per ottenere vantaggi esclusivi e trasformare il tuo shopping in un’esperienza smart e conveniente.      
  • Topics

×
×
  • Create New...

Important Information

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