Trinkets (Fabric)

Trinkets (Fabric)

22M Downloads

[Wiki] Quick Start Guide has some incorrect syntax

Desynq opened this issue ยท 1 comments

commented

Link

original:

public class MyAglet extends TrinketItem {

  public MyAglet(Settings settings) {
    super(settings);
  }

  public Multimap<EntityAttribute, EntityAttributeModifier> getModifiers(ItemStack stack, SlotReference slot, LivingEntity entity, UUID uuid) {
    var modifiers = super.getModifiers(stack, slot, entity, uuid);
    // +10% movement speed
    modifiers.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(uuid, "guidemod:movement_speed", 0.1, EntityAttributeModifier.Operation.MULTIPLY_TOTAL);
    // If the player has access to ring slots, this will give them an extra one
    SlotAttributes.addSlotModifier(modifiers, "hand/ring", uuid, 1, EntityAttributeModifiers.Operation.ADDITION);
    return modifiers;
  }
}

revised:

public class MyAglet extends TrinketItem {

  public MyAglet(Settings settings) {
    super(settings);
  }

  public Multimap<EntityAttribute, EntityAttributeModifier> getModifiers(ItemStack stack, SlotReference slot, LivingEntity entity, UUID uuid) {
    var modifiers = super.getModifiers(stack, slot, entity, uuid);
    // +10% movement speed
    modifiers.put(EntityAttributes.GENERIC_MOVEMENT_SPEED, new EntityAttributeModifier(uuid, "guidemod:movement_speed", 0.1, EntityAttributeModifier.Operation.MULTIPLY_TOTAL));
    // If the player has access to ring slots, this will give them an extra one
    SlotAttributes.addSlotModifier(modifiers, "hand/ring", uuid, 1, EntityAttributeModifier.Operation.ADDITION);
    return modifiers;
  }
}

Revisions are fixing a typo with EntityAttributeModifiers to EntityAttributeModifier at line 13 and adding a missing parenthesis at line 11.

commented

Thanks for pointing this out, documentation has been adjusted.