plugsmustard Posted December 4, 2019 Posted December 4, 2019 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 Quote
plugsmustard Posted December 4, 2019 Author Posted December 4, 2019 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 Quote
plugsmustard Posted December 4, 2019 Author Posted December 4, 2019 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? Quote
Draco18s Posted December 4, 2019 Posted December 4, 2019 (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 December 4, 2019 by Draco18s Quote 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.
plugsmustard Posted December 4, 2019 Author Posted December 4, 2019 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 Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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 Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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? Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 Just now, diesieben07 said: Like this. do you have a small example i can look at then? ive read that entire thing, but i am always unsure Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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? Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 Just now, diesieben07 said: What on earth are you talking about? alright. where in vanilla are there those examples you mentioned? Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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! Quote
Draco18s Posted December 5, 2019 Posted December 5, 2019 (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 December 5, 2019 by Draco18s Quote 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.
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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! Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 25 minutes ago, Draco18s said: virtually nothing correct and really? nothing? Quote
loordgek Posted December 5, 2019 Posted December 5, 2019 (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 December 5, 2019 by loordgek Quote
loordgek Posted December 5, 2019 Posted December 5, 2019 and delete https://github.com/drmdgg/marijuanacraft1.14.4/blob/a27ad62dfb81267511d4ab1ecf2eff5b6c6eba58/src/main/java/drmdgg/marijuanacraft/client/gui/GuiVO.java#L84-L86 Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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 Quote
loordgek Posted December 5, 2019 Posted December 5, 2019 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/ Quote
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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 ) Quote
Draco18s Posted December 5, 2019 Posted December 5, 2019 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. Quote 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.
plugsmustard Posted December 5, 2019 Author Posted December 5, 2019 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 Quote
plugsmustard Posted December 6, 2019 Author Posted December 6, 2019 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? Quote
loordgek Posted December 6, 2019 Posted December 6, 2019 https://github.com/drmdgg/marijuanacraft1.14.4/blob/master/src/main/java/drmdgg/marijuanacraft/network/PacketButtonClicked.java#L29 you need to get the pos from the packetbuffer the ide will tell whats wrong Quote
plugsmustard Posted December 6, 2019 Author Posted December 6, 2019 19 minutes ago, loordgek said: https://github.com/drmdgg/marijuanacraft1.14.4/blob/master/src/main/java/drmdgg/marijuanacraft/network/PacketButtonClicked.java#L29 you need to get the pos from the packetbuffer the ide will tell whats wrong okay, i think i know what you mean. could you give me a little more descriptions if possible? Quote
Recommended Posts
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.