I was wondering how to make it that when you press my key, you fire a snowball, but only one? So that they can't hold the key down and continuously fire.
If you don't know how to detect keypresses, you register a KeyBinding using ClientRegistry, then you query every client tick isPressed (It should only return true once per keypress), and if it's true, you send a message to the server with SimpleNetworkWrapper, and then in the handler, you do the above function.
Rollback Post to RevisionRollBack
Frontier - Space ships in Minecraft, made out of blocks!
The server and the client side both exist even in single player mode.
Server-side does all the calculations, ticks mobs, etc.
Client-side's main job is to render everything in the world, but the client also ticks mobs to make the rendering smoother and to avoid tons of packets.
Packets are sent from the server to the client (or vice-versa) to let the other side know about something new. For example, the server sends packets to the client about mob spawns, player movement, which blocks are where, and much more. The client sends packets to the server about when the player starts and stops moving.
In this situation, it sounds like you are spawning snowballs in client code. When the snowball key is pressed, send a packet to the server, which (when processed) will shoot out a snowball.Packet tutorial
I was wondering how to make it that when you press my key, you fire a snowball, but only one? So that they can't hold the key down and continuously fire.
On the server side, you do
worldIn.spawnEntityInWorld(new EntitySnowball(world, player));
If you don't know how to detect keypresses, you register a KeyBinding using ClientRegistry, then you query every client tick isPressed (It should only return true once per keypress), and if it's true, you send a message to the server with SimpleNetworkWrapper, and then in the handler, you do the above function.
I know how key works, and how to fire a snowball, but I'm wondering how to only fire one snowball for every press, not one for every tick.
You use isPressed, not isKeyDown.
I use getIsKeyPressed() but when I use isPressed() I cannot see the snowballs firing.
Ignore this comment if you are using packets!
This seems to be a problem between server/client.
The server and the client side both exist even in single player mode.
Server-side does all the calculations, ticks mobs, etc.
Client-side's main job is to render everything in the world, but the client also ticks mobs to make the rendering smoother and to avoid tons of packets.
Packets are sent from the server to the client (or vice-versa) to let the other side know about something new. For example, the server sends packets to the client about mob spawns, player movement, which blocks are where, and much more. The client sends packets to the server about when the player starts and stops moving.
In this situation, it sounds like you are spawning snowballs in client code. When the snowball key is pressed, send a packet to the server, which (when processed) will shoot out a snowball.Packet tutorial
~ Crows
Avatar Mod 2 -- Elemental Bending from Avatar: The Last Airbender
Contact: PM or [email protected]