#Sime-dynamic items

22 messages · Page 1 of 1 (latest)

tulip adder
#

Hi!
Maybe someone has encountered the need to create semi-dynamic items like tools from Tinkers Construct or Tetra with durability and other stats depends on the material, maybe there are libraries for this? If not, then perhaps you may have some ideas how to implement such a thing better?

strong obsidian
#

item attributes are component based
components can be set via recipe outputs

use a custom recipe type that takes tags for each part
add the parts to those tags
add the part types/stats to their own data components
add the modifiers from those parts to the itemstack's attribute component
use a combined model for the parts that takes each of the "part" components and renders the model it refers to

tulip adder
tulip adder
#

Sadly, I can't extends ItemStack to make it more suitable for me...

#

I have this, but it didn't affect at item. Its stored into item NBT.

strong obsidian
#

are you datagenning your recipe?

#

when generating the output, you can set the data components of the item:

stack.set(DataComponentTypes.MAX_DAMAGE, 1000);
AttributeModifiersComponent attributes = AttributeModifiersComponent.builder().add(
  EntityAttributes.BLOCK_BREAK_SPEED,
  new EntityAttributeModifier(
    TOOL_HANDLE_IDENTIFIER, 
    2.0, 
    EntityAttributeModifier.Operation.ADD_VALUE),   
  AttributeModifierSlot.MAINHAND);
stack.set(ATTRIBUTE_MODIFIERS, attributes);
#

in this case, the TOOL_HANDLE_IDENTIFIER would be unique to tool handles so that you wouldnt have different parts overriding other parts modifiers

#

ideally, you could use the builder to pass into some method that adds all of a given part's modifiers, so you iterate the parts, and the parts contain the modifiers you add. then each part could be its own itemstack

tulip adder
#

Ye, now I see the components you are talking about don't exist in 1.20.1 unfortunately, so I guess I need to find another way to do it.

tulip adder
#

If you want to know more specifically, I've posted the project on Github.

tulip adder
#

So, I found a way to change the mining speed (luckily a simple override on the method was enough).
-# However, unfortunately, I don't know what to do about the item's durability and tier and also model..

slate flame
slate flame
#

kinda like the bow does

strong obsidian
#

you should have a DynamicRenderer stuff from fabric api, and a method getAttributes or getAttributeMap or something similar (check the SwordItem, it should do that. fabric api provides an itemstack aware one)

#

(isSuitableFor may also be useful since you are on a version before the datafication of that too)