#Lemon problem (lemon are used as an example)

31 messages · Page 1 of 1 (latest)

waxen wigeon
#

If there's mod that adds bunch of new types of lemons. And i want to add more lemons to this mod. It's okay, I make new class extend Lemon class. But the problem is: in original mod, in LemonClassRegistry, and in there is static initializer block which intitializes all types of lemon. Then how do I register my new lemon? I can't edit that LemonClassRegistry!? (Because it's literally a dependency in gradle, i can't edit files from there)

grand sphinx
#

Registries.register(lemonRegistry, myLemon, lemonId) (I may have swapped the last two args)

waxen wigeon
# grand sphinx Registries.register

The essential problem is that lemon is not an item, not an entity it's an instance of new class. And all this new classes are registered at one place.

waxen wigeon
#

Lemon problem (lemon are used as an example)

sick turtle
#

just use CLASS_MAP directly; if it's not public you can mixin into the other mod's class

waxen wigeon
#

i can't access variable since it's private

#

can mixin bypass that?

sick turtle
#

yeah

waxen wigeon
#

yapi

#

lemme try

waxen wigeon
# sick turtle yeah

Excuse me for bothering, i understand how to inject and change method, but as you can see in image above, CLASS_MAP is a private variable and it's not inside of a method. So how do I inject smth into it?

sick turtle
#

alternatively you can inject into <clinit> and @Shadow the CLASS_MAP

waxen wigeon
#

even though I read wiki i have few questions/problems with it

#

i don't quite get what i am doing wrong & what throw new Assertion error even means?

sick turtle
#

have a look at the 'getting a value' part, then you can use that method somewhere in your mod's init

waxen wigeon
#

actually not change value, but like add new element to MAP

sick turtle
#

yeah you'd want to just get the map value

#

so something like this in the mixin

@Accessor("CLASS_MAP")
public static Map<String, Class<? extends InnateClass>> getClassMap() {
    throw new AssertionError();
}
#

then e.g. in your mod init <mixin>.getClassMap().put("my_custom_class", MyCustomClass.class);

waxen wigeon
# sick turtle yeah you'd want to just get the map value

Hm, interesting thing happened. Essentially, i got this error warning: Unable to locate obfuscation mapping for @Accessor target CLASS_MAP
@Accessor("CLASS_MAP"). As far as I understand, the reason being CLASS_MAP is inside of InnateClassRegistry, not InnateClass.

sick turtle
#

oh ya, that's because it's not an obfucasted class (minecraft one). Add remap = false to the top in your @Mixin annotation

waxen wigeon
#

So, that error got fixed, new occured!

sick turtle
#

try make your mixin an interface

waxen wigeon
# sick turtle try make your mixin an interface

Thanks, this in fact fixed the issue. And the mixin... succesfully did nothing? I putted that line inside of ModInitialize? Yet it didn't work, without an error which is a weird part. Moreover, in my new class I reference not existing image, but no error even about that there is

sick turtle
#

not familiar with how jujutsucraft works so I can't help there

#

may be worth looking into other addon mods

waxen wigeon