From 26f05aff131e5c2771f0771454f579dba8a43904 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:50:37 -0400 Subject: [PATCH] Add a tag for non-vibrating tater blocks Fixes #149 --- .../extras/lobby/PlayerLobbyState.java | 3 ++- .../lobby/block/tater/LuckyTaterBlock.java | 10 ++-------- .../lobby/block/tater/WardenTaterBlock.java | 10 ++-------- .../extras/lobby/item/tater/TaterBoxItem.java | 6 ------ .../xyz/nucleoid/extras/tag/NEBlockTags.java | 20 +++++++++++++++++++ .../tags/blocks/non_vibrating_taters.json | 6 ++++++ 6 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 src/main/java/xyz/nucleoid/extras/tag/NEBlockTags.java create mode 100644 src/main/resources/data/nucleoid_extras/tags/blocks/non_vibrating_taters.json diff --git a/src/main/java/xyz/nucleoid/extras/lobby/PlayerLobbyState.java b/src/main/java/xyz/nucleoid/extras/lobby/PlayerLobbyState.java index 2c980961..fd3a44da 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/PlayerLobbyState.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/PlayerLobbyState.java @@ -24,6 +24,7 @@ import xyz.nucleoid.extras.lobby.block.tater.TinyPotatoBlock; import xyz.nucleoid.extras.lobby.item.tater.TaterBoxItem; import xyz.nucleoid.extras.mixin.lobby.ArmorStandEntityAccessor; +import xyz.nucleoid.extras.tag.NEBlockTags; import java.util.HashSet; import java.util.Set; @@ -56,7 +57,7 @@ public ActionResult collectTaterFromEntity(Entity entity, Vec3d hitPos, ItemStac if (targetStack.getItem() instanceof TaterBoxItem) { Block targetTater = TaterBoxItem.getSelectedTater(targetStack); - if (targetTater != null && targetTater.getDefaultState().isIn(TaterBoxItem.VIRAL_TATERS)) { + if (targetTater != null && targetTater.getDefaultState().isIn(NEBlockTags.VIRAL_TATERS)) { return this.collectTater(targetTater, stack, player); } } diff --git a/src/main/java/xyz/nucleoid/extras/lobby/block/tater/LuckyTaterBlock.java b/src/main/java/xyz/nucleoid/extras/lobby/block/tater/LuckyTaterBlock.java index 4c749736..8f593278 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/block/tater/LuckyTaterBlock.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/block/tater/LuckyTaterBlock.java @@ -7,9 +7,7 @@ import net.minecraft.particle.DustColorTransitionParticleEffect; import net.minecraft.particle.ParticleEffect; import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; -import net.minecraft.registry.tag.TagKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; @@ -19,7 +17,6 @@ import net.minecraft.state.property.Properties; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; -import net.minecraft.util.Identifier; import net.minecraft.util.collection.DataPool; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -27,7 +24,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.Random; import net.minecraft.world.World; -import xyz.nucleoid.extras.NucleoidExtras; +import xyz.nucleoid.extras.tag.NEBlockTags; import xyz.nucleoid.extras.util.SkinEncoder; public class LuckyTaterBlock extends CubicPotatoBlock { @@ -36,9 +33,6 @@ public class LuckyTaterBlock extends CubicPotatoBlock { private static final int COURAGE_TICKS = 5; private static final int COOLDOWN_TICKS = SharedConstants.TICKS_PER_MINUTE * 30; - private static final Identifier LUCKY_TATER_DROPS_ID = NucleoidExtras.identifier("lucky_tater_drops"); - private static final TagKey LUCKY_TATER_DROPS = TagKey.of(RegistryKeys.BLOCK, LUCKY_TATER_DROPS_ID); - private final String cooldownTexture; public LuckyTaterBlock(Settings settings, String texture, String cooldownTexture) { @@ -101,7 +95,7 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt } private Block getDrop(ServerWorld world) { - var drops = Registries.BLOCK.getEntryList(LUCKY_TATER_DROPS); + var drops = Registries.BLOCK.getEntryList(NEBlockTags.LUCKY_TATER_DROPS); if (drops.isEmpty()) { return null; diff --git a/src/main/java/xyz/nucleoid/extras/lobby/block/tater/WardenTaterBlock.java b/src/main/java/xyz/nucleoid/extras/lobby/block/tater/WardenTaterBlock.java index fc6c832f..66f9cd3e 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/block/tater/WardenTaterBlock.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/block/tater/WardenTaterBlock.java @@ -3,18 +3,17 @@ import it.unimi.dsi.fastutil.longs.LongArrayList; import it.unimi.dsi.fastutil.longs.LongList; import net.minecraft.SharedConstants; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.VibrationParticleEffect; -import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.event.BlockPositionSource; +import xyz.nucleoid.extras.tag.NEBlockTags; public class WardenTaterBlock extends CubicPotatoBlock { private static final int BOX_SIZE = 16; @@ -80,11 +79,6 @@ private static ParticleEffect getTaterVibrationParticleEffect(BlockPos pos, Serv } private static boolean isVibrationTater(BlockState state) { - if (state.isIn(BlockTags.OCCLUDES_VIBRATION_SIGNALS)) { - return false; - } - - Block block = state.getBlock(); - return block instanceof CubicPotatoBlock && !(block instanceof WardenTaterBlock); + return state.getBlock() instanceof TinyPotatoBlock && !state.isIn(NEBlockTags.NON_VIBRATING_TATERS); } } diff --git a/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterBoxItem.java b/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterBoxItem.java index 4e38925c..1f718c68 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterBoxItem.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/item/tater/TaterBoxItem.java @@ -12,8 +12,6 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.registry.Registries; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.tag.TagKey; import net.minecraft.screen.slot.Slot; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; @@ -22,7 +20,6 @@ import net.minecraft.util.*; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; -import xyz.nucleoid.extras.NucleoidExtras; import xyz.nucleoid.extras.lobby.PlayerLobbyState; import xyz.nucleoid.extras.lobby.block.tater.CorruptaterBlock; import xyz.nucleoid.extras.lobby.block.tater.CubicPotatoBlock; @@ -40,9 +37,6 @@ public class TaterBoxItem extends Item implements PolymerItem, Equipment { private static final String SELECTED_TATER_KEY = "SelectedTater"; private static final int COLOR = 0xCEADAA; - private static final Identifier VIRAL_TATERS_ID = NucleoidExtras.identifier("viral_taters"); - public static final TagKey VIRAL_TATERS = TagKey.of(RegistryKeys.BLOCK, VIRAL_TATERS_ID); - public TaterBoxItem(Settings settings) { super(settings); } diff --git a/src/main/java/xyz/nucleoid/extras/tag/NEBlockTags.java b/src/main/java/xyz/nucleoid/extras/tag/NEBlockTags.java new file mode 100644 index 00000000..a2dcfe90 --- /dev/null +++ b/src/main/java/xyz/nucleoid/extras/tag/NEBlockTags.java @@ -0,0 +1,20 @@ +package xyz.nucleoid.extras.tag; + +import net.minecraft.block.Block; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; +import xyz.nucleoid.extras.NucleoidExtras; + +public final class NEBlockTags { + public static final TagKey LUCKY_TATER_DROPS = of("lucky_tater_drops"); + public static final TagKey NON_VIBRATING_TATERS = of("non_vibrating_taters"); + public static final TagKey VIRAL_TATERS = of("viral_taters"); + + private NEBlockTags() { + return; + } + + private static TagKey of(String path) { + return TagKey.of(RegistryKeys.BLOCK, NucleoidExtras.identifier(path)); + } +} diff --git a/src/main/resources/data/nucleoid_extras/tags/blocks/non_vibrating_taters.json b/src/main/resources/data/nucleoid_extras/tags/blocks/non_vibrating_taters.json new file mode 100644 index 00000000..01cd8efd --- /dev/null +++ b/src/main/resources/data/nucleoid_extras/tags/blocks/non_vibrating_taters.json @@ -0,0 +1,6 @@ +{ + "values": [ + "#minecraft:dampens_vibrations", + "nucleoid_extras:warden_tater" + ] +}