Posted December 16, 20231 yr @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { if(!level.isClientSide&&hand == InteractionHand.MAIN_HAND) { boolean lit = state.getValue(LIT); if (lit) { new Thread(() -> { player.hurt(DamageSource.LIGHTNING_BOLT, 2); level.setBlock(pos, state.cycle(LIT), 3); try { Thread.sleep(300); }catch (Exception e){} level.setBlock(pos, state.cycle(LIT), 3); }).start(); } } return super.use(state, level, pos, player, hand, hitResult); } Why this not work? it doesn't go out
December 16, 20231 yr Please use the code button (looks like this: <>) in the post editor to paste formatted code, as plain text code all on one line is hard to follow. Official Forge Discord server | Support FAQ for players
December 16, 20231 yr Author @Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { if(!level.isClientSide&&hand == InteractionHand.MAIN_HAND) { boolean lit = state.getValue(LIT); if (lit) { new Thread(() -> { player.hurt(DamageSource.LIGHTNING_BOLT, 2); level.setBlock(pos, state.cycle(LIT), 3); try { Thread.sleep(300); }catch (Exception e){} level.setBlock(pos, state.cycle(LIT), 3); }).start(); } } return super.use(state, level, pos, player, hand, hitResult); } i`m sory Edited December 16, 20231 yr by Temenstro
December 16, 20231 yr Thanks, it looks like the issue might be caused by spawning and starting a new thread like that - I don't think that'll work. Official Forge Discord server | Support FAQ for players
December 16, 20231 yr Author how would you solve this problem? I mean adding a timeout before the block expires
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.