Search in sources :

Example 1 with ICapabilityTracker

use of meteordevelopment.meteorclient.mixininterface.ICapabilityTracker in project meteor-client by MeteorDevelopment.

the class GL method getTracker.

private static ICapabilityTracker getTracker(String fieldName) {
    try {
        Class<?> glStateManager = GlStateManager.class;
        Field field = glStateManager.getDeclaredField(fieldName);
        field.setAccessible(true);
        Object state = field.get(null);
        String trackerName = FabricLoader.getInstance().getMappingResolver().mapClassName("intermediary", "com.mojang.blaze3d.platform.GlStateManager$class_1018");
        Field capStateField = null;
        for (Field f : state.getClass().getDeclaredFields()) {
            if (f.getType().getName().equals(trackerName)) {
                capStateField = f;
                break;
            }
        }
        capStateField.setAccessible(true);
        return (ICapabilityTracker) capStateField.get(state);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : GlStateManager(com.mojang.blaze3d.platform.GlStateManager) Field(java.lang.reflect.Field) ICapabilityTracker(meteordevelopment.meteorclient.mixininterface.ICapabilityTracker)

Aggregations

GlStateManager (com.mojang.blaze3d.platform.GlStateManager)1 Field (java.lang.reflect.Field)1 ICapabilityTracker (meteordevelopment.meteorclient.mixininterface.ICapabilityTracker)1