Started by
Kalmeira
on
Topic category: Help with Minecraft modding (Java Edition)
Since mcreator does not yet support adding attributes to items, I am trying to figure out how to do it with code. If I could get an example, I could probably figure it out from there. To further clarify, I don't mean spawning an item in with a command.
Also, I have tried using the attributes plugin (nerdy version) but could not get it to work with items. There is virtually no documentation for it and the plugin itself may be not working, hence why I am seeking help with code.
If you add this chunk of code to (ITEMNAME)Item.java It will add whatever attribute you set it as, you can also change the slot the item has to be put in for the attributes to work.
https://pastebin.com/0sKL1FUs
Thank you for your help.
@Nol_Inuse
I couldn't get it to work. I did add the imports and the code seemingly correctly. Errors and code:
error: method does not override or implement a method from a supertype @Override
error: incompatible types: EquipmentSlot cannot be converted to ItemStack builder.putAll(super.getDefaultAttributeModifiers(equipmentSlot));
error: cannot find symbol builder.put(Attributes.ENTITY_INTERACTION_RANGE, new AttributeModifier(UUID.fromString("1218abdb-72e3-44d6-b690-2867df6199c9"), "Item modifier", 2.0, AttributeModifier.Operation.ADDITION));
^
symbol: variable ADDITION
location: class Operation
error: incompatible types: EquipmentSlot cannot be converted to ItemStack return super.getDefaultAttributeModifiers(equipmentSlot);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
4 errors
Code (at the bottom of the .java class):