The issue is that the `entity` variable isn't actually an `EntityInternal` so there's a ClassCastException. I made this change and it appeared to resolve the issue. I didn't realise that it had the consequence you described (especially as it passed review on the 0.6.x branch PR).

What's a more appropriate solution for this?