package TecknixFileBase; import net.minecraft.client.*; import com.google.common.collect.*; import com.tecknix.client.hud.mod.*; import com.tecknix.client.hud.*; import com.tecknix.client.Event.impl.*; import net.minecraft.client.gui.*; import java.util.*; import com.tecknix.client.Event.*; public class HUDManager { private static HUDManager instance; private static Set registeredRenderers; private Set unregRenderers; private Minecraft mc; static { HUDManager.instance = null; HUDManager.registeredRenderers = (Set)Sets.newHashSet(); } private HUDManager() { this.unregRenderers = (Set)Sets.newHashSet(); this.mc = Minecraft.getMinecraft(); } public static HUDManager getInstance() { if (HUDManager.instance != null) { return HUDManager.instance; } EventManager.register(HUDManager.instance = new HUDManager()); return HUDManager.instance; } public void register(final IRenderer... renderers) { for (final IRenderer render : renderers) { HUDManager.registeredRenderers.add(render); } } public void unregister(final IRenderer... renderers) { for (final IRenderer render : renderers) { HUDManager.registeredRenderers.remove(render); this.unregRenderers.add(render); } } public static void clear() { HUDManager.registeredRenderers.clear(); clear(); final HUDManager hudManager = getInstance(); ModuleInstances.register(hudManager); } public Collection getRegisteredRenderers() { return HUDManager.registeredRenderers; } public void openConfigScreen() { this.mc.displayGuiScreen(new BaseModScreen(this)); } @EventTarget public void onRender(final RendererEvent e) { if (this.mc.currentScreen == null || this.mc.currentScreen instanceof GuiChat) { if (this.mc.gameSettings.showDebugInfo) { return; } for (final IRenderer renderer : HUDManager.registeredRenderers) { this.callRenderer(renderer); } } } private void callRenderer(final IRenderer renderer) { if (!renderer.isEnabled()) { return; } if (this.unregRenderers.contains(renderer)) { return; } ScreenPosition pos = renderer.load(); if (pos == null) { pos = ScreenPosition.fromRelativePosition(0.5, 0.5); } renderer.render(pos); } public Set getUnregisteredRenderers() { return this.unregRenderers; } }