Everything posted by Roboguy99
-
[1.7.10] A quick question about packets
I'm going to sound like some lazy arse programmer who just copies and pastes people's code without understanding, then makes a million excuses in reply, but here's what's happened: I've read and copied the code (I typed, didn't c+p) your tutorial with very little understanding of how the packets work. I was doing something else at the same time, so my attention was only half on programming. Failender told me I should use the constructor with arguments, so I assumed this meant send a string. He then told me to remove the string from the arguments, so I did. By this point I completely forgot that text field existed, and I was checking into this thread every now and then while doing something else. Thanks for the help, and I'll try to be less stupid in the future. It was entirely my fault, and I appreciate that. You guys are very useful, and I didn't mean to waste your time with a really noob mistake like that. EDIT: One last thing, because I'm confused myself silly with all this now. Do I get rid of all references to the string as I don't need it, and leave the fromBytes()/toBytes() blank or do I actually need the string, or something I've also somehow stupidly missed which is so blatantly obvious I need to go and punch a wall? If that sounded like it was against you, it seriously wasn't. I'm angry I didn't spot the text field sooner.
-
[1.7.10] A quick question about packets
The only thing I changed was this line: HotbarBag.networkWrapper.sendToAll(new InventoryUpdate()); I'll upload the rest of the packet related code so you can see that as well: Main class pre-init: Packet class:
-
[1.7.10] A quick question about packets
Ok I've done that and I get this:
-
[1.7.10] A quick question about packets
I'm not getting a crash log - NOTHING is happening. If I don't initialise with a string, I get a nep I am sending the packet using HotbarBag.networkWrapper.sendToAll(new InventoryUpdate("updateInventory")); I have also tried .sendToServer() and got the same result.
-
[1.7.10] A quick question about packets
Ok, but as I said with a message nothing happens.
-
[1.7.10] A quick question about packets
uploaded wrong class, whoops I'm changing it now. In answer to part 1 of your reply, that code was client-side. Lesson learned - make sure you paste the right thing before clicking submit.
-
[1.7.10] A quick question about packets
Ok I've created the packet, but I have a couple of problems. Firstly, my packet doesn't actually seem to be received. If I don't initialise InventoryUpdate (the IMessage class) with a string, it throws a nullpointerexception when encoding. If I do pass a string, nothing happens. Secondly, I have no idea how to actually use the packet to update the inventory. Here's the packet class:
-
[1.7.10] A quick question about packets
Ok thanks, I will create one then.
-
[1.7.10] A quick question about packets
Update as in change the the contents of slots.
-
[1.7.10] A quick question about packets
I want it so when the player clicks a button, their inventory, and another inventory, are both updated. The code to update the inventory is triggered client-side, so as soon as you try to open the updated inventory it un-updates because the server was unaware of the change. Do I need to write a load of packet-handling code or is there a much easier way of doing this?
-
[1.7.10] KeyBinding keyUp() method
Caused a nullpointerexception updating the inventory because no item had been select to update (an item is selected on key release). I'll try jiggling around some code to see if it will work. Also, has anybody got a link to a tutorial on updating the inventory client-side (or would it be better to move the update code to a common class instead?) EDIT: If I set it to true, I get exactly the same result.
-
[1.7.10] KeyBinding keyUp() method
Ok I have no idea when I removed that, because I remember it being there, but it's now not set to anything (just private boolean pressedLastTick; ). I still have to press the key twice for it to work.
-
[1.7.10] KeyBinding keyUp() method
Hmm, well it's not working. I'll upload the class in which the game is unfocussed and the HUD is drawn, because it must be something in there. I hate logic.
-
[1.7.10] KeyBinding keyUp() method
Whoops. I actually did, that just more testing before I sent the code.
-
[1.7.10] KeyBinding keyUp() method
Using .getIsKeyPressed() I got the same result (HUD renders for 1 tick and game remains unfocussed first button press, second button press acts as expected). I then tried .isPressed() and now the HUD only renders for 1 tick and the game never re-focusses. Here's my code, just in case I've done something stupid: private boolean pressedLastTick = false; @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.START) { if (pressedLastTick && !HotbarBag.bagHUD.isPressed()) { Minecraft.getMinecraft().setIngameFocus(); } pressedLastTick = HotbarBag.bagHUD.getIsKeyPressed(); } }
-
[1.7.10] KeyBinding keyUp() method
I want it to be true as the key is let go of, so as it is released (not true for as long as the key is not pressed, otherwise I could have just used !keyIsPressed() couldn't I?). The problem is it is only set to true if you release it twice for some reason.
-
[1.7.10] KeyBinding keyUp() method
For some reason keyReleased is not set to true unless I release the key, press it and release it again. Here is the entire class: public class TickEventHandler { public static boolean keyReleased = false; @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.START) { if (keyReleased && !HotbarBag.bagHUD.getIsKeyPressed()) this.keyReleased = true; keyReleased = HotbarBag.bagHUD.getIsKeyPressed(); System.out.println(this.keyReleased); } } } This is also causing the HUD to only render for one frame. Here's the check for that: if (TickEventHandler.keyReleased && !minecraft.inGameHasFocus) minecraft.setIngameFocus(); Sorry if I'm making really stupid basic Java mistakes, but it's the first week back at school and I'm tired
-
[1.7.10] KeyBinding keyUp() method
I'll admit I did very quickly skim through the answer in between doing something else. Thanks.
-
[1.7.10] KeyBinding keyUp() method
I probably should have made this clear, but I need to know when the key is actually let go of, not just all the time it's not held down. Or maybe I did make this clear, and you've answered that? Sorry for the stupid questions.
-
[1.7.10] KeyBinding keyUp() method
I need to know when a key is released, and have noticed no built in method for this. How would I make one?
-
[1.7.10] Freeing cursor on keypress
Ok so I can unfocus the game without a problem, but making sure it's focussed again when the button is released is quite hard: a) I don't wan't to keep the game focussed even when other HUD elements (i.e the chat or pause menu) are trying to open because this breaks them and b) I want my HUD element to appear for more than one frame. I suppose what I'm asking by hinting at my problems is how do I toggle the focus on button press without keeping it stuck in focus the whole time the button is not pressed? Would I need to write a keyUp method (this could do with being implemented into Forge, I might look into writing and pushing it when I've got time), or is there a better way? Here's the whole class (mostly) to (maybe) make life easier:
-
[1.7.10] Freeing cursor on keypress
This seems like it should work. I'm going to have to play with it a bit, because you have to manually re-set the focus when the key is no longer pressed. If the other method doesn't work, I will use a GUI. It sounds easy enough, although I'll need to find out how packets work.
-
[1.7.10] Freeing cursor on keypress
My weapon wheel is rendered straight onto the HUD because it was easier to dynamically adjust the size this way. Would opening a GUI still work, and would I just have to open it client-side?
-
[1.7.10] Freeing cursor on keypress
So the idea is when the player holds down a key, a HUD appears showing items stored in an inventory in a GTA V-style weapon wheel. The rendering is all done, but I'd like the user to be able to move their cursor over one of the options and click (or move the cursor and let go of the key without clicking, doesn't really matter). So I need to know the mouse co-ordinates and possibly when they click essentially.
-
[1.7.10] Freeing cursor on keypress
I want to make it so when the player presses a key (my keybind is already working) the cursor is unlocked from the centre like when you use a Gui, and locked again when the player lets go. How would I do this?
IPS spam blocked by CleanTalk.