Jump to content

Recommended Posts

Posted

can someone point me in the right direction. 

i have a "purge" button on my furnace's GUI, but the "purge" method is something i am unsure of. i looked at various examples, but nothing seemed like it was what i was looking for. 

i simply want my furnace to be switched on and burn the item when the button is clicked.

 

thanks in advance 

Posted
10 minutes ago, diesieben07 said:

You will need to send a custom packet to the server when the button is clicked. When the packet is received server-side, validate that the player can actually perform the requested action (in range, etc.) and if so, toggle your furnace's state.

do i need to make an entire new class for this one button because i have it in my gui class. and if not, do implement what you just showed me in my "purge" method

Posted
13 minutes ago, diesieben07 said:

I really do not understand your question.

do i need to make a new class for this gui button (ive seen several examples that do this)

here's my code for what i have:

 

 

addButton(new Button(relX + 18, relY + 15, 5, 20, "PURGE", button -> purge("NOT SURE WHAT TO PUT HERE")));
}

public void purge(String id)

{
    return;  <-------------NOT SURE WHAT TO PUT HERE

}

 

where do i implement the custom packets?

Posted (edited)
4 minutes ago, plugsmustard said:

NOT SURE WHAT TO PUT HERE

sendPacketToServer()

 

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/industry/client/gui/FilterGuiContainer.java#L83

(Yes, you will need at least one new class)

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
2 minutes ago, diesieben07 said:

I am not sure either. You added the String id parameter to the purge method. What for?

i was looking at examples, this is what it automatically adds:
private Object purge(String string)

{
    return null;
}

 

5 minutes ago, diesieben07 said:

I have no idea what this question means. You can develop your code wherever you like, you could even do it in your car, if you have a laptop.

lol, forget it then

Posted
20 minutes ago, diesieben07 said:

What is "it"?

my bad...this:

addButton(new Button(relX + 18, relY + 15, 5, 20, "PURGE", button -> purge("not sure")));

 

this "purge" tells me to add a method called purge

Posted
Just now, diesieben07 said:

Ah yes, good old "programming by eclipse quickfix". That's not how programming works.

in the example i was looking at, that's how they did it. how should i be doing it?

Posted
2 minutes ago, diesieben07 said:

Vanilla has examples on how to add an action to a button.

My link explains how to create and send custom packets.

What more information do you need?

you mean like the button classes?

Posted
6 hours ago, diesieben07 said:

Any GUI that has a button on it. MainMenuScreen for example.

Alirght. I'm a little lost. could you give me a bit more help?

here's what i have so far...whether it is correct, im not sure.

 

GUI:

https://github.com/drmdgg/marijuanacraft1.14.4/blob/a27ad62dfb81267511d4ab1ecf2eff5b6c6eba58/src/main/java/drmdgg/marijuanacraft/client/gui/GuiVO.java#L79-L86

 

network:
https://github.com/drmdgg/marijuanacraft1.14.4/tree/master/src/main/java/drmdgg/marijuanacraft/network

 

don't be too harsh!

Posted (edited)

Oh god, oh god, oh god oh god ohgodohgodohgod

There is virtually nothing correct about what you have. Some of it is still a direct copy of my own code without any attempt to change it.

 

Your button still does fuckall because you gave it an empty stub method, that still takes a string parameter that you do fuckall with, have fuckall purpose for, and even have made it clear that you don't even know why you have it (which is true, because it does fuckall).

 

What the fuck is this shit. Why are you creating a tile entity? Why are you trying to send a tile entity across the network?

Not that you ever even call that method.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
5 minutes ago, Draco18s said:

Oh god, oh god, oh god oh god ohgodohgodohgod

There is virtually nothing correct about what you have. Some of it is still a direct copy of my own code without any attempt to change it.

 

Your button still does fuckall because you gave it an empty stub method, that still takes a string parameter that you do fuckall with, have fuckall purpose for, and even have made it clear that you don't even know why you have it (which is true, because it does fuckall).

 

What the fuck is this shit. Why are you creating a tile entity? Why are you trying to send a tile entity across the network?

Not that you ever even call that method.

people may call you a dick, but i like yer style. 
and i used yers an example, but mostly went off the simpleImpl stuff i was shown in the docs. i deleted most of what i used from yours just missed that.

