Everything posted by HappyKiller1O1
-
[1.7.10] updateGui won't call!
Ok so, that works! But, I can't seem to get it to call the update method more than once. Gui Class: @SideOnly(Side.CLIENT) public class GuiCoinCollected extends Gui { private static final ResourceLocation texAchi = new ResourceLocation(MR.TNAME + "textures/gui/coin_collected.png"); /** Holds the instance of the game (Minecraft) */ private Minecraft theGame; /** Holds the latest width scaled to fit the game window. */ private int width; /** Holds the latest height scaled to fit the game window. */ private int height; private String headerText; private String coinNameText; private RenderItem renderedItem; private boolean canUpdate; private long unlockedTime; public GuiCoinCollected(Minecraft mc) { this.theGame = mc; this.renderedItem = new RenderItem(); this.canUpdate = false; this.headerText = "Coin Collected!"; this.coinNameText = "x "; } private void updateWindowScale() { //if(!theGame.theWorld.isRemote) { System.out.println("STARTING WINDOW SCALE"); GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); this.width = this.theGame.displayWidth; this.height = this.theGame.displayHeight; ScaledResolution scaledresolution = new ScaledResolution(this.theGame, this.theGame.displayWidth, this.theGame.displayHeight); this.width = scaledresolution.getScaledWidth(); this.height = scaledresolution.getScaledHeight(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, (double)this.width, (double)this.height, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); System.out.println("ENDING WINDOW SCALE"); //} } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } //testUpdate(); //if(this.canUpdate) { // updateGui(); //} updateGui(); } public void updateGui() { //if(!theGame.theWorld.isRemote) { if (this.unlockedTime != 0L && Minecraft.getMinecraft().thePlayer != null) { System.out.println("PAST FIRST LINE!"); double d0 = (double)(Minecraft.getSystemTime() - this.unlockedTime) / 3000.0D; if (!this.canUpdate) { System.out.println("canUpdate EQUALED FALSE!"); if (d0 < 0.0D || d0 > 1.0D) { this.unlockedTime = 0L; return; } }else if (d0 > 0.5D) { d0 = 0.5D; } System.out.println("STARTING RENDER"); this.updateWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double d1 = d0 * 2.0D; if (d1 > 1.0D) { d1 = 2.0D - d1; } d1 *= 4.0D; d1 = 1.0D - d1; if (d1 < 0.0D) { d1 = 0.0D; } d1 *= d1; d1 *= d1; int i = this.width - 160; int j = 0 - (int)(d1 * 36.0D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); this.theGame.getTextureManager().bindTexture(texAchi); GL11.glDisable(GL11.GL_LIGHTING); this.drawTexturedQuadFit(0, 0, 160, 32, 0); this.drawTexturedModalRect(i - 50, j, 0, 0, 160, 32); System.out.println("RENDERED BOX"); if (this.canUpdate) { this.theGame.fontRenderer.drawSplitString(this.headerText, i + 30, j + 7, 120, -1); }else { this.theGame.fontRenderer.drawString(this.headerText, 30, 7, -256); this.theGame.fontRenderer.drawString(this.coinNameText, 30, 18, -1); } RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); this.renderedItem.renderItemAndEffectIntoGUI(this.theGame.fontRenderer, this.theGame.getTextureManager(), new ItemStack(CrewMod.crewCoin), i + 8, j + ; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); System.out.println("FINISHED RENDERING"); } //} } public void testUpdate() { System.out.println("STARTING RENDER"); double d0 = 0.5D; this.updateWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double d1 = d0 * 2.0D; if (d1 > 1.0D) { d1 = 2.0D - d1; } d1 *= 4.0D; d1 = 1.0D - d1; if (d1 < 0.0D) { d1 = 0.0D; } d1 *= d1; d1 *= d1; int i = this.width - 160; int j = 0 - (int)(d1 * 36.0D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); this.theGame.getTextureManager().bindTexture(texAchi); GL11.glDisable(GL11.GL_LIGHTING); //this.drawTexturedQuadFit(0, 0, 160, 32, 50); this.drawTexturedModalRect(i - 50, j, 0, 0, 160, 32); this.theGame.fontRenderer.drawString(this.headerText, 30, 7, -256); this.theGame.fontRenderer.drawString(this.coinNameText, 30, 18, -1); System.out.println("FINISHED RENDER"); } public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel){ Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0,1); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1); tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1,0); tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0); tessellator.draw(); } public void checkUnlockTime() { if(this.unlockedTime != 0) { updateGui(); } } public long setUnlockTime(long amount) { System.out.println("SET UNLOCK TIME TO: " + amount); return this.unlockedTime = amount; } public void setUnlockTime() { this.unlockedTime = theGame.getSystemTime() + 2500L; this.canUpdate = true; //updateGui(); System.out.println("SET UNLOCK TIME TO SYSTEM TIME"); } } EventHandler Class: public class CrewEventHandler { @SubscribeEvent public void notifyPickup(ItemPickupEvent event) { if(event.pickedUp.getEntityItem().isItemEqual(new ItemStack(CrewMod.crewCoin))) { event.player.inventory.consumeInventoryItem(CrewMod.crewCoin); CoinKeeper.addCoin(event.player); PacketRegistry.network.sendTo(new PacketCoinChangeClient(event.player, CoinKeeper.getCoinAmount(event.player)),(EntityPlayerMP)event.player); } } }
-
[1.7.10] updateGui won't call!
I forgot to add text to the strings. My last problem is my main one. I can't seem to call updateGui() when picking up my coin. Here are my classes: GuiCoinCollected @SideOnly(Side.CLIENT) public class GuiCoinCollected extends Gui { private static final ResourceLocation texAchi = new ResourceLocation(MR.TNAME + "textures/gui/coin_collected.png"); /** Holds the instance of the game (Minecraft) */ private Minecraft theGame; /** Holds the latest width scaled to fit the game window. */ private int width; /** Holds the latest height scaled to fit the game window. */ private int height; private String headerText; private String coinNameText; private RenderItem renderedItem; private boolean canUpdate; private long unlockedTime; public GuiCoinCollected(Minecraft mc) { this.theGame = mc; this.renderedItem = new RenderItem(); this.canUpdate = false; this.headerText = "Coin Collected!"; this.coinNameText = "x "; } private void updateWindowScale() { //if(!theGame.theWorld.isRemote) { System.out.println("STARTING WINDOW SCALE"); GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); this.width = this.theGame.displayWidth; this.height = this.theGame.displayHeight; ScaledResolution scaledresolution = new ScaledResolution(this.theGame, this.theGame.displayWidth, this.theGame.displayHeight); this.width = scaledresolution.getScaledWidth(); this.height = scaledresolution.getScaledHeight(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, (double)this.width, (double)this.height, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); System.out.println("ENDING WINDOW SCALE"); //} } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } //testUpdate(); //if(this.canUpdate) { // updateGui(); //} updateGui(); } public void updateGui() { //if(!theGame.theWorld.isRemote) { if (this.unlockedTime != 0L && Minecraft.getMinecraft().thePlayer != null) { System.out.println("PAST FIRST LINE!"); double d0 = (double)(Minecraft.getSystemTime() - this.unlockedTime) / 3000.0D; if (!this.canUpdate) { System.out.println("canUpdate EQUALED FALSE!"); if (d0 < 0.0D || d0 > 1.0D) { this.unlockedTime = 0L; return; } }else if (d0 > 0.5D) { d0 = 0.5D; } System.out.println("STARTING RENDER"); this.updateWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double d1 = d0 * 2.0D; if (d1 > 1.0D) { d1 = 2.0D - d1; } d1 *= 4.0D; d1 = 1.0D - d1; if (d1 < 0.0D) { d1 = 0.0D; } d1 *= d1; d1 *= d1; int i = this.width - 160; int j = 0 - (int)(d1 * 36.0D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); this.theGame.getTextureManager().bindTexture(texAchi); GL11.glDisable(GL11.GL_LIGHTING); this.drawTexturedQuadFit(0, 0, 160, 32, 0); //this.drawTexturedModalRect(i, j, 96, 202, 160, 32); System.out.println("RENDERED BOX"); if (this.canUpdate) { this.theGame.fontRenderer.drawSplitString(this.headerText, i + 30, j + 7, 120, -1); }else { this.theGame.fontRenderer.drawString(this.headerText, i + 30, j + 7, -256); this.theGame.fontRenderer.drawString(this.coinNameText, i + 30, j + 18, -1); } RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); this.renderedItem.renderItemAndEffectIntoGUI(this.theGame.fontRenderer, this.theGame.getTextureManager(), new ItemStack(CrewMod.crewCoin), i + 8, j + ; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); System.out.println("FINISHED RENDERING"); } //} } public void testUpdate() { System.out.println("STARTING RENDER"); double d0 = 0.5D; this.updateWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double d1 = d0 * 2.0D; if (d1 > 1.0D) { d1 = 2.0D - d1; } d1 *= 4.0D; d1 = 1.0D - d1; if (d1 < 0.0D) { d1 = 0.0D; } d1 *= d1; d1 *= d1; int i = this.width - 160; int j = 0 - (int)(d1 * 36.0D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); this.theGame.getTextureManager().bindTexture(texAchi); GL11.glDisable(GL11.GL_LIGHTING); //this.drawTexturedQuadFit(0, 0, 160, 32, 50); this.drawTexturedModalRect(i - 50, j, 0, 0, 160, 32); this.theGame.fontRenderer.drawString(this.headerText, 30, 7, -256); this.theGame.fontRenderer.drawString(this.coinNameText, 30, 18, -1); System.out.println("FINISHED RENDER"); } public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel){ Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0,1); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1); tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1,0); tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0); tessellator.draw(); } public void checkUnlockTime() { if(this.unlockedTime != 0) { updateGui(); } } public long setUnlockTime(long amount) { System.out.println("SET UNLOCK TIME TO: " + amount); return this.unlockedTime = amount; } public void setUnlockTime() { this.unlockedTime = theGame.getSystemTime() + 2500L; this.canUpdate = true; //updateGui(); System.out.println("SET UNLOCK TIME TO SYSTEM TIME"); } } EventHandler: public class CrewEventHandler { @SubscribeEvent public void notifyPickup(ItemPickupEvent event) { Minecraft mc = Minecraft.getMinecraft(); GuiCoinCollected guiCoin = new GuiCoinCollected(mc); if(event.pickedUp.getEntityItem().isItemEqual(new ItemStack(CrewMod.crewCoin))) { event.player.inventory.consumeInventoryItem(CrewMod.crewCoin); CoinKeeper.addCoin(event.player); PacketRegistry.network.sendTo(new PacketCoinChangeClient(event.player, CoinKeeper.getCoinAmount(event.player)), (EntityPlayerMP)event.player); if(!event.player.worldObj.isRemote) { guiCoin.setUnlockTime(); System.out.println("CLIENT WORLD GOTTEN AND SET UNLOCK TIME"); } //guiCoin.checkUnlockTime(); //System.out.println("Ran Correctly! Your current coin total is: " + CoinKeeper.getCoinAmount(event.player)); } } }
-
[1.7.10] updateGui won't call!
Ok, so that works but, I can't draw text on the screen. D: Any input?
-
[1.7.10] updateGui won't call!
OMG! I am so stupid.
-
how to add a drop to a vanilla mob [1.7.10]
put the "@EventHandler" Annotation over your init method in your main class.
-
[1.7.10] updateGui won't call!
Ok, so it worked (after changing the texture to match the UV) but this happens: http://i.imgur.com/ozQ36uc.png
-
[1.7.10] updateGui won't call!
So, that worked! But, the UV is off. I'm not good with Tess so, how would I change the UV?
-
[1.7.10] updateGui won't call!
So it all runs (the print outs show) but its not seeming to draw the box. Any input?
-
[1.7.10]No OpenGL context found in current thread?
I'll get to work on that! Thank you for the help so far.
-
how to add a drop to a vanilla mob [1.7.10]
Java*, bro, Java. As to other "never give up stuff" - true that. I was going to put Java but, I thought Minecraft mod creation was a better fit.
-
[1.7.10]No OpenGL context found in current thread?
Hm ok. Then just send the packet to the client?
-
[1.7.10] updateGui won't call!
So, like this? @SideOnly(Side.CLIENT) public class GuiCoinCollected extends Gui { private static final ResourceLocation texAchi = new ResourceLocation("textures/gui/achievement/achievement_background.png"); /** Holds the instance of the game (Minecraft) */ private Minecraft theGame; /** Holds the latest width scaled to fit the game window. */ private int width; /** Holds the latest height scaled to fit the game window. */ private int height; private String headerText; private String coinNameText; private RenderItem renderedItem; private boolean canUpdate; private long unlockedTime; public GuiCoinCollected(Minecraft mc) { this.theGame = mc; this.renderedItem = new RenderItem(); this.canUpdate = false; } private void updateWindowScale() { //if(!theGame.theWorld.isRemote) { System.out.println("STARTING WINDOW SCALE"); GL11.glViewport(0, 0, this.theGame.displayWidth, this.theGame.displayHeight); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); this.width = this.theGame.displayWidth; this.height = this.theGame.displayHeight; ScaledResolution scaledresolution = new ScaledResolution(this.theGame, this.theGame.displayWidth, this.theGame.displayHeight); this.width = scaledresolution.getScaledWidth(); this.height = scaledresolution.getScaledHeight(); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0.0D, (double)this.width, (double)this.height, 0.0D, 1000.0D, 3000.0D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); System.out.println("ENDING WINDOW SCALE"); //} } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.EXPERIENCE) { return; } updateGui(); } public void updateGui() { //if(!theGame.theWorld.isRemote) { if (this.unlockedTime != 0L && Minecraft.getMinecraft().thePlayer != null) { System.out.println("PAST FIRST LINE!"); double d0 = (double)(Minecraft.getSystemTime() - this.unlockedTime) / 3000.0D; if (!this.canUpdate) { System.out.println("canUpdate EQUALED FALSE!"); if (d0 < 0.0D || d0 > 1.0D) { this.unlockedTime = 0L; return; } } else if (d0 > 0.5D) { d0 = 0.5D; } System.out.println("STARTING RENDER"); this.updateWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double d1 = d0 * 2.0D; if (d1 > 1.0D) { d1 = 2.0D - d1; } d1 *= 4.0D; d1 = 1.0D - d1; if (d1 < 0.0D) { d1 = 0.0D; } d1 *= d1; d1 *= d1; int i = this.width - 160; int j = 0 - (int)(d1 * 36.0D); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); this.theGame.getTextureManager().bindTexture(texAchi); GL11.glDisable(GL11.GL_LIGHTING); this.drawTexturedModalRect(i, j, 96, 202, 160, 32); System.out.println("RENDERED BOX"); //if (this.field_146262_n) //{ // this.theGame.fontRenderer.drawSplitString(this.field_146265_j, i + 30, j + 7, 120, -1); //} //else // { this.theGame.fontRenderer.drawString(this.headerText, i + 30, j + 7, -256); this.theGame.fontRenderer.drawString(this.coinNameText, i + 30, j + 18, -1); // } RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); this.renderedItem.renderItemAndEffectIntoGUI(this.theGame.fontRenderer, this.theGame.getTextureManager(), new ItemStack(CrewMod.crewCoin), i + 8, j + ; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); System.out.println("FINISHED RENDERING"); } //} } public void checkUnlockTime() { if(this.unlockedTime != 0) { updateGui(); } } public long setUnlockTime(long amount) { System.out.println("SET UNLOCK TIME TO: " + amount); return this.unlockedTime = amount; } public void setUnlockTime() { this.unlockedTime = theGame.getSystemTime() + 2500L; this.canUpdate = true; updateGui(); System.out.println("SET UNLOCK TIME TO SYSTEM TIME"); } }
-
how to add a drop to a vanilla mob [1.7.10]
I was in your position 3 years ago (I was 12) and, honestly a lot people expect you to know a good amount about Minecraft mod creation before posting. My first mod I just added everything I could think of. Might seem stupid but, it broadened my knowledge to a very far extent. Now I am creating a Java game just from trial and error. Keep going and never give up even when the going gets tough!
-
[1.7.10] updateGui won't call!
But, how would I be able to make the overlay appear? Even by using that event my problem would still persist.
-
[1.7.10]No OpenGL context found in current thread?
Well, I need the minecraft instance to create an instance for my GuiCoinCollected. Would I just do: GuiCoinCollected guiCoin = new GuiCoinCollected(Minecraft.getMinecraft);
-
[1.7.10]No OpenGL context found in current thread?
You don't say. Not sure if that's sarcasm but, that is how you grab the instance of Minecraft you know.
-
[1.7.10]No OpenGL context found in current thread?
I know how to setup packets and such. I just don't know how I would use a packet to tell the game to display the achievement get overlay.
-
how to add a drop to a vanilla mob [1.7.10]
If it won't show your item, make sure the item is static in the main mod class.
-
how to add a drop to a vanilla mob [1.7.10]
Instead of doing "itemcorruptedsoul" do "yourmod.itemcorruptedsoul". Also, I suggest organizing classes into different packages.
-
[1.8]create a gui local only and only when this specific item is in hand ???
Try this out: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and Go down to the spoiler that says "GuiManaBar" and see how he puts it on screen. Then, you can kinda go from there. As for when you're holding the item, you could do something like this: if(player.inventory.getCurrentItem().isItemEqual(new ItemStack(YourMod.YourItem))) { //Add the render stuff }
-
[1.7.10] updateGui won't call!
When I was looking through the other code of mods that use the Achievement Get overlay for something else; they never use it. So, I was thinking to just go around it like they do. Plus, I have no idea how to use that event.
-
[1.7.10]No OpenGL context found in current thread?
Could you give me an example of what the packet would consist of and where to put it? Packets are honestly my weakest link when it comes to programming.
-
[1.7.10] Entity adding light not working
Try changing: this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX, (int) this.posY, (int) this.posZ, 16); To: this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX, (int) this.posY, (int) this.posZ, 15); If that doesn't work, trying putting "this.addLight" before you call the super.
-
[1.7.10]No OpenGL context found in current thread?
I don't think you guys are understanding what I want to do. I am trying to add the onscreen overlay (like the hud and stuff) that acts like and looks like the achievement overlay that says "Achievement Get!". So, in the notify pickup (which is running correctly) I have to use the worldObj to check if the world is remote? I don't see how that would change my circumstance.
-
[1.7.10] updateGui won't call!
See, when I change it I get a "OpenGL not found in current Thread" error. Meaning, it was trying to run it server side. This problem is confusing me beyond the point of reason.
IPS spam blocked by CleanTalk.