Marwinkas / Mystical-Nature

Mystical Crops is a mod allow growing your resources with crops. Use crops to grow essences used to make materials!
5 stars 2 forks source link

[1.19.2] Use tag to test for knives #5

Closed kwpugh closed 1 year ago

kwpugh commented 1 year ago

Hi, I was wondering if you could use your c:knives tag to test if an item is suitable for the Botanical Table.

https://github.com/Marwinkas/MysticalCrops/blob/master/src/main/java/net/marwinka/mysticalcrops/util/inventory/KnifeSlot.java

This would allow players and other mod authors to insert their own knives into the tag rather any fancy coding.

Regard

kwpugh

kwpugh commented 1 year ago

if you are unfamiliar on creating and using tags in code

register the tag with this:

public static final TagKey<Item> KNIVES = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "knives"));

then reference it in code with this:

if(toolStack.isIn(TagInit.KNIVES))

Marwinkas commented 1 year ago

Thanks for issue! I planned to add this, added a tag to the knives and forgot, sorry. v1.6-1.19.2: https://www.curseforge.com/minecraft/mc-mods/mystical-nature/files/4052909

kwpugh commented 1 year ago

Hi,

So this is wonderful in that it allows my unbreakable Gobber End Paxel to be used in the table. Although, the primary reason for this integration is to provide the player with the reward of using an unbreakable multi-tool to do the knife cutting.

Problem is your code does not check to see if the tool has the vanilla "unbreakable" tag in its NBT, so it takes damage with each use.

Would it be possible for you to also check for that? Fortunately, vanilla already has code to do this check

you could update your code to use the isDamageable() method in the ItemStack class Screen Shot 2022-10-26 at 9 38 17 PM

If you could incorporate a check to see that the stack is supposed to take damage before damaging it, that would solve the issue. https://github.com/Marwinkas/MysticalCrops/blob/fea15767f9b388d137655d70d9110fbf244a3c2e/src/main/java/net/marwinka/mysticalcrops/blockentities/BotanicalTableEntity.java#L216

This would allow any other mods leveraging the c:knives tag with an unbreakable to tool to work as well.

Thank you for considering and the help.

Regards,

kwpugh

kwpugh commented 1 year ago

Above is the answer to that latest issue that was opened.