Search in sources :

Example 1 with RegistryBackedTrackableBridge

use of org.spongepowered.common.bridge.RegistryBackedTrackableBridge in project SpongeCommon by SpongePowered.

the class BlocksMixin_Tracker method impl$initializeTrackerState.

@Redirect(method = "register", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Registry;register(Lnet/minecraft/core/Registry;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;"))
private static Object impl$initializeTrackerState(final Registry<Object> registry, final String key, final Object toRegister) {
    final Object registered = Registry.register(registry, key, toRegister);
    final Block block = (Block) toRegister;
    final boolean randomlyTicking = block.isRandomlyTicking(block.defaultBlockState());
    // TODO Not the best check but the tracker options only matter during block ticks...
    if (randomlyTicking) {
        final RegistryBackedTrackableBridge<Block> trackableBridge = (RegistryBackedTrackableBridge<Block>) toRegister;
        trackableBridge.bridge$refreshTrackerStates();
    }
    return registered;
}
Also used : Block(net.minecraft.world.level.block.Block) RegistryBackedTrackableBridge(org.spongepowered.common.bridge.RegistryBackedTrackableBridge) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Aggregations

Block (net.minecraft.world.level.block.Block)1 Redirect (org.spongepowered.asm.mixin.injection.Redirect)1 RegistryBackedTrackableBridge (org.spongepowered.common.bridge.RegistryBackedTrackableBridge)1