Skip to content

Commit

Permalink
Add trial grief whitelist block tag (part of #141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligabi1 committed Nov 3, 2023
1 parent 8cebf42 commit 65abbe6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 10 additions & 0 deletions base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.nathanpb.dml.misc

import dev.nathanpb.dml.identifier
import net.minecraft.block.Block
import net.minecraft.registry.RegistryKeys

import net.minecraft.registry.tag.TagKey


val TRIAL_GRIEF_WHITELIST: TagKey<Block> = TagKey.of(RegistryKeys.BLOCK, identifier("trial_grief_whitelist"))
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
package dev.nathanpb.dml.trial

import dev.nathanpb.dml.config
import dev.nathanpb.dml.misc.TRIAL_GRIEF_WHITELIST
import dev.nathanpb.dml.utils.runningTrials
import dev.nathanpb.dml.utils.squared
import dev.nathanpb.dml.utils.toBlockPos
import dev.nathanpb.dml.utils.toVec3i
import net.fabricmc.fabric.api.event.player.AttackBlockCallback
import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.minecraft.block.Blocks
import net.minecraft.entity.Entity
import net.minecraft.entity.damage.DamageSource
import net.minecraft.entity.mob.EndermanEntity
Expand All @@ -39,7 +39,6 @@ import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3d
import net.minecraft.world.World
import net.minecraft.world.explosion.Explosion
import net.minecraft.world.explosion.ExplosionBehavior

class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback {
Expand All @@ -65,11 +64,8 @@ class TrialGriefPrevention : AttackBlockCallback, UseBlockCallback {
!world.isClient
&& config.trial.interactGriefPrevention
&& isBlockProtected(world, pos)
&& world.getBlockState(pos)?.run {
block !== Blocks.CHEST
&& block !== Blocks.TRAPPED_CHEST
&& "grave" !in Registries.BLOCK.getId(block).path
} != false
&& !world.getBlockState(pos).isIn(TRIAL_GRIEF_WHITELIST)
&& "grave" !in Registries.BLOCK.getId(world.getBlockState(pos).block).path
) {
ActionResult.FAIL
} else ActionResult.PASS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"#c:chests",
{"id": "yigd:grave", "required": false},
{"id": "gravestones:gravestone", "required": false}
]
}

0 comments on commit 65abbe6

Please sign in to comment.