Project MMO

Project MMO

11M Downloads

Crash with oritech enderic laser due to missing ServerPlayerEntity instance checks.

Rearth opened this issue ยท 7 comments

commented

Describe the bug
Hi, Oritech dev here. This bug was reported to me here: Rearth/Oritech#293
In Oritech there are machines that can kill entities, and have a custom class extender PlayerEntity as the killing entity set. The damagehandler class here: https://github.com/Caltinor/Project-MMO-2.0/blob/main/src/main/java/harmonised/pmmo/events/impl/DamageDealtHandler.java#L104 casts any playerentity on the server to a serverentity, which leads to a crash here. An additional instance check should be added in this method.

Expected behavior
Entity instance is checked to avoid crash.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions:

  • Minecraft: 1.21.1
  • Loader: Neoforge
  • Project MMO version pmmo-1.21.1-2.6.24

Additional context
Add any other context about the problem here.

commented

@Rearth is there a reason why your block entity doesn't extend FakePlayer? It is my understanding that is the standard method for simulating player-like behavior when not using an actual player. I ask because this is something i do check for due to things like Create's Deployer, which have similar behavior.

commented

@Rearth @Caltinor would re-coding the laser as a FakePlayer similar to how the mob masher is handled from Mob Grinding Utils

example below

example mob utils FakePlayer Handler.txt

commented

that would be my assumption. since the Forge FakePlayer is also an extension of ServerPlayer and you don't want BE behavior happening on the client outside of rendering for cheating purposes, it makes sense to extend this instead of the common-level player class. I say that from a purely theoretical position though because i do not know what the Oritech machines are doing at a technical level to know if this is the correct and practical solution.

commented

is there a way for us to exclude the oritech laser via some sort of config file?, I really want to put oritech and PMMO on our modpack so that mechanism isn't the prominent tech mod in the pack. any guidance would be appreciated.

commented

@KaydenXzilon , unfortunately there is not. Because Oritech is emulating an actual player class to perform block behavior, there is no way for pmmo to differentiate between a real player and this block. This is why the FakePlayers exist in the first place.

commented

Hi, sorry for the late response, missed the notifications here. I didn't actually know the fake player was a thing, and the custom player class was working pretty well.
However since Oritech is a multiloader mod using architectury, the solution on Oritechs side would be a bit more complicated. Fabric also has a fake player available, but Architectury does not, meaning I'd have to add loader specific code in each subproject and then reference that in the common code again, which always is annoying and brings other issues with it. Considering that this here is the only issue with this, the effort of fixing this on Oritechs side is not worth it to me.
Feel free to close this issue. I'd be happy to see the instance check I mentioned in the beginning added to pmmo (it should be a very small change), but I also can't expect you guys to work around me just because I'm using a multiloader setup.

commented

@Rearth I am surprised that the call to isClientSide() isn't detecting whether the world you are instantiating your anonymous player class with. In any case i will change the side-test condition to more explicitly look for server player classes, which should fix this error.