Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpyglassGui extends Gui {
- private final static ResourceLocation overlay = new ModelResourceLocation("glassworks:textures/gui/spyglass.png");
- private final static int OVERLAY_WIDTH = 256;
- private final static int OVERLAY_HEIGHT = 256;
- private Minecraft mc;
- public SpyglassGui(Minecraft mc) {
- this.mc = mc;
- }
- public void renderOverlay(int screenWidth, int screenHeight) {
- ScaledResolution scaledresolution = new ScaledResolution(mc);
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
- float scalefact = (float)screenHeight/(float)OVERLAY_HEIGHT;
- int xPos = width/2 -(int)((scalefact*OVERLAY_WIDTH)/2);
- int yPos = height/2 -OVERLAY_HEIGHT/2;
- GL11.glPushMatrix();
- mc.renderEngine.bindTexture(overlay);
- GL11.glScalef(scalefact,scalefact, 1);
- this.drawTexturedModalRect(xPos, 0, 0, 0, 256, 256);
- this.drawRect(0, 0, xPos, screenHeight, 0);
- this.drawRect((int) (xPos+scalefact*256), 0, screenWidth, screenHeight, 0);
- GL11.glPopMatrix();
- }
- }
- Called in
- public SpyglassHandler(SpyglassGui overlay) {
- spyglassOverlay = overlay;
- }
- private SpyglassGui spyglassOverlay;
- @SubscribeEvent
- public void preRenderOverlay(RenderGameOverlayEvent.Pre event)
- {
- //condition code
- spyglassOverlay.renderOverlay(event.getResolution().getScaledWidth(), event.getResolution().getScaledHeight());
- }
- set in
- @EventHandler
- public void init(FMLInitializationEvent event)
- {
- MinecraftForge.EVENT_BUS.register(new SpyglassHandler(new SpyglassGui(Minecraft.getMinecraft())));
- }
Advertisement
Add Comment
Please, Sign In to add comment