Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HappyKiller1O1

Members
  • Joined

  • Last visited

Everything posted by HappyKiller1O1

  1. Nevermind! Thank you so much Ernio! You're such a talented programmer. Probably doesn't mean that much considering the circumstance of the issue but, the mod you're creating is incredible. Can't wait to see the beta!
  2. @Ernio Thank you for that explanation! Honestly, even when messing with those variables; it doesn't change that damn left side. I'm probably missing the obvious so, I'll figure it out. @jabelar Honestly, it's not that complicated. I mean, your way is simpler but, the way coolAlias showed (the way I used) seems to work just fine. I don't see the point in adding them to a string array considering it is not needed.
  3. Here's the initGui: public void initGui() { this.list = new GuiScrollingList(this.mc, this.width + 100, this.height, 0, this.height, -100, 14) { //MAKE THIS WORK! List players = mc.getNetHandler().playerInfoList; int selectedIndex = -1; protected boolean isSelected(int index) { if(index == selectedIndex) { return true; } return false; } protected int getSize() { return players.size(); } protected void elementClicked(int index, boolean doubleClick) { this.selectedIndex = index; this.isSelected(selectedIndex); } protected void drawSlot(int var1, int width, int height, int var4, Tessellator tess) { //mc.fontRenderer.setBidiFlag(true); for(int i = 0; i < getSize(); i++) { GuiPlayerInfo victim = ((GuiPlayerInfo)players.get(i)); mc.fontRenderer.drawString(victim.name, width / 2 - 20, height, 0xFFFFFF); } } protected void drawBackground() { } }; } What I mean is, every variable I change draws the left side way off screen. You can see this by the selection box that has no border for the left side.
  4. So, I got the selection part to work but, there's no variable that I can change that allows me to bring in the left side. Check out the picture: http://i.imgur.com/vnCsneG.png
  5. So, I got the player name to work by doing this in my draw slot method: for(int i = 0; i < getSize(); i++) { GuiPlayerInfo info = ((GuiPlayerInfo)players.get(i)); } So, that worked pretty well! But, I still can't figure out how to select an index. .-.
  6. This is probably an idiotic question but, how exactly would I declare the index?
  7. Ok so, I have this: this.list = new GuiScrollingList(this.mc, this.width + 100, this.height, 50, 150, -100, 24) { List players = mc.getNetHandler().playerInfoList; String[] strings = new String[]{"one", "two", "three"}; protected boolean isSelected(int index) { return false; } protected int getSize() { return players.size(); } protected void elementClicked(int index, boolean doubleClick) { this.isSelected(index); } protected void drawSlot(int var1, int width, int height, int var4, Tessellator tess) { //mc.fontRenderer.setBidiFlag(true); mc.fontRenderer.drawString(players.get(0).toString(), width / 3, height, 0xFFFFFF); } protected void drawBackground() { } }; All of it is declared in my initGui. Now a few questions, for starters; I can't seem to be able to select the text (Like with select world). To be honest, I looked through other classes and couldn't figure out how they did it. Secondly, how would I get the player username from the list? And thirdly, can I draw the scroll list over like a normal gui? What I mean is like the the background of the furnace gui or, does it require the whole screen to be overlayed?
  8. I completely understand that. I have an understanding to where I can be giving a starting point and excel from there. This scrolling list is the only thing that has confused me from the start.
  9. Oh and jabelar, I am not fully fluent in Java. I try my best to learn everything I can but, just like you may have experienced through your first years of programming; some things don't come as easy to me as others. But, I thank you for telling me what to look into in order to accomplish my goal.
  10. Well thanks for the hints. I'll get to looking into creating it. I actually didn't know forge made a GuiScrollingList.
  11. After viewing all those videos, not one showed how to screate a scrolling GUI. I would really appreciate some help on this matter. ;-;
  12. Thank you for that but, it's not letting me view the lecture for the Interface tutorial.
  13. See, I know it just is a thing that moves up and down but, when I look at the classes I get so confused. Someone really needs to right a tutorial explaining some of the key parts in implementing a scrolling type gui.
  14. Thank you for that but, I still don't know how to add a scrolling Gui There's no real explanation for it. Also, couldn't you use "world.playerEntites"?
  15. Ok so, I want to add to my gui a scrolling list containing the names of all the players on the server. But honestly, I have no clue how to accomplish this. If anyone can help that'd be great!
  16. Well... that worked. I feel like the more difficult side of things when it comes to mod creation I understand and overcome. But the simplistic things I overlook and have to post a thread on it. Thanks to both of you.
  17. Here's my Gui class: public class GuiShopBlock extends GuiScreen { public static final ResourceLocation texture = new ResourceLocation(MR.TNAME + "textures/gui/crew_shop.png"); private static final ResourceLocation crewShopPurchase = new ResourceLocation(MR.TNAME + "textures/gui/crew_shop_purchase.png"); private int xSize; private int ySize; private int itemPrice; RenderItem renderedItem; Item item; GuiSlider slider; GuiButton buy; GuiButton exit; GuiButton prev; GuiButton next; GuiButton exitGui; private boolean canDisplayPurchase; public GuiShopBlock() { //ADD THE REST OF THE PAGES this.xSize = 176; this.ySize = 166; renderedItem = new RenderItem(); canDisplayPurchase = false; itemPrice = 0; item = null; } public void initGui() { int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; buttonList.clear(); slider = new GuiSlider(0, k + 48, l + 40, 72, 14, "Quantity: ", "", 1, 64, 1, false, true); buy = new GuiButton(1, k + 49, l + 79, 26, 14, "Buy"); exit = new GuiButton(2, k + 92, l + 79, 26, 14, "Exit"); prev = new GuiButton(3, k + 6, l + 145, 30, 18, "Prev"); next = new GuiButton(4, k + 139, l + 145, 30, 18, "Next"); exitGui = new GuiButton(5, k + 72, l + 145, 30, 18, "Exit"); buttonList.add(slider); buttonList.add(buy); buttonList.add(exit); buttonList.add(prev); buttonList.add(next); buttonList.add(exitGui); slider.visible = false; buy.visible = false; exit.visible = false; prev.enabled = false; } public void actionPerformed(GuiButton button) { int cost = (int)(slider.getValueInt() * itemPrice); int userID = this.mc.thePlayer.getEntityId(); World world = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld(); EntityPlayer player = (EntityPlayer)world.getEntityByID(userID); ExtendedPlayer ep = ExtendedPlayer.get(player); switch(button.id) { case 0: break; case 1: if(canPlayerBuy(cost)) { //System.out.println(ep.getCrewCoinAmount()); ep.modifyCrewCoins(-cost); PacketRegistry.network.sendTo(new PacketCoinChangeClient(player, ep.getCrewCoinAmount()), (EntityPlayerMP)player); ItemStack stack = new ItemStack(this.item, slider.getValueInt(), 0); //System.out.println(this.item); if(stack != null) { EntityItem item = new EntityItem(world, player.posX, player.posY, player.posZ, stack); if(!world.isRemote) { world.spawnEntityInWorld(item); } } //System.out.println(ep.getCrewCoinAmount()); //System.out.println(cost); //System.out.println(slider.getValueInt()); closePurchase(); }else { EventsClientForge.purchaseError(); } break; case 2: closePurchase(); break; } } public void drawScreen(int x, int y, float f) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; mc.getTextureManager().bindTexture(texture); this.drawTexturedModalRect(k, l, 0, 0, xSize, ySize); this.renderItemOnGui(Items.emerald, 0, 0); this.renderItemOnGui(Items.diamond, 100, 0); this.renderItemOnGui(Items.gold_ingot, 0, 25); this.renderItemOnGui(Items.iron_ingot, 100, 25); this.renderItemOnGui(Items.quartz, 0, 50); this.renderItemOnGui(Items.redstone, 100, 50); this.drawString(mc.fontRenderer, "Crew Shop", k + 60, l + 8, 0xFFFFFF); this.drawString(mc.fontRenderer, "Welcome to the Crew Shop!", k + 20, l + 100, 0xFFFFFF); this.drawString(mc.fontRenderer, "To purchase an something,", k + 18, l + 114, 0xFFFFFF); this.drawString(mc.fontRenderer, "please click an item above.", k + 20, l + 124, 0xFFFFFF); if(this.canDisplayPurchase) { this.drawPurchaseOverlay(); } this.drawToolTips(x, y); super.drawScreen(x, y, f); } public void drawToolTips(int mouseX, int mouseY) { int boxX = (this.width - this.xSize) / 2 + 25; int boxY = (this.height - this.ySize) / 2 + 25; int defaultX = 16; int defaultY = 16; /* Left Side */ if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.EMERALD, "Emerald"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.GOLD_INGOT, "Gold Ingot"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.QUARTZ, "Quartz"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } /* Right Side */ if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.DIAMOND, "Diamond"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.IRON_INGOT, "Iron Ingot"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) { List list = new ArrayList(); defaultTooltip(list, ItemPrices.REDSTONE, "Redstone"); this.drawTooltipText(list, mouseX, mouseY, fontRendererObj); } } public void mouseClicked(int mouseX, int mouseY, int which) { int boxX = (this.width - this.xSize) / 2 + 25; int boxY = (this.height - this.ySize) / 2 + 25; int defaultX = 16; int defaultY = 16; if(!this.canDisplayPurchase) { /* Left Side */ if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { openPurchase(ItemPrices.EMERALD, Items.emerald); } if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) { openPurchase(ItemPrices.GOLD_INGOT, Items.gold_ingot); } if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) { openPurchase(ItemPrices.QUARTZ, Items.quartz); } /* Right Side */ if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { openPurchase(ItemPrices.DIAMOND, Items.diamond); } if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 25 && mouseY < boxY + 25 + defaultY) { openPurchase(ItemPrices.IRON_INGOT, Items.iron_ingot); } if(mouseX > boxX + 100 && mouseX < boxX + 100 + defaultX && mouseY > boxY + 50 && mouseY < boxY + 50 + defaultY) { openPurchase(ItemPrices.REDSTONE, Items.redstone); } } super.mouseClicked(mouseX, mouseY, which); } public void renderItemOnGui(Item item, int mulX, int mulY) { int k = (this.width - this.xSize) / 2 + 25; int l = (this.height - this.ySize) / 2 + 25; GL11.glPushMatrix(); 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.glScalef(2.00F, 2.00F, 2.00F); renderedItem.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(item), k + mulX, l + mulY); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); RenderHelper.disableStandardItemLighting(); GL11.glPopMatrix(); } private void drawPurchaseOverlay() { //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int xSize = 80; int ySize = 62; int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; mc.getTextureManager().bindTexture(crewShopPurchase); this.drawTexturedModalRect(k + 44, l + 34, 0, 0, this.xSize, this.ySize); this.renderItemOnGui(this.item, 50, 36); //this.drawCenteredString(mc.fontRenderer, "Purchase Item", k + 84, l + 40, 0xFFFFFF); //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.glScalef(2.00F, 2.00F, 2.00F); //renderedItem.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), new ItemStack(itemForRender), k + 25, l + 25); //GL11.glDisable(GL11.GL_LIGHTING); //GL11.glDepthMask(true); //GL11.glEnable(GL11.GL_DEPTH_TEST); //GL11.glPopMatrix(); } private void openPurchase(int itemPrice, Item itemToDrop) { this.canDisplayPurchase = true; slider.visible = true; buy.visible = true; exit.visible = true; this.itemPrice = itemPrice; this.item = itemToDrop; slider.maxValue = item.getItemStackLimit(); slider.updateSlider(); next.enabled = false; exitGui.enabled = false; } public void closePurchase() { canDisplayPurchase = false; slider.visible = false; buy.visible = false; exit.visible = false; slider.setValue(1D); slider.maxValue = 64; slider.updateSlider(); this.item = null; next.enabled = true; exitGui.enabled = true; } private void drawTooltipText(List list, int mouseX, int mouseY, FontRenderer fr) { if(!this.canDisplayPurchase) { this.drawHoveringText(list, mouseX, mouseY, fr); }else { return; } } private void defaultTooltip(List list, int itemP, String itemN) { list.add(EnumChatFormatting.YELLOW + itemN); list.add(EnumChatFormatting.AQUA + "Price: " + getCost(itemP)); } private boolean canPlayerBuy(int cost) { if(ExtendedPlayer.get(this.mc.thePlayer).getCrewCoinAmount() >= cost) { return true; }else { return false; } } private String getCost(int itemPrice) { if(ExtendedPlayer.get(this.mc.thePlayer).getCrewCoinAmount() >= itemPrice) { return EnumChatFormatting.GREEN.toString() + itemPrice; }else { return EnumChatFormatting.RED.toString() + itemPrice; } } public void keyTyped(char character, int par1) { if(character == Keyboard.KEY_E) { this.mc.displayGuiScreen((GuiScreen)null); } super.keyTyped(character, par1); } public boolean doesGuiPauseGame() { return false; } } It's a bit messy because I am still testing some things within it. I mainly just call "this.drawHoveringText()" from the GuiScreen class. Maybe they did something wrong?
  18. I was just burned so hard.
  19. Hey so, I made my gui and all that fancy stuff. But, when ever I display hovering text, this happens: http://i.imgur.com/l8NZpKU.png I really don't know what's causing this. I would really appreciate some help!
  20. Maybe something like this? while(spellParalysis.isActive()) { KeyBoard.destroy(); Mouse.destroy(); } Not sure where you would put this but, I believe this disables the KeyBoard and Mouse.
  21. I'm quite sure you can set an int to be the damage then set it as your tool material: int swordDamage = YourFormula; public static EnumToolMaterial DSRemake = EnumHelper.addToolMaterial("DSRemake", 0, 1000, swordDamge, 0, 0); Also, I suggest at least updating to 1.7 ESPECIALLY for your first mod. Considering 1.6 is no longer supported by forge and, the way everything is made has changed in 1.7; you'll be very confused when switching to 1.7.
  22. I actually figured it out. After an hour, I found out by doing EntityPlayer player = (EntityPlayer)FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getEntityByID(userID) I could get the EntityPlayerMP. To set the user id just do: int userID = Minecraft.getMinecraft().thePlayer.getEntityId(); Sorry for the pre-mature post! Didn't realize how persistent I could be.
  23. I know the title is confusing but, basically I have a shop which is a GuiScreen. This GuiScreen opens when you right click the block (I have tried some things with the TileEntity to no avail). I really need to update the the coin amount or else it doesn't register. Any ideas?
  24. Well, when I render it after the items are rendered, I get quite a weird lighting glitch and, the items still overlap.
  25. Next time, please in case your code in "code" and "/code". It becomes quite difficult to read otherwise.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.