MarkusBordihn / BOs-Easy-NPC

Create easily NPC for your world or for your mod.
Other
19 stars 7 forks source link

[Bug] Encountered an unexpected Exception with getTradingPlayer() and open trading screen. #145

Closed remanam closed 5 months ago

remanam commented 5 months ago

https://github.com/MarkusBordihn/BOs-Easy-NPC/issues/135

After the fix now when i rightclick on trader server crashes.

I uploaded error log in closed issue so you can all context of issue. If it's not comfortable i can copy all data from #135 to here

MarkusBordihn commented 5 months ago

Thanks for the report. I'm not really able to reproduce the crash.

image

Did you use a standard Forge client and server or is this a modified client and/or server ?

It looks like this is related to the used Java Version, so I will release a fix which should hopefully fix this for you.

remanam commented 5 months ago

Hm.

Yes I use standart forge server 1.20.1, forge 47.2.20

I reproduced crush 5 times.

May be I need to delete config after upgrading from 4.3.0 to 4.3.1 ?

MarkusBordihn commented 5 months ago

Should not be the issue with the config and is more related to the Java version or the server itself.

The server claims that getTradingPlayer does not exists:

[12:59:13] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
java.lang.AbstractMethodError: Receiver class de.markusbordihn.easynpc.entity.easynpc.npc.Villager does not define or inherit an implementation of the resolved method 'abstract net.minecraft.world.entity.player.Player getTradingPlayer()' of interface de.markusbordihn.easynpc.entity.easynpc.data.TradingData.
at de.markusbordihn.easynpc.entity.easynpc.data.TradingData.isTrading(TradingData.java:256) ~[easy_npc_1.20.1-4.3.1.jar%23204!/:4.3.1] {re:classloading}
at de.markusbordihn.easynpc.entity.easynpc.data.TradingData.openTradingScreen(TradingData.java:398) ~[easy_npc_1.20.1-4.3.1.jar%23204!/:4.3.1] {re:classloading}

However, it clearly exists in the code: https://github.com/MarkusBordihn/BOs-Easy-NPC/blob/ef43e6c2c7c6eeaca724b69ccd8d3374258ee687/Common/src/main/java/de/markusbordihn/easynpc/entity/EasyNPCBaseEntity.java#L237

I will add some additional Java specific hints which will hopefully fix this.

remanam commented 5 months ago

Very funny. Yeah I see it exists. If there is a fix it will be awesome and I'm going to try find problem

remanam commented 5 months ago

Did you get you jar file from here ?

https://www.curseforge.com/minecraft/mc-mods/easy-npc/files/5244194

Also my java on server is 21 (don't know exact version), and

on PC java version "21.0.1" 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

McPersson commented 5 months ago

Faced a similar problem. If I trade with one merchant, the server crashes. He sells all kinds of weapons. Other trades just stopped opening. Appeared with the new version of the mod.

remanam commented 5 months ago

yeah, issue is repeated anyways :(

MarkusBordihn commented 5 months ago

Was able to reproduce the issue on another PC with the latest forge version. Working on a fix for this.

MarkusBordihn commented 5 months ago

Should be fixed with 4.3.3. See: https://modrinth.com/mod/easy-npc/version/6goQd23E

Let me know if you still running into any issues with trading. Thanks.

MarkusBordihn commented 5 months ago

Also my java on server is 21 (don't know exact version), and ...

1.20.1 normally runs on Java 17, this explain why I'm not getting the same error here. Java 21 is more restricted, so specific parts needs to be coded differently.

But good to know that this will cause such weird issues and crashes. ;)

1.21 is the first version which is officially using Java 21, see: https://www.minecraft.net/en-us/article/minecraft-snapshot-24w14a

remanam commented 5 months ago

Yes it's working now! But i thought any player could trade. Now only one per npc can trade. But at least crashes are gone, you are a god programmer :)