Skip to content

Commit

Permalink
Prevent tater boxes from granting armor (#154)
Browse files Browse the repository at this point in the history
Fixes #153
  • Loading branch information
haykam821 authored Sep 7, 2023
1 parent 760d19f commit adce6ca
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/xyz/nucleoid/extras/lobby/item/TaterBoxItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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.*;
Expand All @@ -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");

Expand All @@ -44,7 +46,7 @@ public class TaterBoxItem extends ArmorItem implements PolymerItem {
public static final TagKey<Block> 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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
Expand Down

0 comments on commit adce6ca

Please sign in to comment.