henkelmax / easy-piglins

Never get annoyed by bartering again!
3 stars 6 forks source link

NullPointerException is thrown when looking at Barterer with Jade installed #5

Closed yanang007 closed 2 years ago

yanang007 commented 2 years ago

Bug description When both Easy Piglins and Jade are installed, looking at a Barterer block will lead to a NullPointerException, causing Jade failing to show tooltip for barterer.

It looks likes that Easy Piglins failed to deal with getCapability calls from Jade.

This is where Jade calls getCapability. https://github.com/Snownee/Jade/blob/8cec1985a7d86db97fe3a13ddfea94f6351da823/src/main/java/snownee/jade/addon/forge/InventoryProvider.java#L132-L133

This is how auto trader handles it while side is null. https://github.com/henkelmax/easy-villagers/blob/e04174dec80edf6d85491ad298774bbb2d7e4dd2/src/main/java/de/maxhenkel/easyvillagers/blocks/tileentity/AutoTraderTileentity.java#L235-L239

And this is how barterer handles it. https://github.com/henkelmax/easy-piglins/blob/8c51dbac83822c5caab3f6c6ed8d0519f78c7796/src/main/java/de/maxhenkel/easypiglins/blocks/tileentity/BartererTileentity.java#L123-L131

I'm not sure which one is the right way to implement this method, but I guess this might be the cause for this issue.

Steps to reproduce the issue

  1. Install Easy Piglins and Jade
  2. Go into game, place a Barterer block and look at the block
  3. Jade tooltip fails to show up and log shows that a NullPointerException was thrown

Expected behavior Jade tooltip shows up correctly for Barterer block like Auto Trader from Easy Villagers.

Log files As the cause is obvious, so I would only show the related lines but a full log is ready to upload if needed. [21:55:11 ERROR]: Error executing task on Server java.lang.NullPointerException: Cannot invoke "net.minecraft.core.Direction.equals(Object)" because "side" is null at de.maxhenkel.easypiglins.blocks.tileentity.BartererTileentity.getCapability(BartererTileentity.java:125) ~[easy_piglins-1.18.2-1.0.2.jar%2394!/:1.18.2-1.0.2] at net.minecraftforge.common.capabilities.ICapabilityProvider.getCapability(ICapabilityProvider.java:34) ~[forge-1.18.2-40.1.0-universal.jar%23145!/:?] at snownee.jade.addon.forge.InventoryProvider.appendServerData(InventoryProvider.java:133) ~[Jade-1.18.2-5.1.0.jar%23107!/:5.1.0] at snownee.jade.addon.forge.InventoryProvider.appendServerData(InventoryProvider.java:41) ~[Jade-1.18.2-5.1.0.jar%23107!/:5.1.0] at mcp.mobius.waila.network.RequestTilePacket$Handler.lambda$onMessage$0(RequestTilePacket.java:62) ~[Jade-1.18.2-5.1.0.jar%23107!/:5.1.0] at net.minecraftforge.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:208) ~[forge-1.18.2-40.1.0-universal.jar%23145!/:?] at mcp.mobius.waila.network.RequestTilePacket$Handler.onMessage(RequestTilePacket.java:46) ~[Jade-1.18.2-5.1.0.jar%23107!/:5.1.0] at net.minecraftforge.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:114) ~[forge-1.18.2-40.1.0-universal.jar%23145!/:?] ...

Versions

Other mods Jade version: 1.18.2-5.1.0

yanang007 commented 2 years ago

Thanks for the great work!