itzme1on Posted April 20, 2023 Posted April 20, 2023 Hello, Forge community! Please, help me. I can't find a method that is responsible for destroying a block if there are no other blocks underneath it. Do you know how this can be implemented? Quote Author / contributor of AlcoCraft+, Medieval Siege Machines, Epic Knights: Shields, Armor and Weapons
TheElementGuy Posted April 21, 2023 Posted April 21, 2023 (edited) Well, you could get the position, modify it to get the position of the block underneath, check if that block is air, and then destroy the original block using: ServerLevel#destroyBlock() Edited April 21, 2023 by TheElementGuy Incorrect info. 1 Quote Please don't put anything from 1.16.5, 1.12.2, 1.14, 1.15, 1.0, or anything not 1.18.x or 1.19.x!
warjort Posted April 21, 2023 Posted April 21, 2023 override BlockBehaviour.canSurvive() in your block. See for example DoorBlock. 1 Quote Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
itzme1on Posted April 21, 2023 Author Posted April 21, 2023 (edited) Thank you, guys! I just copy code from TorchBlock: @Override public BlockState updateShape(@NotNull BlockState state, @NotNull Direction direction, @NotNull BlockState state2, @NotNull LevelAccessor levelAccessor, @NotNull BlockPos pos, @NotNull BlockPos pos2) { return direction == Direction.DOWN && !this.canSurvive(state, levelAccessor, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, direction, state2, levelAccessor, pos, pos2); } Thanks for your ideas! Edited April 21, 2023 by itzme1on Wrong code Quote Author / contributor of AlcoCraft+, Medieval Siege Machines, Epic Knights: Shields, Armor and Weapons
Recommended Posts
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.