Cooking for Blockheads

Cooking for Blockheads

145M Downloads

NoClassDefFoundError [Update to MouseTweaks 2.8 to fix]

DeadSix27 opened this issue ยท 15 comments

commented

Versions:
CookingForBlockheads_1.10.2-4.2.35.jar
MouseTweaks-2.7.3-mc1.10.2.jar

This stracktrace mentions this mod and mousetweaks as cause, so I'm unsure which one of those causes it.

Other issue link: https://bitbucket.org/YaLTeR/mouse-tweaks/issues/6/noclassdeffounderror-error-upon-accessing

Stacktrace: https://paste.ubuntu.com/24098307/

commented

That's kind of my fault, in update to 1.11 I completely reworked the API and removed the old class, and forgot to restore it when backporting the latest version back to Minecraft 1.10.2 (I was also pretty sure no one used it). I should probably add the old class back to the 1.10.2 version.

commented

@YaLTeR On the topic of reworking APIs, since you're here right now, I'd love if it was easier to disable Mouse Tweaks in a gui container. Like with an annotation or something. Having to implement a huge interface just to return false in one function is very cluttery. :(

Edit: In fact I'm having trouble getting the interface implemented in 1.11 at all. It's referencing Minecraft classes via notch names rather than srg names, causing this to happen.

commented

I just started having this same crash. Hopefully an update is coming soon?

commented

Edit: In fact I'm having trouble getting the interface implemented in 1.11 at all. It's referencing Minecraft classes via notch names rather than srg names, causing this to happen.

Doesn't it work if you implement it using the deobfuscated .java API interface from my bitbucket repo? I'm pretty sure Forge can handle all the obfuscation business.

On the topic of reworking APIs, since you're here right now, I'd love if it was easier to disable Mouse Tweaks in a gui container. Like with an annotation or something. Having to implement a huge interface just to return false in one function is very cluttery. :(

I'm not sure how to detect an annotation, do you have some link where I can read about it? Also why would you want to disable MT for the whole container?

commented

Doesn't it work if you implement it using the deobfuscated .java API interface from my bitbucket repo?

That would work if I shipped the API in my jar (unless you know how to make Gradle include it in compiling but not in the final jar). At the moment I'm adding it as a compile-time dependency.

In order for me to ship the API in my jar safely you need to put a package.info with the API annotation into your api package. That way Forge knows which mod owns the API and will prefer that one when loading.

@API(owner = "mousetweaks", apiVersion = "1.0", provides = "MouseTweaksAPI")
package yalter.mousetweaks.api;

import net.minecraftforge.fml.common.API;

Java ignores unknown annotations so it should still work fine in a non-forge environment.

Also why would you want to disable MT for the whole container?

The mouse wheel tweak was causing the scrolling list in my recipe book to go wonky on fake slots with canTakeStack() == false (where you'd expect nothing to happen, but I think it still set inventoryChanged to true or something, causing my mod to update the list) and there isn't really any need for MouseTweaks to work inside that GUI so I took the easy route out.

I'm not sure how to detect an annotation, do you have some link where I can read about it?

// MouseTweaksIgnore.java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MouseTweaksIgnore {
}
// To check if a class is annotated
guiContainer.getClass().getAnnotation(MouseTweaksIgnore.class) != null
commented

I think I managed to get gradle to output an API JAR with compiled classes without obfuscation (looking at this repo as an example mainly). Could you check if you can use this properly for a compile time dependency? Mod and API

commented

Yup, class names are correct in the API jar and it works.

commented

So if everything works on that last .jar I'm gonna upload it to CurseForge along with a minecraft 1.10.2 version.

commented

Awesome, thanks.

commented

The same crash happens with Farming For Blockheads.

commented

Try updating to MouseTweaks 2.8. The issue should be solved.

commented

That would work if I shipped the API in my jar (unless you know how to make Gradle include it in compiling but not in the final jar). At the moment I'm adding it as a compile-time dependency.

I'm not sure if that works, but what about adding the Source JAR as a compile-time dependency? Or maybe I should be buiding another API jar with forge obf (can LiteLoader gradle even do that)?

In order for me to ship the API in my jar safely you need to put a package.info with the API annotation into your api package. That way Forge knows which mod owns the API and will prefer that one when loading.

@API(owner = "mousetweaks", apiVersion = "1.0", provides = "MouseTweaksAPI")
package yalter.mousetweaks.api;

import net.minecraftforge.fml.common.API;

Hmm I'll try this. Are there good docs available on this?

The mouse wheel tweak was causing the scrolling list in my recipe book to go wonky on fake slots with canTakeStack() == false (where you'd expect nothing to happen, but I think it still set inventoryChanged to true or something, causing my mod to update the list) and there isn't really any need for MouseTweaks to work inside that GUI so I took the easy route out.

What if you just set them as ignored slots with MT_isIgnored()? That's what I did for GuiContainerCreative and it allows both scrolling the view properly and using RMB tweak and whatnot in the player inventory.

Annotation stuff

I'll definitely check this out, I always thought having to implement the whole interface just to disable the mod was stupid.

commented

I'm not sure if that works, but what about adding the Source JAR as a compile-time dependency?

I tried that, but since the .java files are not compiled they'll just be available as resources, rather than classes.

Are there good docs available on this?

Not sure if there's anything official, but this basically covers it: https://github.com/Minalien/BlogArchive/blob/master/ForgeTutorials/Spotlight__API_Annotation.md

What if you just set them as ignored slots with MT_isIgnored()?

I haven't tried that. It's just that you really don't need to move items around in my screen, the inventory part is more for visual feedback. It's all based on clicking on fake slots rather than moving items. Also looking at the video again it doesn't seem to be the mousewheel tweak after all, rather it just likes to break with MouseTweaks enabled for some reason.

commented

Ok, I added the old API interface, the annotations and package-info.java here. Could you check if I did the package-info.java part right before switching to annotations? Built MouseTweaks JAR

commented

Looks good!