Skip to content

Commit

Permalink
refactor: clean up laser permission checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemmmy committed Apr 7, 2024
1 parent ec67fce commit 5acef3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ systemProp.kotlinVersion = 1.9.23
fabricKotlinVersion = 1.10.19+kotlin.1.9.23

# Mod Properties
modVersion = 1.11.4
modVersion = 1.11.6
mavenGroup = io.sc3

# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class LaserEntity : Entity, IPlayerOwnable {
// Ensure the player is set up correctly
syncPositions(true)

if (!world.canPlayerModifyAt(player, position)) {
if (!canBreakBlock(world, position, false, player)) {
potency = -1f
return
}
Expand All @@ -273,10 +273,8 @@ class LaserEntity : Entity, IPlayerOwnable {
potency -= hardness

// Ignite TNT blocks
if (canBreakBlock(world, position, false, player)) {
TntBlockInvoker.invokePrimeTnt(world, position, player)
world.removeBlock(position, false)
}
TntBlockInvoker.invokePrimeTnt(world, position, player)
world.removeBlock(position, false)
} else if (block === Blocks.OBSIDIAN) {
potency -= hardness

Expand All @@ -285,13 +283,8 @@ class LaserEntity : Entity, IPlayerOwnable {
val offsetState = world.getBlockState(offset)
if (!offsetState.isAir) return

// Check that both the obsidian and the offset side (fire placement location) are trusted
if (
!world.server.isSpawnProtected(world, position, player)
&& !world.server.isSpawnProtected(world, offset, player)
&& canBreakBlock(world, position, false, player)
&& canBreakBlock(world, offset, false, player)
) {
// The obsidian block is checked above, but check the place we're putting the fire too
if (canBreakBlock(world, offset, false, player)) {
world.playSound(null, offset, ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0f,
rand.nextFloat() * 0.4f + 0.8f)
world.setBlockState(offset, Blocks.FIRE.defaultState)
Expand Down

0 comments on commit 5acef3a

Please sign in to comment.