#Sime-dynamic items
22 messages · Page 1 of 1 (latest)
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
Well, that's a good start, thank you
Hello again!
How i can modify item durability, mining speed and other stats?
Do you have any examples?
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.
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
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.
Not sure what you meaning.
If you about this (screenshot 1), then no, i do it manually through custom recipe type (screenshot 2).
If you want to know more specifically, I've posted the project on Github.
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..
crazy that you're coding with the mc font
for the model you could either make a custom renderer, or give the model predicates, to change its texture/model based on some predefined values
kinda like the bow does
yeah, sorry, i didnt realize you were on a version that was nearly 1.5 years out of date
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)
BuiltinItemRendererRegistry for the renderer https://maven.fabricmc.net/docs/fabric-api-0.92.3+1.20.1/net/fabricmc/fabric/api/client/rendering/v1/BuiltinItemRendererRegistry.DynamicItemRenderer.html
(isSuitableFor may also be useful since you are on a version before the datafication of that too)