and i know everything does fuck all right now, i am unsure of what to put in the places where that has already been mentioned. and to be honest. i don't fucking know why the fuck i was doing that with my tile entity in that portion. 
all i can ask is for help and direction. and you know yer shit!

Posted (edited)
addButton(new Button(relX + 18, relY + 15, 5, 20, "PURGE", button -> sent the message to the server));

is that so hard ?

 

https://github.com/drmdgg/marijuanacraft1.14.4/blob/master/src/main/java/drmdgg/marijuanacraft/network/PacketHandler.java#L49

you want to not this

 

https://github.com/drmdgg/marijuanacraft1.14.4/blob/master/src/main/java/drmdgg/marijuanacraft/network/Networking.java#L12

is a bad name

 give the constructor only the blockPos

in the encode method encode the blockPos look inside the PacketBuffer to see how

in decode return a new packet

Edited by loordgek
Posted
20 minutes ago, loordgek said:

is that so hard ?

yes, and that gives me errors.

 

20 minutes ago, loordgek said:

is a bad name

what should i be names then? ButtonClicked or something like that?

 

21 minutes ago, loordgek said:

give the constructor only the blockPos

in the encode method encode the blockPos look inside the PacketBuffer to see how

im assuming im wrong:

    public Networking(BlockPos pos) {
        this.pos = pos;
    }
  
    public static void encode(Networking msg, PacketBuffer buf) {
        buf.readBlockPos();
    }

22 minutes ago, loordgek said:

in decode return a new packet

not 100% on what you mean by this

Posted
5 minutes ago, plugsmustard said:

not 100% on what you mean by this

give it a try it is simple

 

5 minutes ago, plugsmustard said:

what should i be names then? ButtonClicked or something like that?

yes packetButtonClicked

 

6 minutes ago, plugsmustard said:

im assuming im wrong:

no that is fine

 

8 minutes ago, plugsmustard said:

yes, and that gives me errors.

no shit sherlock

sent the message to the server

https://mcforge.readthedocs.io/en/1.13.x/networking/simpleimpl/

Posted
7 minutes ago, loordgek said:

give it a try it is simple

 

yes packetButtonClicked

 

no that is fine

 

no shit sherlock

sent the message to the server

https://mcforge.readthedocs.io/en/1.13.x/networking/simpleimpl/

1. maybe for you, i don't get this at the moment and everyone is giving me different ways to do this.

2. changed the name

3. really!? unbelievable

4. ive read all of that like three times now. still don't understand

 

(call me stupid, i dont care. im doing my best to learn as i want to implement buttons on my other GUIs )

 

Posted
5 minutes ago, plugsmustard said:

4. ive read all of that like three times now. still don't understand

I posted this already, but sure, I'll do it again.

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/industry/client/gui/FilterGuiContainer.java#L83

That line is what you put in the "send stuff to server here" location. Or I should say, a line like that. You'll have to massage it to fit your class names, data details, and so on.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
28 minutes ago, Draco18s said:

I posted this already, but sure, I'll do it again.

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/industry/client/gui/FilterGuiContainer.java#L83

That line is what you put in the "send stuff to server here" location. Or I should say, a line like that. You'll have to massage it to fit your class names, data details, and so on.

 addButton(new Button(relX + 18, relY + 15, 5, 20, "PURGE", button -> PacketHandler.sendToServer(new PacketButtonClicked(tileEntity.getPos()))));  ????

 

if that's not right, im gonna snap

Posted
5 hours ago, loordgek said:

yes that looks right

well thats just fantastic.

i THINK i have some of the other parts. but in my packethandler, i'm getting errors on this line due to my encode and decode methods in "PacketButtonClicked" 

https://github.com/drmdgg/marijuanacraft1.14.4/blob/cf3c6c06d4ac6c8245a386a2159b5ae8284ec25a/src/main/java/drmdgg/marijuanacraft/network/PacketHandler.java#L32

https://github.com/drmdgg/marijuanacraft1.14.4/blob/master/src/main/java/drmdgg/marijuanacraft/network/PacketButtonClicked.java

what else should i be adding in there?

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



×
×
  • Create New...

Important Information

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