Skip to content

Commit

Permalink
Make Break Block check for permission (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object authored Aug 14, 2024
2 parents 3fece7e + 0681c82 commit de10fa6
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.phys.Vec3

object OpBreakBlock : SpellAction {
Expand Down Expand Up @@ -40,6 +41,12 @@ object OpBreakBlock : SpellAction {
!blockstate.isAir
&& blockstate.getDestroySpeed(env.world, pos) >= 0f // fix being able to break bedrock &c
&& IXplatAbstractions.INSTANCE.isCorrectTierForDrops(tier, blockstate)
&& IXplatAbstractions.INSTANCE.isBreakingAllowed(
env.world,
pos,
blockstate,
env.castingEntity as? ServerPlayer
)
) {
env.world.destroyBlock(pos, true, env.castingEntity)
}
Expand Down

0 comments on commit de10fa6

Please sign in to comment.