Open oOJoshOo opened 1 year ago
I haven't tested it, but you could create a 'generic class' to make non-consumable items. Extend it from Item and implement the logic you desire within the method that returns the item to your hand once crafted. That way, it won't technically be consumed; it will be returned back to you. example: public class UnconsumableItem extends Item { public UnconsumableItem(Properties properties) { super(properties); }
@Override
public InteractionResultHolder<ItemStack> useOn(UseOnContext context) {
// Your crafting logic here
// For example, you can check if it's being used on a crafting table and create the desired output
return InteractionResultHolder.success(context.getItemInHand());
}
} att: It's an example, you can get the idea of the class from that, but that code isn't functional (I think).
that may not be useful for all conditions, think about industrial BE, you may want to use tools inside the machine (like cutter or casts or other items) they are part of a recipe for BE but still won't be consumed or damaged. There is old fashion way of handling each recipe in code, that is true, but I think there should be a way to use json for these conditions?
You could take a look at the Item.Properties class, and try and work off of the craftRemainder method. It would be different in several ways, but it could work. Anytime I want to do something there is no tutorial for, I just look at vanilla and what other people have said, and modify it to my needs.
@oOJoshOo What you could do is making a craftremainder that somehow is the same item but as a ItemStack that has less durability. I'm not sure though. You might have to improvise.
Hey,
could you make an Tutorial wich shows how to make an Item that will not be consumed when you craft with it. Or uses Durebility at Crafting?
Like a Chissle that can cave some Stone and will not Break.
Thank You