
HappyKiller1O1
Members-
Posts
581 -
Joined
-
Last visited
Everything posted by HappyKiller1O1
-
how to add a drop to a vanilla mob [1.7.10]
HappyKiller1O1 replied to 2FastAssassin's topic in Modder Support
Did you import it? Also, you made EventHandler a separate class, right? If that is all true, then make sure you're registering your EventHandler CLASS and not the method. -
Ok so, I am trying to make it where the achievement thing that appears when you get an achievements appears also when you pick up my mods coin. So I found the class that makes the achievement thing happen and copied over then edited away unnecessary things. My problem is the updateGui, although my tick handler works just fine, won't seem to run. Someone please help! Gui class: package com.happykiller.crewmod.client.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import com.happykiller.crewmod.CrewMod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @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"); } } 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"); } } Tickhandler (registered through my client proxy) package com.happykiller.crewmod.client; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.multiplayer.WorldClient; import com.happykiller.crewmod.client.gui.GuiCoinCollected; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TickHandlerClient { public GuiCoinCollected guiCoin; @SubscribeEvent public void renderTick(RenderTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); guiCoin = new GuiCoinCollected(mc); GuiScreen screen = mc.currentScreen; if(mc.theWorld != null) { WorldClient world = mc.theWorld; if(event.phase == Phase.START) { guiCoin.updateGui(); System.out.println("START"); }else { guiCoin.updateGui(); System.out.println("END"); } } } }
-
how to add a drop to a vanilla mob [1.7.10]
HappyKiller1O1 replied to 2FastAssassin's topic in Modder Support
Create a class called "EventHandler". After that add this method: @SubscribeEvent public void onLivingDrop(LivingDropsEvent event) { if(event.entity instanceof EntityWither) { ItemStack itemStackToDrop = new ItemStack(itemcorruptedsoul, 1); event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, itemStackToDrop)); } } Next, go into your main class and go into the init method and register your event handler: @EventHandler //MAKE SURE YOU HAVE THIS ANNOTATION public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new EventHandler()); FMLCommonHandler.instance().bus().register(new EventHandler()); //Only add this if your event doesn't fire with the first register. } Now go run your mod and see if it works. I encourage you to learn more about Java so you can have a understanding on how the game works. Don't go looking around for copy and paste code. Go on the wonderful journey of trial and error until you finally figure out your problem and smile at the accomplishment. -
[1.7.10]No OpenGL context found in current thread?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
Thanks! Maybe you could help me with this; when I pickup an item I'm trying to call the updateGui method below but, it won't run! When I don't check for the isRemote, it runs and crashes with the thread error. @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"); } } 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"); } } Here's my EventHandler method: @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); guiCoin.setUnlockTime(); //guiCoin.checkUnlockTime(); //System.out.println("Ran Correctly! Your current coin total is: " + CoinKeeper.getCoinAmount(event.player)); } } -
[1.7.10]No OpenGL context found in current thread?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
How would I make it run on a client thread? Sorry if that's an ignorant question, this error has persisted on me for quite some time. -
So, all I want to do is draw some text to the side of the player inventory screen. I thought I did it correctly like this: public class TickHandlerClient { @SubscribeEvent public void renderTick(RenderTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); GuiScreen screen = mc.currentScreen; if(mc.theWorld != null) { WorldClient world = mc.theWorld; if(event.phase == Phase.START) { if(screen instanceof GuiInventory) { mc.fontRenderer.drawString("TEXT TEXT TEXT TEXT", 176, 166, 4210752); System.out.println("Rendered Text"); } } } } } But, only the printout runs in the console. So what am I doing wrong?
-
So, anytime I try to do anything OpenGL related, I get this error when calling the method. ---- Minecraft Crash Report ---- // There are four lights! Time: 3/25/15 10:29 PM Description: Ticking player java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glPushMatrix(GL11.java:2592) at com.happykiller.crewmod.client.gui.GuiCoinCollected.updateGui(GuiCoinCollected.java:73) at com.happykiller.crewmod.client.gui.GuiCoinCollected.checkUnlockTime(GuiCoinCollected.java:150) at com.happykiller.crewmod.events.CrewEventHandler.notifyPickup(CrewEventHandler.java:30) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_CrewEventHandler_notifyPickup_ItemPickupEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.firePlayerItemPickupEvent(FMLCommonHandler.java:565) at net.minecraft.entity.item.EntityItem.onCollideWithPlayer(EntityItem.java:430) at net.minecraft.entity.player.EntityPlayer.collideWithPlayer(EntityPlayer.java:681) at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:672) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) at org.lwjgl.opengl.GL11.glPushMatrix(GL11.java:2592) at com.happykiller.crewmod.client.gui.GuiCoinCollected.updateGui(GuiCoinCollected.java:73) at com.happykiller.crewmod.client.gui.GuiCoinCollected.checkUnlockTime(GuiCoinCollected.java:150) at com.happykiller.crewmod.events.CrewEventHandler.notifyPickup(CrewEventHandler.java:30) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_CrewEventHandler_notifyPickup_ItemPickupEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.firePlayerItemPickupEvent(FMLCommonHandler.java:565) at net.minecraft.entity.item.EntityItem.onCollideWithPlayer(EntityItem.java:430) at net.minecraft.entity.player.EntityPlayer.collideWithPlayer(EntityPlayer.java:681) at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:672) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 369 Entity Name: Player909 Entity's Exact location: -116.24, 71.00, 269.88 Entity's Block location: World: (-117,71,269), Chunk: (at 11,4,13 in -8,16; contains blocks -128,0,256 to -113,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0.00, -0.08, 0.00 Stacktrace: at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@5e77de98 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_75, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 926575768 bytes (883 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.05 FML v7.10.85.1291 Minecraft Forge 10.13.2.1291 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available CrewMod{1.0.0} [The Crew Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player909'/369, l='Test World Crew Mod', x=-116.24, y=71.00, z=269.88]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' Please help me with this!
-
[1.7.10] How to Drag-and-Drop an element in GuiScrollingList?
HappyKiller1O1 replied to Abastro's topic in Modder Support
Honestly, I have no clue how to do this. I have tried before but could never understand how the scrolling works. I would suggest finding a mod the implements some of what you want and decompiling it or, finding their github. -
So one problem, I need to save a UUID of the player to the ByteBuf. How would I do this?
-
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
Ok, let me go try that out. -
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
Oh I understand how to do it! But where would the ElementType.All need to be put? -
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
Where would I put that? -
Ok, thanks! I kind of have an understanding of what to do. If I run into any more complex issues I'll just post it here.
-
But, would I need to send a packet to the client to update a onscreen gui?
-
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
Oh. I was still looking on how I would use that (no previous experience). I said I just wrote that class up as a base for displaying the achievement thing. -
Ok that's what slightly confuses me. When someone picks up an item, I would use that event and send the packet to the server, correct?
-
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
You mean a TickEvent? -
So, to add gold to someone; I'd send a packet to the server to run the "addGold" method in my GoldKeeper class and that's it?
-
I have seen that tutorial before but, I still couldn't figure out how to tell the server the player got a coin then, add it to their overall amount and update them. I'm sorry if I seem ignorant towards programming; packets just always go over my head.
-
[1.7.10] Using the Achievement Overlay for something else?
HappyKiller1O1 replied to HappyKiller1O1's topic in Modder Support
I have tried doing that but, I am stilling learning about OpenGL and such with Java. Here's something I wrote up but I'm not sure how to put it on screen when picking up an item: @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 long unlockedTime; public GuiCoinCollected(Minecraft par1Minecraft) { this.theGame = par1Minecraft; this.headerText = "\u00A7e" + StatCollector.translateToLocal("crewMod.coinCollected"); coinNameText = ""; } /** * Update the display of the achievement window to match the game window. */ private void updateWindowScale() { 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); } /** * Updates the small achievement tooltip window, showing a queued achievement if is needed. */ public void updateGui() { GL11.glPushMatrix(); if (this.unlockedTime != 0L) { double d0 = (double)(Minecraft.getSystemTime() - this.unlockedTime) / 3000.0D; if ((d0 < 0.0D || d0 > 1.0D) || coinNameText.equalsIgnoreCase("")) { this.unlockedTime = 0L; } else { 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); 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); GL11.glTranslatef((float)i + 16, (float)j + 16, 50F); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glScalef(1.0F, -1.0F, 1.0F); GL11.glScalef(20.0F, 20.0F, 20.0F); GL11.glRotatef(10.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-22.5F, 0.0F, 1.0F, 0.0F); GL11.glRotatef((float)(Minecraft.getSystemTime() - this.unlockedTime) / 6F, 0.0F, 1.0F, 0.0F); System.out.println("Gui Class: Ran"); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); } } GL11.glPopMatrix(); } } -
Hey! So, to get right to the point I am trying to add a currency to my mod that will be saved digitally. What I mean is when you pick up a coin it will add it to your overall amount and such. I easily did this in 1.6.4 but in 1.7.10 that's not the case. I just need someone to explain to me how to use the new packet system to communicate with the server about how many coins a specific player has and to add or subtract accordingly. I'm not asking to be hand-fed code here, just for someone to explain how to use the packet system in 1.7.10 with maybe a few examples. Thank you in advance, - Joey
-
[1.7.2] How to create a Book with custom GUI ?
HappyKiller1O1 replied to xXxKanemanxXx's topic in Modder Support
That is something i want to read. Something that gives me the courage to learn Java And i got it already not with a custom gui but with NBT NBT is the easy way of saving data in Minecraft. It is quite simple to use it and I suggest you take a look at classes such as the TileEntityChest and different classes that require an inventory or, some number to be saved. I used to think it was hard but, after actually learning about it, it becomes easy. -
So, I am trying to add my tick but, when doing it I need to use "Minecraft.currentScreen" but when I do it gives me the error "Cannot make a static reference to a non-static field Minecraft.currentScreen" I realize it could be something to do with the class file of Minecraft but eclipse doesn't allow me to edit those class files. Any help will be greatly appreciated My code for reference: