Crash When Placing NetherEx Urn
ChloeDawn opened this issue ยท 9 comments
The game crashes to desktop when placing an Urn of Sorrow from NetherEx whilst sneaking, as you don't check if the tile is one of yours before casting to ISortingGridMember.
Relevant line: BlockHighlightHandler.java#L25
Forge version: 1.12-14.21.1.2424
Mod version: 4.1.4
Crash report: paste.ee/6tCb2
It's not an issue of casting on my side, it's the fact that NetherEx returns something that's not an ISortingGridMember
in their getCapability
implementation despite having been passed a sorting grid member capability. This should be fixed on NetherEx's side.
Because it shouldn't be necessary. The capability parameter is passed for a reason, and the JavaDocs state that getCapability should return The requested capability. Returns null when {@link #hasCapability(Capability, EnumFacing)} would return false.
Y'all are both right. The standard is to check if it has the capability first, in case someone is depending on that check for some reason. I do in NP, iirc.
Except, disallowing capability attachment, as NetherEx does, is also nonstandard. They should have checks and supercalls, as blay suggests.
Doing extra logic in hasCapability
would defeat its point of being a lightweight version and I can't find anything about mods having to call hasCapability
before calling getCapability
, neither in the Forge Documentation nor in the JavaDocs themselves - other than Forge's hopper hooks doing it.
If it's a standard (which in my opinion would just encourage bad code design by making getCapability needlessly more state-dependent), it needs to be properly documented, because it's far from obvious (compare to Java's map implementations, for example).