This commit is contained in:
Sollace 2021-03-03 20:32:51 +02:00
parent c21e492482
commit f511e2b346
2 changed files with 5 additions and 15 deletions

View file

@ -31,31 +31,21 @@ import net.minecraft.world.World;
public class AmuletItem extends WearableItem {
private final int maxEnergy;
private final float drain;
private final ImmutableMultimap<EntityAttribute, EntityAttributeModifier> modifiers;
public AmuletItem(FabricItemSettings settings, int maxEnergy, int drainRate) {
this(settings, maxEnergy, drainRate, ImmutableMultimap.builder());
public AmuletItem(FabricItemSettings settings, int maxEnergy) {
this(settings, maxEnergy, ImmutableMultimap.builder());
}
public AmuletItem(FabricItemSettings settings, int maxEnergy, int drainRate, ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> modifiers) {
public AmuletItem(FabricItemSettings settings, int maxEnergy, ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> modifiers) {
super(settings);
this.maxEnergy = maxEnergy;
drain = ((float)drainRate / (float)maxEnergy) / 10;
this.modifiers = modifiers.build();
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
/*if (world.isClient) {
return;
}
if (isChargable() && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack) {
consumeEnergy(stack, drain);
}*/
if (this == UItems.PEGASUS_AMULET
&& entity.world.getTime() % 6 == 0
&& entity instanceof LivingEntity

View file

@ -64,11 +64,11 @@ public interface UItems {
AmuletItem PEGASUS_AMULET = register("pegasus_amulet", new AmuletItem(new FabricItemSettings()
.maxDamage(890)
.rarity(Rarity.UNCOMMON)
.group(ItemGroup.DECORATIONS), 900, 10));
.group(ItemGroup.DECORATIONS), 900));
/*AmuletItem ALICORN_AMULET = register("alicorn_amulet", new AmuletItem(new AmuletItem.Settings("alicorn_amulet")
.toughness(900000000)
.resistance(90000000)
.group(ItemGroup.DECORATIONS), 0, 0));*/
.group(ItemGroup.DECORATIONS), 0));*/
static <T extends Item> T register(String name, T item) {
ITEMS.add(item);