Hello everyone! I had a question currently, we can create ""custom items"" with a crafting shape and a custom name, the current problem is that if someone rename an item with the name of one of the custom items name, it will have the same behavior. We can do a double check with the meta but it's only working with items that doesn't get damage (food, ores, etc) but for armor and weapons, it doesn't work. Is there any better idea to be sure that a player cannot cheat just by renaming an item ? Ik there is enchants but I try to avoid that.
"Custom items" having "custom behaviour" shouldn't rely on an identifier that can be changed by them... like item name as you mentioned. Use nbt tags instead.
I keep saying stuff about NBT but never really understood how to use them, can you explain please ? Yes I know, this is exactly why I made this post, actually, I was hoping that someone mention NBT tags but I wasn't sure that I was correct.
It's simple. You set an nbt tag onto an item so you can verify it is a custom item by checking if it has that tag. See how https://github.com/dktapps-pm-pl/AimTP does it.
$stick->setNamedTagEntry(new ByteTag(self::AIMSTICK_TAG, 1)); Ah ok I see, it's much easier than I thought. Thank you very much for your help.
setting a namedTagEntry on custom crafted items seems to not work. PHP: $i = Item::get(Item::MUSHROOM_STEW, 0, 1); $i->setCustomName("Iderula Soup"); $i->setNamedTagEntry(new StringTag("IDERULA_SOUP", 'aaaaaasdfasdf')); $LE = new EnchantmentInstance(Enchantment::getEnchantment(Enchantment::PROTECTION)); $LE->setLevel(1); $i->addEnchantment($LE); $CEB = new ShapedRecipe(["AAA"," B ","AAA"], ["A"=>Item::get(Item::SPIDER_EYE, 0, 1), "B"=>Item::get(Item::MUSHROOM_STEW,0 , 1)],[$i]); $CEB->registerToCraftingManager($this->getServer()->getCraftingManager()); Doing that will make the item to disappear when you try to hold it
You really shouldn't do this. If you were around for the mob spawner debacle of 1.9.0 you should know this. For the uninitiated, magic meta values are not supported by Minecraft and they may break at any time without any warning. Meta values which don't exist in vanilla are on borrowed time. They work by accident, and they will stop working in the future.