CubeGrid.GetCubeBlock returns null if target is IMySlimBlock
There already was a bug report 4 years ago:
But since there was no resolution 4 years later I'll assume it has fallen through the system and open a new report.
The Problem:
IMyCubeGrid.GetCubeBlock returns null even if there is a block at the given position.
The reason (if the code on github is up to date):
The function makes a security check for "Fatblocks", so one can't get access to blocks one is not supposed to have. It is however ignored that for "non Fatblocks" this is not necessary.
The weird part:
The ingame script has access to IMySlimBlock, but to my knowledge the currently is no way to get a truly slim block.
Given the return type of IMyCubeGrid.GetCubeBlock it seems that it was intended to be exactly that pathway.
The following code is a modification of the code on github which leaves the check intact, but returns the truly slim blocks.
VRage.Game.ModAPI.Ingame.IMySlimBlock VRage.Game.ModAPI.Ingame.IMyCubeGrid.GetCubeBlock(Vector3I position) { VRage.Game.ModAPI.Ingame.IMySlimBlock block = GetCubeBlock(position); if (block != null && block.FatBlock != null) { if ((block.FatBlock is MyTerminalBlock) && (block.FatBlock as MyTerminalBlock).IsAccessibleForProgrammableBlock) { return block; } return null; } return block; }
Hello Shurlan,
Thank you for reaching our forum and letting us know about this issue.
We have put it into our internal system.
Kind Regards,
Keen Software House: QA Department
Hello Shurlan,
Thank you for reaching our forum and letting us know about this issue.
We have put it into our internal system.
Kind Regards,
Keen Software House: QA Department
Replies have been locked on this page!