Search in sources :

Example 1 with ICapabilityTracker

use of mathax.client.mixininterface.ICapabilityTracker in project Client by MatHax.

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(mathax.client.mixininterface.ICapabilityTracker)

Aggregations

GlStateManager (com.mojang.blaze3d.platform.GlStateManager)1 Field (java.lang.reflect.Field)1 ICapabilityTracker (mathax.client.mixininterface.ICapabilityTracker)1