jabelar / MovingLightSource-1.12

Jabelar's Moving Light Sources Mod
https://minecraft.curseforge.com/projects/jabelars-moving-light-sources
4 stars 2 forks source link

Crash with Better Records #10

Closed ClockwerkKaiser closed 6 years ago

ClockwerkKaiser commented 6 years ago

Here is a link the the crash report

It seems there is an issue when both Moving Light Sources and Better Records are in the same instance. The game won't even load. Seems to be an issue with the Strobe Light.

I'll send the same report to the Better Records issue tracker as well.

jabelar commented 6 years ago

Thanks for pointing this out.

That mod is developed in Kotlin language which is closely related to Java but I'm not super familiar with it. But one weird thing is that the code in his strobelight block has the following for the erroring method: override fun getLightValue(state: IBlockState, access: IBlockAccess, pos: BlockPos): Int { val te = access.getTileEntity(pos) if (te == null || te !is IRecordWire || te !is IRecordAmplitude) return 0 return if ((te as IRecordWire).connections.size > 0) 5 else 0 } which implies that it is overriding the block method (his block extends BlockContainer), but the Block type hierarchy in the 1.12 source I have shows this method prototypes: int getLightValue(IBlockAccess world, BlockPos pos);

So the weird thing is that his code is expecting another parameter which I would never pass based on the Java interface. I must be missing something. It is further weird because the Java method can handle null parameters, so the best fix would be for the other mod to handle it too -- like give out a value of no light when it is null, or else some other default value.

Anyway, I can handle the crash for now. The strobe light will not (of course) strobe while being held, although it might be fun to try to make that work in the future.

In any case, I'll make an update to handle this mod compatibility. Should be posted in next day or two.

jabelar commented 6 years ago

Okay, I fixed the issue in version 1.0.11 which should be approved on CurseForge for downloads pretty soon.

NicholasFeldman commented 5 years ago

Dev of better records, just chiming in on this issue:

On this line here, you call getDefaultState().getLightValue(null, null);, a method declared in the interface net.minecraft.block.state.IBlockProperties, implemented by IBlockState. in short, the method you're using exists on the BlockState, not the Block. I believe what you should do here is entry.getValue().getLightValue(entry.getDefaultState(), null, null). https://github.com/jabelar/MovingLightSource-1.12/blob/06251364c13af6ae2fa4b5991f58fce04be4a357/src/main/java/com/blogspot/jabelarminecraft/movinglightsource/blocks/BlockMovingLightSource.java#L123

However, the parameters to either method are not marked as @Nullable so I don't believe null should be passed in. This specifically would cause issues with at least BetterRecords for sure, since Kotlin is a null safe language.