All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.hendrixshen.magiclib.carpet.mixin.MixinSettingManager Maven / Gradle / Ivy

There is a newer version: 0.7.398+fe2125a-beta
Show newest version
package top.hendrixshen.magiclib.carpet.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import top.hendrixshen.magiclib.carpet.impl.WrappedSettingManager;
import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies;
import top.hendrixshen.magiclib.dependency.api.annotation.Dependency;

//#if MC > 11802
//$$ import carpet.api.settings.SettingsManager;
//#else
import carpet.settings.SettingsManager;
//#if MC <= 11502
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.class_2168;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#endif
//#endif

@Dependencies(and = @Dependency("carpet"))
@Mixin(value = SettingsManager.class, remap = false)
public class MixinSettingManager {
    //#if MC <= 11502
    @SuppressWarnings("ConstantConditions")
    @Inject(
            method = "registerCommand",
            at = @At(
                    value = "HEAD"
            )
    )
    private void registerCommand(CommandDispatcher dispatcher, CallbackInfo ci) {
        if (((SettingsManager) (Object)this) instanceof WrappedSettingManager) {
            ((WrappedSettingManager) (Object)this).registerCommandCompat(dispatcher);
        }
    }
    //#endif

    @Inject(
            method = "listAllSettings",
            at = @At(
                    value = "INVOKE",
                    //#if MC > 11802
                    //$$ target = "Lcarpet/api/settings/SettingsManager;getCategories()Ljava/lang/Iterable;"
                    //#else
                    target = "Lcarpet/settings/SettingsManager;getCategories()Ljava/lang/Iterable;"
                    //#endif
            )
    )
    private void printAdditionVersion(class_2168 source, CallbackInfoReturnable cir) {
        WrappedSettingManager.printAllExtensionVersion(source);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy