Posted March 6, 20223 yr Hello, I am trying to create a block that will trigger a redstone power for 10~15 seconds after being right-clicked with a specific item. I can render the block when if has no functions/property. But when I try to add a 'is_activating' property, the game crash on load with the following exception: Quote [11:37:00] [Render thread/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: Cannot set property BooleanProperty{name=is_activating, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in Block{null} This is my block code (I copied the functions from the Lever class): public class ActivatorBlock extends HorizontalDirectionalBlock { public static final BooleanProperty IS_ACTIVATING = BooleanProperty.create("is_activating"); public ActivatorBlock(Properties properties) { super(properties); registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH).setValue(IS_ACTIVATING, Boolean.valueOf(false))); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { super.createBlockStateDefinition(builder); builder.add(FACING); } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { return defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); } @Override public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) { if (level.isClientSide) { BlockState blockstate1 = blockState.cycle(IS_ACTIVATING); return InteractionResult.SUCCESS; } else { BlockState blockstate = this.pull(blockState, level, blockPos); float f = blockstate.getValue(IS_ACTIVATING) ? 0.6F : 0.5F; level.playSound((Player)null, blockPos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f); level.gameEvent(player, blockstate.getValue(IS_ACTIVATING) ? GameEvent.BLOCK_SWITCH : GameEvent.BLOCK_UNSWITCH, blockPos); return InteractionResult.CONSUME; } } public BlockState pull(BlockState p_54677_, Level p_54678_, BlockPos p_54679_) { p_54677_ = p_54677_.cycle(IS_ACTIVATING); p_54678_.setBlock(p_54679_, p_54677_, 3); this.updateNeighbours(p_54677_, p_54678_, p_54679_); return p_54677_; } public int getSignal(BlockState p_54635_, BlockGetter p_54636_, BlockPos p_54637_, Direction p_54638_) { return p_54635_.getValue(IS_ACTIVATING) ? 15 : 0; } public int getDirectSignal(BlockState p_54670_, BlockGetter p_54671_, BlockPos p_54672_, Direction p_54673_) { return p_54670_.getValue(IS_ACTIVATING) ? 15 : 0; } public boolean isSignalSource(BlockState p_54675_) { return true; } private void updateNeighbours(BlockState p_54681_, Level p_54682_, BlockPos p_54683_) { p_54682_.updateNeighborsAt(p_54683_, this); //p_54682_.updateNeighborsAt(p_54683_.relative(getConnectedDirection(p_54681_).getOpposite()), this); } } The block is registered as: public static final BlockBehaviour.Properties TEST_BLOCK_PROPERTIES = BlockBehaviour.Properties .of(Material.GLASS, MaterialColor.TERRACOTTA_BLACK) .strength(-1.0F, 3600000.0F) .noDrops() .sound(SoundType.METAL); public static final RegistryObject<Block> ACTIVATOR_BLOCK = BLOCKS.register("activator_block", () -> new ActivatorBlock(TEST_BLOCK_PROPERTIES)); Edited March 6, 20223 yr by Ideki
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.