sisby-folk / switchy

A minecraft mod that combines player personalization features from other mods into presets.
https://modrinth.com/mod/switchy
GNU Lesser General Public License v3.0
12 stars 8 forks source link

upd2: Switchy compatible with IlMusuEnchantmentsMod!, but does not remember things in his pockets #70

Closed mrcrashmer closed 5 months ago

mrcrashmer commented 5 months ago

I get an error every time I turn on the module. Fabric 1.20.1 Server [02:45:08] [Server thread/ERROR]: [Switchy] Module switchy_inventories:inventories failed to update! Error:

java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1657.method_37908()" because "player" is null Then this error is spammed into the console and after 10 seconds the server fails write if you need to provide more information

sisby-folk commented 5 months ago

Yep, this is the same issue as #53 - basically, switchy inventories constructs player inventories without players associated with them. If a mod attempts to access the player (on this case, inventory.player.getworld()) without null safety, it will fail.

Feel free to upload and post a full log from https://mclo.gs/ if you don't have infinitory installed, and we can see if another mod has the same issue.

mrcrashmer commented 5 months ago

Thanks for the quick response, I shortened the lines leaving errors, I hope this helps. And, yes, infinitory is not installed latest.log

sisby-folk commented 5 months ago

Could you try out this jar in your pack and post latest.log to mclogs again? I've just made the error print the full stack trace, so we might see which mod is getting the world.

switchy-2.9.1+1.20.jar.zip

mrcrashmer commented 5 months ago

image Okay, it worked, I highlighted the mod that creates the problem. It's already cool that we know what the reason is. Specifically here - the mod adds enchantment and one of them (it creates additional slots in the inventory and pops up in the log image I know very little about the structure of the mod, but recording data about things in pocket slots is not recorded in the player's data and it is not known (to me) where the mod stores information. I am very glad if I helped you. I will create a theme on github from the author of the mod

sisby-folk commented 5 months ago

The mod author should be able to just null check the player and not perform the usual operations when the player is null, but feel free to send a link to the mod repo as well and I can have a look at the code.

mrcrashmer commented 5 months ago

https://github.com/IlMusu/IlMusuEnchantmentsMod.git The author of the mod does not look active enough by github standards). But yours, like his mod, is cool and has no alternatives, especially for version 1.20 I hope to be able to solve the compatibility problem in the future

sisby-folk commented 5 months ago

The problematic line is CustomCallbacksMixins.java#L241

PlayerEquipCallback.ARMOR.invoker().handler(inventory.player, stack, equipmentSlot);

to

if (inventory.player != null) PlayerEquipCallback.ARMOR.invoker().handler(inventory.player, stack, equipmentSlot);

sisby-folk commented 5 months ago

The author pushed an update last week so it should be fixed soon.

mrcrashmer commented 5 months ago

Okay, Switchy and Ilmusuinchants are working together! Great, but there's a point that bothers me. Switchy refuses to memorize things in his pants pockets with enchantment. I don't know how this can be done, or I should write an issue just on the topic of enchantment fashion. Just mark it if there is no need to do it, or if it should be done on the side not of your mod. Special thanks for the help, now I can use your mods to the fullest!

sisby-folk commented 5 months ago

swapping out new modded data requires a switchy module! IlMusuEnchantments stores its pockets in a different location to the player inventory, so the mod would need explicit code to support switchy (like trinkets) feel free to open a fresh issue if you'd like to track that - but we won't build it on to switchy inventories, so it'd have to be on their end if they wanted it, or an independent addon to both.

mrcrashmer commented 5 months ago

I think I'm the only one who noticed it. In general, it doesn't matter or make sense right now. There is just information that it does not work as we would like. For example, if we take into account the backpacked mod that I use, all things are registered in the backpack itself, and therefore it transfers its contents from switchy