@codechicken.lib.annotation.FunctionProxy

Here are the examples of the java api @codechicken.lib.annotation.FunctionProxy taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

17 Source : JEIIntegrationManager.java
with MIT License
from TheCBProject

/**
 * Created by covers1624 on 7/14/2016.
 * Handles hiding and showing things from jei and nei. Basically an interface between the two.
 */
@SideOnly(Side.CLIENT)
public clreplaced JEIIntegrationManager {

    @FunctionProxy
    public static IJEIProxy proxy;

    public static boolean jeiLoaded;

    public static EnumItemBrowser searchBoxOwner = EnumItemBrowser.JEI;

    public static EnumItemBrowser itemPanelOwner = EnumItemBrowser.JEI;

    public static void pushChanges(VisibilityData data) {
        JeiRuntime runtime = Internal.getRuntime();
        if (runtime != null) {
            IngredientListOverlay overlay = runtime.getIngredientListOverlay();
            GuiTextFieldFilter fieldFilter = getTextFieldFilter(overlay);
            if (searchBoxOwner == EnumItemBrowser.JEI) {
                data.showSearchSection = false;
                if (fieldFilter != null) {
                    fieldFilter.setVisible(true);
                }
            } else {
                data.showSearchSection = true;
                if (fieldFilter != null) {
                    fieldFilter.setVisible(false);
                }
            }
            if (itemPanelOwner == EnumItemBrowser.JEI) {
                data.showItemPanel = false;
                if (!Config.isOverlayEnabled()) {
                    Config.toggleOverlayEnabled();
                }
            } else {
                data.showItemPanel = data.showSearchSection = true;
                if (Config.isOverlayEnabled()) {
                    Config.toggleOverlayEnabled();
                }
            }
        }
    }

    public static void initConfig(ConfigTagParent tag) {
        sereplacedemPanelOwner(tag.getTag("jei.itemPanel").getIntValue(1));
        setSearchBoxOwner(tag.getTag("jei.searchBox").getIntValue(1));
    }

    public static void openRecipeGui(ItemStack stack) {
        proxy.openRecipeGui(stack);
    }

    public static void openUsageGui(ItemStack stack) {
        proxy.openUsageGui(stack);
    }

    public static boolean isBlacklisted(ItemStack stack) {
        return proxy.isBlacklistedJEI(stack);
    }

    public static boolean setSearchBoxOwner(int ordinal) {
        try {
            searchBoxOwner = EnumItemBrowser.values()[ordinal];
            return true;
        } catch (IndexOutOfBoundsException e) {
            searchBoxOwner = EnumItemBrowser.NEI;
            return false;
        }
    }

    public static boolean setSearchBoxOwner(EnumItemBrowser browser) {
        searchBoxOwner = browser;
        return true;
    }

    public static boolean sereplacedemPanelOwner(EnumItemBrowser browser) {
        itemPanelOwner = browser;
        return true;
    }

    public static boolean sereplacedemPanelOwner(int ordinal) {
        try {
            itemPanelOwner = EnumItemBrowser.values()[ordinal];
            return true;
        } catch (IndexOutOfBoundsException e) {
            itemPanelOwner = EnumItemBrowser.NEI;
            return false;
        }
    }

    public static GuiTextFieldFilter getTextFieldFilter() {
        if (Internal.getRuntime() == null) {
            return null;
        }
        return getTextFieldFilter(Internal.getRuntime().getIngredientListOverlay());
    }

    private static GuiTextFieldFilter getTextFieldFilter(IngredientListOverlay overlay) {
        if (overlay == null) {
            return null;
        }
        try {
            Field field = overlay.getClreplaced().getDeclaredField("searchField");
            field.setAccessible(true);
            return (GuiTextFieldFilter) field.get(overlay);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private static IngredientFilter gereplacedemFilter(GuiTextFieldFilter fieldFilter) {
        if (fieldFilter == null) {
            return null;
        }
        try {
            Field field = fieldFilter.getClreplaced().getDeclaredField("ingredientFilter");
            field.setAccessible(true);
            return (IngredientFilter) field.get(fieldFilter);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void setFilterText(String text) {
        if (Internal.getRuntime() != null && Internal.getRuntime().gereplacedemListOverlay() != null) {
            IngredientListOverlay overlay = Internal.getRuntime().getIngredientListOverlay();
            overlay.onSetFilterText(text);
        }
    }

    public static List<Object> getFilteredItems() {
        if (Internal.getRuntime() != null && Internal.getRuntime().gereplacedemListOverlay() != null) {
            IngredientListOverlay overlay = Internal.getRuntime().getIngredientListOverlay();
            IngredientFilter filter = gereplacedemFilter(getTextFieldFilter(overlay));
            if (filter != null) {
                return filter.getFilteredIngredients();
            }
        }
        return new ArrayList<>();
    }

    public static KeyBinding getShowUses() {
        return KeyBindings.showUses;
    }

    public static KeyBinding getShowRecipes() {
        return KeyBindings.showRecipe;
    }

    public static KeyBinding getFocusSearch() {
        return KeyBindings.focusSearch;
    }

    public static KeyBinding getRecipeBack() {
        return KeyBindings.recipeBack;
    }

    public static KeyBinding getToggleOverlay() {
        return KeyBindings.toggleOverlay;
    }

    /**
     * Gracefully handles JEI integration breaking, sets SearchBox and ItemPanel back to defaults, disables further integration.
     *
     * @param throwable The error that occurred.
     */
    public static void handleJEIError(Throwable throwable) {
    // TODO
    }

    public static String proxyCallback() {
        if (Loader.isModLoaded("jei")) {
            jeiLoaded = true;
            return JEIProxy.clreplaced.getName();
        }
        jeiLoaded = false;
        return DummyProxy.clreplaced.getName();
    }
}