From 65abbe64c453e2e7e7e5ac7d6b4fc6fcf2cd4e0f Mon Sep 17 00:00:00 2001 From: Luligabi1 <33578169+Luligabi1@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:37:21 -0300 Subject: [PATCH] Add trial grief whitelist block tag (part of #141) --- base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt | 10 ++++++++++ .../dev/nathanpb/dml/trial/TrialGriefPrevention.kt | 10 +++------- .../tags/blocks/trial_grief_whitelist.json | 7 +++++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt create mode 100644 base/src/main/resources/data/dml-refabricated/tags/blocks/trial_grief_whitelist.json diff --git a/base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt b/base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt new file mode 100644 index 00000000..4a8dfb0e --- /dev/null +++ b/base/src/main/kotlin/dev/nathanpb/dml/misc/Tags.kt @@ -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 = TagKey.of(RegistryKeys.BLOCK, identifier("trial_grief_whitelist")) \ No newline at end of file diff --git a/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt b/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt index 529b63cb..26e92cd1 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/trial/TrialGriefPrevention.kt @@ -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 @@ -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 { @@ -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 diff --git a/base/src/main/resources/data/dml-refabricated/tags/blocks/trial_grief_whitelist.json b/base/src/main/resources/data/dml-refabricated/tags/blocks/trial_grief_whitelist.json new file mode 100644 index 00000000..b5ab71de --- /dev/null +++ b/base/src/main/resources/data/dml-refabricated/tags/blocks/trial_grief_whitelist.json @@ -0,0 +1,7 @@ +{ + "values": [ + "#c:chests", + {"id": "yigd:grave", "required": false}, + {"id": "gravestones:gravestone", "required": false} + ] +}