Botania (Fabric/Quilt)

Botania (Fabric/Quilt)

5M Downloads

ItemReachRing configurability modification

adamrisihs opened this issue ยท 2 comments

commented

I've been experimenting with Botania recently, and I have a small request: Would you mind making the additional reach the Reach Ring gives be settable via NBT attribute? It would make the tool just a little more handy in creative mode, and should have no impact unless the player explicitly summons a ring with the desired reach. I've played w/ it in 1.15.2 (code below), but haven't implemented it for 1.16.2.

Here's my 1.15.2 code:
...
import vazkii.botania.common.core.helper.ItemNBTHelper;
public class ItemReachRing extends ItemBauble {
private static final String TAG_REACH_DISTANCE = "reachDistance";

public ItemReachRing(Properties props) {
	super(props);
}

    @Override
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
	Multimap<String, AttributeModifier> attributes = HashMultimap.create();
	attributes.put(PlayerEntity.REACH_DISTANCE.getName(),
                           new AttributeModifier(getBaubleUUID(stack),
                                                 "Reach Ring",
                                                 ItemNBTHelper.getDouble(stack, TAG_REACH_DISTANCE, 3.5),
                                                 AttributeModifier.Operation.ADDITION));
	return attributes;
}

}

Thank you for the mod!

commented

Looks like Curios has a form of overriding this, see CuriosHelper#getAttributeModifiers. It looks basically identical to what vanilla does for armor and held items.

For 1.15, this code is present in CurioUtils#getAttributeModifiers and looks basically identical.

commented

Awesome, thank you!

For future googlers: If you are looking to add an AttributeModifiers field to an item that is being worn in a curio slot, you need to use "CurioAttributeModifiers", not "AttributeModifiers". For example, here's how to create a Botania Reach Ring with a longer reach range:

/give @p botania:reach_ring{display:{Name:"{\"text\":\"Ring of Extra Far Reach\"}"},CurioAttributeModifiers:[{Name:reach, AttributeName:generic.reachDistance, Amount:12, Operation:0, Slot:ring, UUIDLeast:12, UUIDMost:14113}]}