Skip to content

Commit

Permalink
Add a tag for non-vibrating tater blocks
Browse files Browse the repository at this point in the history
Fixes #149
  • Loading branch information
haykam821 authored and Gegy committed Jun 6, 2024
1 parent fd03413 commit 26f05af
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,15 +17,14 @@
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;
import net.minecraft.util.math.Direction;
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 {
Expand All @@ -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<Block> LUCKY_TATER_DROPS = TagKey.of(RegistryKeys.BLOCK, LUCKY_TATER_DROPS_ID);

private final String cooldownTexture;

public LuckyTaterBlock(Settings settings, String texture, String cooldownTexture) {
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Block> VIRAL_TATERS = TagKey.of(RegistryKeys.BLOCK, VIRAL_TATERS_ID);

public TaterBoxItem(Settings settings) {
super(settings);
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/xyz/nucleoid/extras/tag/NEBlockTags.java
Original file line number Diff line number Diff line change
@@ -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<Block> LUCKY_TATER_DROPS = of("lucky_tater_drops");
public static final TagKey<Block> NON_VIBRATING_TATERS = of("non_vibrating_taters");
public static final TagKey<Block> VIRAL_TATERS = of("viral_taters");

private NEBlockTags() {
return;
}

private static TagKey<Block> of(String path) {
return TagKey.of(RegistryKeys.BLOCK, NucleoidExtras.identifier(path));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"#minecraft:dampens_vibrations",
"nucleoid_extras:warden_tater"
]
}

0 comments on commit 26f05af

Please sign in to comment.