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)
#Lemon problem (lemon are used as an example)
31 messages · Page 1 of 1 (latest)
Registries.register
Registries.register(lemonRegistry, myLemon, lemonId) (I may have swapped the last two args)
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.
Lemon problem (lemon are used as an example)
just use CLASS_MAP directly; if it's not public you can mixin into the other mod's class
i can't access variable since it's private
can mixin bypass that?
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?
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?
have a look at the 'getting a value' part, then you can use that method somewhere in your mod's init
- that's a field as far as i understand 2) i need to change value, not get it
actually not change value, but like add new element to MAP
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);
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.
oh ya, that's because it's not an obfucasted class (minecraft one). Add remap = false to the top in your @Mixin annotation
So, that error got fixed, new occured!
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
not familiar with how jujutsucraft works so I can't help there
may be worth looking into other addon mods
Sadly, there's no addons for this mod. The only supposet difference between techniques which appear and don't appear should be fact if they are added to that MAP.