Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package halocraft;
- import org.lwjgl.opengl.GL11;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.gui.ScaledResolution;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.WorldRenderer;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.gameevent.InputEvent;
- public class KeyInputHandler extends Gui {
- private Minecraft mc = Minecraft.getMinecraft();
- ResourceLocation brscope = new ResourceLocation("halocraft:textures/gui/BattleRifleScope.png");
- public static boolean keyPressed = false;
- @SubscribeEvent
- public void onKeyInput(InputEvent.KeyInputEvent event) {
- while(KeyBindings.scope.isPressed()){
- if(mc.thePlayer.getHeldItem() != null){
- if(mc.thePlayer.getHeldItem().getItem() == halocraft.Main.itemBattleRifle){
- //Chat Message telling Player Scope is Initialized{Debugging Purpose}
- mc.thePlayer.addChatMessage(new ChatComponentText("[HaloCraft 2.0] Scope Initialized."));
- //Rendering Scope
- // Add this block of code before you draw the section of your texture containing transparency
- //Rendering Halo HUD
- ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
- System.out.println("Scaled Width: " + scaled.getScaledWidth());
- System.out.println("Scaled Height: " + scaled.getScaledHeight());
- int xPos = (scaled.getScaledWidth() - 256) / 2;
- int yPos = (scaled.getScaledHeight() - 256) / 2;
- System.out.println("X-Pos " + xPos + " Y-Pos " + yPos);
- this.mc.getTextureManager().bindTexture(brscope);
- // Add this block of code before you draw the section of your texture containing transparency
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glDisable(GL11.GL_DEPTH_TEST);
- GL11.glDepthMask(false);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
- GL11.glDisable(GL11.GL_ALPHA_TEST);
- drawTexturedModalRect(xPos, yPos, 256, 256, 256, 256);
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glDepthMask(true);
- }
- else{
- mc.thePlayer.addChatMessage(new ChatComponentText("[HaloCraft 2.0] This is not a weapon or does not have a scope."));
- }
- }
- else{
- mc.thePlayer.addChatMessage(new ChatComponentText("[HaloCraft 2.0] You're not holding anything!"));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment