Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OxidizableBlocksRegistry.registerOxidizableBlockPair does not work for Vanilla oxidizable Block implementations #4371

Open
FoxSamu opened this issue Jan 9, 2025 · 0 comments

Comments

@FoxSamu
Copy link
Contributor

FoxSamu commented Jan 9, 2025

When registering a pair of custom oxidizable blocks created from a Vanilla Block implementation (such as WeatheringCopperFullBlock (mojmap)). These blocks override the isRandomlyTicking method, and check the field WeatheringCopper.NEXT_BY_BLOCK to see if they can oxidize further. This field is updated by OxidizableBlocksRegistry.registerOxidizableBlockPair, so it would work if it wasn't for BlockState caching the return value of isRandomlyTicking at the moment the Block is created. Hence, upon the time of caching this value, the block pair isn't registered yet and the block will not be randomly ticked.

// WeatheringCopperFullBlock.java (mojmap!)
@Override
protected boolean isRandomlyTicking(BlockState state) {
    // Here it accesses the WeatheringCopper.NEXT_BY_BLOCK registry, updated by OxidizableBlocksRegistry
    // This is called and cached before we get the chance to call OxidizableBlocksRegistry!
    return WeatheringCopper.getNext(state.getBlock()).isPresent();
}

It's not actually possible to override this by setting Block.Properties.randomTicks(), since the Block implementations completely override that. The only workaround is to extend the vanilla block logic and override isRandomlyTicking to check for the weathering state instead of looking in the registry.

The cause lays somewhere with the Fabric Registry Sync API initializing the block states early. The problem could potentially be fixed if OxidizableBlocksRegistry.registerOxidizableBlockPair re-caches the isRandomlyTicking for all the block states of the registered blocks. The only reason it does work for Vanilla blocks is because the Vanilla blocks are hardcoded into the registry in the WeatheringCopper interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant