Security Craft

Security Craft

54M Downloads

Server crash when accessing keypad chest from ComputerCraft due to false assumption

MCJack123 opened this issue ยท 1 comments

commented

I'm a user on the ComputerCraft Discord server, and someone has recently told us that there was an issue when using SecurityCraft keypad chests and ComputerCraft turtles. I'm making this issue on their behalf.

Here is the crash log they sent.

The crash log leads to this line:

This assumes that side is not null, since as far as I can tell from the source code of Minecraft, BlockPos.offset does not like null arguments. However, ComputerCraft calls this function with side as null:

CC-Tweaked/src/main/java/dan200/computercraft/shared/peripheral/generic/GenericPeripheralProvider.java
Line 48 in 1316d6a
LazyOptional<?> wrapper = tile.getCapability( capability );

This causes KeypadChestTileEntity.getCapability to call BlockPos.offset with a null argument, causing the server to crash.

To reproduce, place a keypad chest down, and place a turtle facing the chest, but a few blocks away. Then place some fuel in the turtle's inventory and run refuel. Finally, run go forward 100 in the turtle to cause it to move towards the chest. Once it ends up next to the chest, the server will crash. (I haven't tested this myself, however.)

Environment:

  • Minecraft 1.16.4
  • SecurityCraft v1.8.20.2
  • CC: Tweaked 1.95.2
  • OS: Linux amd64
  • Java: 1.8.0_275

More info is available in the attached crash log.

commented

Thanks for bringing this to our attention. The contract of getCapability actually notes that the Direction argument is nullable, so we were violating that contract with our implementation.