architectury-api icon indicating copy to clipboard operation
architectury-api copied to clipboard

Different result between forge and fabric when trying to register a block to replace vanila one.

Open qyl27 opened this issue 10 months ago • 5 comments

When I tried to register a block with id "minecraft:dandelion" (accroding to forge doc and fabricmc reddit), I found different result between architectury api forge and fabric version.
In forge, it will replace the vanilla one.
In fabric, it will shows Attempted to register ID ResourceKey[minecraft:block / minecraft:dandelion] at different raw IDs (147, 1003)! If you're trying to override an item, use .set(), not .register()!, and then game crash.

My project code repo

qyl27 avatar Aug 23 '23 07:08 qyl27

I found a solution after my attempt, in my fork repo. Should I PR it? Or maybe better solution?

qyl27 avatar Aug 23 '23 07:08 qyl27

This is an intentional feature of Fabric API to prevent people from accidentally modifying registered content - replacement has to be explicit.

I also feel that hardcoding the minecraft namespace is problematic, a more proper solution would simply check if the content has already been registered.

Juuxel avatar Aug 23 '23 15:08 Juuxel

ah, you are right.
I have updated it. commit

qyl27 avatar Aug 24 '23 12:08 qyl27

The code is still incorrect, now it checks if that entry has been registered instead of whether that id is already taken.

Juuxel avatar Aug 24 '23 15:08 Juuxel

I have not noticed about contains(ResourceLocation) yet, is it correct that I use contains(id)?

qyl27 avatar Aug 24 '23 23:08 qyl27