Jump to content

Recommended Posts

Posted

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!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

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"?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

See, I know it just is a thing that moves up and down but, when I look at the classes I get so confused. xD Someone really needs to right a tutorial explaining some of the key parts in implementing a scrolling type gui.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Thank you for that but, it's not letting me view the lecture for the Interface tutorial.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

After viewing all those videos, not one showed how to screate a scrolling GUI. I would really appreciate some help on this matter. ;-;

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

After viewing all those videos, not one showed how to screate a scrolling GUI. I would really appreciate some help on this matter. ;-;

 

The reason no one is answering is because it is obvious from your question that your coding isn't strong enough. If you were strong in coding, you'd already figure out how to put it together.

 

Now I know people have to start somewhere, but scrolling is really just a matter of looping through a subset of a list or array of strings, which is really very basic.

 

But here's a hint of the steps you need to figure out:

1) how to draw something on the screen at all -- look at rendering overlay and hud tutorials

2) how to draw text on the screen

3) how to create an array of text based on the player list info people above have already explained how to get.

4) figure out how to send packets from server to client to get the player list to the client.

5) figure out how to loop through a subset of the list and draw the text

6) figure out how to change the subset of the list you draw -- this is where it actually scrolls.

 

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

GUIs are one above many things that will never have "do this" tutorial, that most of new coders expect to magically appear.

 

If you undestand the nature of objects in java, can do SOME math, and understands which method is responsible for what:

initGui, drawScreen, mouse and keyborad methods, the only thing left for you to do is literally look how vanilla makes things you want to have, no other way. Helpful stuff - Checking call hierarchy and type hierarchy.

 

Hints:

Use GuiScrollingList or GuiListExtended (difference: 1st is forge, 2nd - vanilla, safer to use forge)

Declare GuiScrollingList inside you GuiScreen class.

Initialize list in initGui() - method is called not only when you open gui, but also when you resize screen - NOTE THAT (personal trauma of few hours of searching my own mistake)

put stuff inside (you will want to get data from what diesieben told you in 1st answer) and voila.

 

Put together some code and post it or call me.

 

To actually understand mechincs - you are better off copying part of vanilla code that uses thing you want to use and then edit it step by step, OR if you are brave enough go from scraps alone.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Well thanks for the hints. :P I'll get to looking into creating it. I actually didn't know forge made a GuiScrollingList. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

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. :)

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

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. :)

 

You'll end up much better if you figure things out on your own, however there is a point where you don't even know where to start. The thing we don't want to do is discuss every line of code with you -- it's your mod and should be unique to you (also why there is never a perfect tutorial for what you want to do).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

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. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

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?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I think you should get it but.. GuiScrollingList#elementClicked called when certain element is clicked, so you should set the selected index there. (You should declare the selected variable in the class.)

And, it does not overlay the whole screen. As you can see, some of the parameters of the constructor indicates the size of the list.

+ Are you defining the list class as anonymous class? Don't do that;

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

@Abastro What's wrong with using an anonymous class?

 

@OP For getting the player name, you'd have to look at what type of Object is stored in the 'playerInfoList'. Without looking, my guess is it would be an EntityPlayer of some type, in which case you can use any of the EntityPlayer methods to find their usernames:

for (int i = 0; i < this.list.size(); ++i) {
((EntityPlayer) this.list.get(i)).getDisplayName();
}

 

Yes you can display it over a background by drawing the background and then drawing the foreground, or you can make the scrolling frame part of the background and just draw the text and scrollbar - look at vanilla and/or modded GUI classes, watch the VSWE interface videos again, etc. and you will be able to figure it out.

 

Here is an example of a GUI with a scrollbar.

Posted

I think you should get it but.. GuiScrollingList#elementClicked called when certain element is clicked, so you should set the selected index there. (You should declare the selected variable in the class.)

And, it does not overlay the whole screen. As you can see, some of the parameters of the constructor indicates the size of the list.

+ Are you defining the list class as anonymous class? Don't do that;

 

This is probably an idiotic question but, how exactly would I declare the index?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

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. .-.

 

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

@Abastro What's wrong with using an anonymous class?

I just thought that anonimous class is bad structure, since the codecould be long.

By now, I realized that it is short enough to use anonimous class.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

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

What do you mean by ' there's no variable that I can change that allows me to bring in the left side'?

Please post your code, too.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

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.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Constructor is not like other gui things you met untill this time.

 

GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)

 

width and height are the size of list box. top and bottom are the "trimmers", left is the offset from position 0 starting from left of the screen. entryHeight is static forr all entries size of entry.

 

Example: GuiScrollingList(mc, 4, this.height, 3, this.height - 2, 2, 1)

--XXXX

--XXXX

--XXXX

--OOOO

--OOOO

--OOOO

--OOOO

--XXXX

--XXXX

 

Problem with this gui is that the list itself cannot be offset in Y axis, therefore the 3rd argument must ALWAYS be the height of your screen for it to look GOOD.

1.7.10 is no longer supported by forge, you are on your own.

Posted

For convinience, I've made myself do more explanation for maybe future-finders:

 

23hogia.jpg

 

There are 2 GuiScrollingLists here, lets call them left and right.

GuiScrollingList was designed to be used inside screens that cover whole screen height, therefore if you want to use them on top of world-render, you are going to have to code custom thing.

 

In left list there are 5 elements, E1, E2, E3,E4, E5.

T1 is out top border, B1 is our bottom border.

The renderer that actually renders elements will render only E2, E3 - because they are in visible field, and E4 - yes, WHOLE thing, not jut visible part - that's why there are those "trimming" borders - they are covering what needs to be cut, so followin that logic - you have to make them always be bigger than elementHeight OR make sure that element will go out of screen once it quits border.

 

In right list you can see that E'2 is being rendered outside - that is because it is partially visible in "visible field", yet it passes outside visible field and even outside border, and since height of whole list in != screenHeight - you will get part of it outside boundaries.

1.7.10 is no longer supported by forge, you are on your own.

Posted

@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. xD

 

@jabelar Honestly, it's not that complicated. O.o I mean, your way is simpler but, the way coolAlias showed (the way I used) seems to work just fine. xD I don't see the point in adding them to a string array considering it is not needed.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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