Easy Piglins

Easy Piglins

8M Downloads

NullPointerException is thrown when looking at Barterer with Jade installed

yanang007 opened this issue · 1 comments

commented

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.

public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (!remove && cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (side.equals(Direction.DOWN)) {
return LazyOptional.of(this::getOutputInventoryItemHandler).cast();
} else {
return LazyOptional.of(this::getInputInventoryItemHandler).cast();
}
}

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

  • Minecraft version: 1.18.2
  • Forge version: 40.1.0
  • Mod version: 1.18.2-1.0.0

Other mods
Jade version: 1.18.2-5.1.0

commented

Thanks for the great work!