mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-28 15:38:00 +01:00
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
|
package com.minelittlepony.unicopia.item;
|
||
|
|
||
|
import com.minelittlepony.unicopia.trinkets.TrinketsDelegate;
|
||
|
|
||
|
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||
|
import net.minecraft.entity.EquipmentSlot;
|
||
|
import net.minecraft.entity.LivingEntity;
|
||
|
import net.minecraft.item.ArmorMaterials;
|
||
|
import net.minecraft.item.ItemStack;
|
||
|
import net.minecraft.sound.SoundEvent;
|
||
|
|
||
|
public class GlassesItem extends WearableItem {
|
||
|
public GlassesItem(FabricItemSettings settings) {
|
||
|
super(settings);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public SoundEvent getEquipSound() {
|
||
|
return ArmorMaterials.LEATHER.getEquipSound();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public EquipmentSlot getPreferredSlot(ItemStack stack) {
|
||
|
return EquipmentSlot.HEAD;
|
||
|
}
|
||
|
|
||
|
public boolean isApplicable(LivingEntity entity) {
|
||
|
return getForEntity(entity).getItem() == this;
|
||
|
}
|
||
|
|
||
|
public static ItemStack getForEntity(LivingEntity entity) {
|
||
|
return TrinketsDelegate.getInstance().getEquipped(entity, TrinketsDelegate.FACE)
|
||
|
.filter(stack -> stack.getItem() instanceof GlassesItem)
|
||
|
.findFirst()
|
||
|
.orElse(ItemStack.EMPTY);
|
||
|
}
|
||
|
}
|