Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent tater boxes from granting armor #154

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading