Skip to content

[Bug] BlockEntityType mixin is dangerous & slow #143

@embeddedt

Description

@embeddedt

Describe the bug

Create Casing injects a hook into BlockEntityType.isValid that disables the valid blocks check for specific block entity types. This is very inefficient, as it must check equality against each of the listed types, and is also dangerous as it bypasses the purpose of the check (to protect against a desync of the block entity and the block in the world, which happens under certain conditions).

If ability to dynamically add blocks from addons to the BE type is a goal, a better approach would be to use BlockEntityTypeAddBlocksEvent to add any desired blocks to the BlockEntityType's set of valid blocks at startup.

I've attached a profiler screenshot highlighting that most of the CPU time in the BlockEntityType.isValid method is consumed by this mixin hook. This profiler report was captured from the Craftoria 1.23.0 modpack.

Image

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions