From dd7a62f042c38f3ced57555cb3d880d898e23d43 Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Thu, 7 Sep 2023 11:34:26 -0400 Subject: [PATCH] Prevent tater boxes from granting armor Fixes #153 --- .../nucleoid/extras/lobby/item/TaterBoxItem.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/nucleoid/extras/lobby/item/TaterBoxItem.java b/src/main/java/xyz/nucleoid/extras/lobby/item/TaterBoxItem.java index d221691..edbaefc 100644 --- a/src/main/java/xyz/nucleoid/extras/lobby/item/TaterBoxItem.java +++ b/src/main/java/xyz/nucleoid/extras/lobby/item/TaterBoxItem.java @@ -5,6 +5,7 @@ import eu.pb4.sgui.api.elements.GuiElementInterface; import net.minecraft.block.Block; import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.StackReference; import net.minecraft.item.*; @@ -17,6 +18,7 @@ import net.minecraft.registry.tag.TagKey; import net.minecraft.screen.slot.Slot; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.sound.SoundCategory; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.*; @@ -31,7 +33,7 @@ import java.util.*; -public class TaterBoxItem extends ArmorItem implements PolymerItem { +public class TaterBoxItem extends Item implements PolymerItem, Equipment { private static final Text NOT_OWNER_MESSAGE = Text.translatable("text.nucleoid_extras.tater_box.not_owner").formatted(Formatting.RED); public static final Text NONE_TEXT = Text.translatable("text.nucleoid_extras.tater_box.none"); @@ -44,7 +46,7 @@ public class TaterBoxItem extends ArmorItem implements PolymerItem { public static final TagKey VIRAL_TATERS = TagKey.of(RegistryKeys.BLOCK, VIRAL_TATERS_ID); public TaterBoxItem(Settings settings) { - super(ArmorMaterials.LEATHER, ArmorItem.Type.HELMET, settings); + super(settings); } private ActionResult isOwner(ItemStack stack, PlayerEntity player) { @@ -115,6 +117,8 @@ private void openTaterBox(World world, PlayerEntity user, ItemStack stack, Hand ui.setHideUnfound(true); ui.setTitle(this.getTitle((ServerPlayerEntity) user)); ui.open(); + + ((ServerPlayerEntity) user).playSound(this.getEquipSound(), SoundCategory.PLAYERS, 0.8f, 1); } } @@ -159,6 +163,11 @@ public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipContext context return out; } + @Override + public EquipmentSlot getSlotType() { + return EquipmentSlot.HEAD; + } + @Override public void appendTooltip(ItemStack stack, World world, List tooltip, TooltipContext context) { super.appendTooltip(stack, world, tooltip, context);