Crash: Invalid block entity #4812
Answered
by
ffmsb
ffmsb
asked this question in
Mod Dev Support
-
DescriptionI was trying to create a custom brushable block. Unfortunately when the block is placed into the world the game crashes.
The Codeprivate static final RegistryKey<Block> SUSPICIOUS_COBBLE_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(SKYER.MOD_ID,"suspicius_cobble"));
public static final Block SUSPICIOUS_COBBLE = Registry.register(
Registries.BLOCK,
SUSPICIOUS_COBBLE_KEY,
new SuspiciousCobble(Blocks.COBBLESTONE, SoundEvents.ITEM_BRUSH_BRUSHING_GENERIC, SoundEvents.ITEM_BRUSH_BRUSHING_GENERIC,
AbstractBlock.Settings.copy(Blocks.COBBLESTONE).registryKey(SUSPICIOUS_COBBLE_KEY) )
);
public static final BlockEntityType<?> SUSPICIOUS_COBBLE_ENTITY = Registry.register(Registries.BLOCK_ENTITY_TYPE,
RegistryKey.of(RegistryKeys.BLOCK_ENTITY_TYPE, Identifier.of(SKYER.MOD_ID, "suspicius_cobble")),
FabricBlockEntityTypeBuilder.create(SuspiciousCobbleEntity::new, SUSPICIOUS_COBBLE).build()
); class SuspiciousCobble extends BrushableBlock {
public SuspiciousCobble(Block baseBlock, SoundEvent brushingSound, SoundEvent brushingCompleteSound, Settings settings) {
super(baseBlock, brushingSound, brushingCompleteSound, settings);
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new SuspiciousCobbleEntity(pos, state);
}
}
class SuspiciousCobbleEntity extends BrushableBlockEntity {
public SuspiciousCobbleEntity(BlockPos pos, BlockState state) {
super(pos, state);
}
@Override
public BlockEntityType<?> getType() {
return ModBlocks.SUSPICIOUS_COBBLE_ENTITY;
}
} This code is strongly inspired by https://modrinth.com/mod/suspicious-snow , |
Beta Was this translation helpful? Give feedback.
Answered by
ffmsb
Aug 15, 2025
Replies: 1 comment
-
Solved by changing the supports function: public class SuspiciousCobbleEntity extends BrushableBlockEntity {
public SuspiciousCobbleEntity(BlockPos pos, BlockState state) {
super(pos, state);
}
@Override
public BlockEntityType<?> getType() {
return ModBlocks.SUSPICIOUS_COBBLE_ENTITY;
}
public boolean supports(BlockState state) {
return this.getType().supports(state);
}
} I don't know why this works, but it does the job. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ffmsb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved by changing the supports function:
I don't know why this works, but it does the job.