PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
10.06k stars 2.34k forks source link

MaterialTags.ENCHANTABLE.isTagged(Material.BRUSH) return false #9862

Closed KioProject123 closed 1 year ago

KioProject123 commented 1 year ago

Expected behavior

The brush is enchantable, so MaterialTags.ENCHANTABLE.isTagged(Material.BRUSH) should return true

Observed/Actual behavior

MaterialTags.ENCHANTABLE.isTagged(Material.BRUSH) return false

Steps/models to reproduce

.

Plugin and Datapack List

.

Paper version

I am not using Paper, but I confirm that this occurred on the latest Paper

Other

No response

electronicboy commented 1 year ago
public class MaterialTagsTest extends AbstractTestingBase {

    @Test
    public void testEnchantables() {
        for (final Item item : BuiltInRegistries.ITEM) {
            boolean hasMatch = false;
            Set<EnchantmentCategory> matched = new HashSet<>();

            for (final EnchantmentCategory value : EnchantmentCategory.values()) {
                if (value.canEnchant(item)) {
                    hasMatch = true;
                    matched.add(value);
                }
            }

            boolean isTagged = MaterialTags.ENCHANTABLE.isTagged(CraftMagicNumbers.getMaterial(item));
            if (hasMatch != isTagged) {
                System.out.println("Item: " + item.getDescriptionId() + " matchedEnch: " + hasMatch + " tagged: " + isTagged + " :" + matched);
            }
        }
    }
}

output:

MaterialTagsTest > testEnchantables() STANDARD_OUT
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.carved_pumpkin matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: item.minecraft.compass matchedEnch: true tagged: false :[cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.skeleton_skull matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.wither_skeleton_skull matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.player_head matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.zombie_head matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.creeper_head matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.dragon_head matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: block.minecraft.piglin_head matchedEnch: true tagged: false :[cat: WEARABLE, cat: VANISHABLE]
[08:39:10 INFO]: [STDOUT]: Item: item.minecraft.brush matchedEnch: true tagged: false :[cat: BREAKABLE, cat: VANISHABLE]

I think ideally a fix for this would also see if we can get a test working for some of this stuff, I had to manually hack MaterialTags into not blowing up due to the lack of registries from the seems of it

LaylaSilbernberg commented 1 year ago

Hello hello! I'm a java junior dev and I'd be interested in helping out. Could I be assigned to this?

lynxplay commented 1 year ago

We generally don't assign issues, you are free to open a PR however to resolve this! As cat said, we might want to look into creating tests for this to prevent us from missing stuff in the future, however I think it would be fine to merge a PR only fixing this specific issue too if you don't feel comfortable in creating test cases.

We can always open a new issue to create test cases later.

LaylaSilbernberg commented 1 year ago

I'll have a look then! Thank you very much.

MiniDigger commented 1 year ago

if you need any assitance just join #paper-dev on our discord (https://discord.gg/papermc) and I am sure people will be happy to help :)