Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited


  • Gender

m_pro_m's Achievements

Tree Puncher

Tree Puncher (2/8)



  1. Hey guys, I am trying to create a GUI with a scrolling list. Inside that, I want to display "achievements". Problem is, they are somehow out of position.. Screenshots: http://pho.to/9doT0 (second one is fullscreen) My code: GuiAchievements.java import cpw.mods.fml.client.GuiScrollingList; import eu.mprom.gm.achievements.GMAchievements; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.util.ArrayList; public class GuiAchievements extends GuiScreen{ protected int guiWidth = 256; protected int guiHeight = 200; private ArrayList<String> achievements; private GuiSlotAchievement achievementsList; private EntityPlayer player; public GuiAchievements(EntityPlayer player) { this.player = player; achievements = new ArrayList<String>(); for(int i=0; i<10; i++) { achievements.add("Achv " + i); } } @Override public void initGui() { super.initGui(); int guiX = (width - guiWidth) / 2; int guiY = (height - guiHeight) / 2; this.buttonList.add( new GuiButton(1, guiX + 9, guiY + 148, 50, 15, "Close")); this.achievementsList=new GuiSlotAchievement(this, achievements); this.achievementsList.registerScrollButtons(this.buttonList, 7, ; } @Override protected void keyTyped(char p_73869_1_, int p_73869_2_) { player.closeScreen(); } @Override protected void actionPerformed(GuiButton button) { if (button.enabled) { switch (button.id) { case 1: this.player.closeScreen(); return; } } super.actionPerformed(button); } @Override public void drawScreen(int x, int y, float ticks) { super.drawScreen(x, y, ticks); GL11.glColor4f(1, 1, 1, 1); drawDefaultBackground(); int guiX = (width - guiWidth) / 2; int guiY = (height - guiHeight) / 2; mc.renderEngine.bindTexture(new ResourceLocation(GMAchievements.MOD_ID, "textures/gui/achievements.png")); drawTexturedModalRect(guiX, guiY, 0, 0, 256, 200); //drawTexturedModalRect(guiX + 18, guiY + 18, 0, 200, 200, 30); this.achievementsList.drawScreen(x, y, ticks); } Minecraft getMinecraftInstance() { /** Reference to the Minecraft object. */ return mc; } FontRenderer getFontRenderer() { /** The FontRenderer used by GuiScreen */ return fontRendererObj; } } GuiSlotAchievement.java import cpw.mods.fml.client.GuiScrollingList; import eu.mprom.gm.achievements.GMAchievements; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.util.ArrayList; public class GuiSlotAchievement extends GuiScrollingList { private ArrayList<String> achievements; private GuiAchievements parent; public GuiSlotAchievement(GuiAchievements parent, ArrayList<String> achievements) { super( parent.getMinecraftInstance(), 240, 140, (parent.height - parent.guiHeight) / 2 + 8, (parent.height - parent.guiHeight) / 2 + 190, (parent.width - parent.guiWidth) / 2 + 7, 50 ); this.func_27259_a(true, -22); this.parent = parent; this.achievements = achievements; } @Override protected int getSize() { return achievements.size(); } @Override protected void elementClicked(int index, boolean doubleClick) { } @Override protected boolean isSelected(int index) { return false; } @Override protected void drawBackground() { //this.parent.drawDefaultBackground(); } /* @Override protected int getContentHeight() { return this.getSize() * 30; } */ @Override protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5) { int guiX = (this.parent.width - this.parent.guiWidth) / 2; int guiY = (this.parent.height - this.parent.guiHeight) / 2; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); GL11.glColor4f(1,1,1,1); this.parent.mc.renderEngine.bindTexture(new ResourceLocation(GMAchievements.MOD_ID, "textures/gui/achievements.png")); this.parent.drawTexturedModalRect(guiX + 15, guiY + var3, 0, 200, 200, 30); this.parent.getFontRenderer().drawString("Achievement name", guiX + 20, guiY + var3 + 5, 0x000000); } } I was trying to do something with this function this.func_27259_a(true, -22);, but it just moves the content up and down. Main problem is: When I scroll the slider, content is displayed over the container that holds it (over the top and bottom - you can sometimes see up to 5 elements). Second problem is the fullscreen (see screenshot), but I guess all I have to do is to reposition everything on resize of the window, right? Any pointers to the window resize event? Last thing, I was trying to close the GUI after clicking the button or pressing a keyboard, but it doesn't work. I also tried this.mc.thePlayer.closeScreen(). Any ideas? Thank you!
  2. Hey guys, I've been trying to create a simple GUI, but I keep getting this error message everytime I am trying to use a texture: [18:10:39] [Client thread/WARN]: Failed to load texture: gmachievements:textures/gui/magic_bag.png java.io.FileNotFoundException: gmachievements:textures/gui/magic_bag.png at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:71) ~[simpleReloadableResourceManager.class:?] ...etc I tried all of these methods to bind my texture mc.renderEngine.bindTexture(new ResourceLocation("gmachievements", "textures/gui/magic_bag.png")); mc.renderEngine.bindTexture(new ResourceLocation("gmachievements:textures/gui/magic_bag.png")); mc.renderEngine.bindTexture(new ResourceLocation(GMAchievements.MOD_ID, "textures/gui/magic_bag.png")); mc.renderEngine.bindTexture(new ResourceLocation(GMAchievements.MOD_ID + ':' + "textures/gui/magic_bag")); MOD_ID is "gmachievements" Project structure http://pasteboard.co/2GWAvAyX.png I read all the topics here on forums with similar problems, but everyting was pointing to wrong typo or no modid.. I tried a lot of things, even creating a totally new project - nothing helped me. Btw I am sorry but I couldnt use any of the formatting tools (JS errors in console!)
  3. Hello, I made a mod that merges XP Orbs together. It's just a utility mod (for servers). Purpose of this mod is to ensure there aren't tons of XP Orbs dropped nearby XP farms, you can not remove easily with 5 FPS... I hope you will find this useful Download: XPPackager.zip
  4. I tried to put event.setResult(Result.DENY); but nothing happened. I am using event EntityJoinWorldEvent.
  5. Hello, I've got a code that removes some xp orb entities. Whenever it removes something, console says [WARNING] Fetching addPacket for removed entity That's ton of spam. Can I do something about it ? My code is simple .. I have got an event and then entity.setDead(); // Solved using event EntityEvent and checking if entity exists for at least 1 tick
  6. Hello, i am trying to load my custom sounds using this code: @ForgeSubscribe public void onSound(SoundLoadEvent event) { try { event.manager.addSound("randmusic:song1.ogg"); System.out.println("[Random Music] Songs loaded !"); } catch (Exception e) { System.out.println("[Random Music] Error loading music files "); } } It's working fine, but I will have more and more songs in my mod's assets folder. And I don't want to update my code everytime I add a song. So I need to get a count of files in the mod.zip (assets/sound/...). Is it event possible or will I have to update it everytime in code ? I am talking about event.manager.addSound("randmusic:song1.ogg");
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.