Jump to content

Recommended Posts

Posted

I am currently using the client tick event to check mouse input so I can call a method every tick on both sides (so I can play sounds, spawn entities, manipulate ItemStack NBT, etc.). Yes, I absolutely need to call this method every tick - some items held will have a built-in delay for calling the method. Right now, I am sending a packet to the server in the client tick event, based on mouse input, to call the method and to also send the same packet to the client (Bi-Directional packet) to also call the method. This works well, it calls the method on both sides, however sending packets at that rate and size is a pretty bad idea. It was recommended that I send the packet once setting a Boolean to true, and to save the Boolean in IEEP.

 

Would it be best to send the packet once in the client tick event and then check the IEEP Boolean on the player tick event? Is the player tick event called on both sides? What is the best way of reducing this network traffic while still being able to achieve the same results? Any input is greatly appreciated, thanks.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted
  On 10/23/2015 at 8:41 PM, EverythingGames said:

It was recommended that I send the packet once setting a Boolean to true, and to save the Boolean in IEEP.

 

Would it be best to send the packet once in the client tick event and then check the IEEP Boolean on the player tick event? Is the player tick event called on both sides? What is the best way of reducing this network traffic while still being able to achieve the same results? Any input is greatly appreciated, thanks.

 

1. Yes, if you need to know exacly when player is holding down button/mouse the best way is to send packet containing key(int) and pressed(boolean).

- ClientTickEvent is called once on client per tick, so using it would be "fine", but not entirely, because you would also have to know (on client) if previous-tick button/mouse state is different (and if so - send state-changed packet), which requires additional fields (check is needed so you don't send packet with button state every tick).

- What you can utilize are input events, but I am not sure they work in all cases (might have to use ClientTick after all).

- If you would have to do that - simply hold list of previous states and send apcket only if you know state is different than one from prev-tick.

2. Yes, PlayerTickEvent is called for both sides for each EntityPlayer (mening on client it will be called for every loaded-by-client player). It is also (like other TickEvents) called twice with Phase.

3. Pretty much point 1.

  Quote

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

Posted
  Quote

Packet code?

Pretty much irrelevant to the question - I am not learning how to read and write data from packets.

- I am reading and writing an int (Mouse button pressed) and an ItemStack.

 

  Quote

  Quote

It was recommended that I send the packet once setting a Boolean to true, and to save the Boolean in IEEP.

 

Would it be best to send the packet once in the client tick event and then check the IEEP Boolean on the player tick event? Is the player tick event called on both sides? What is the best way of reducing this network traffic while still being able to achieve the same results? Any input is greatly appreciated, thanks.

 

1. Yes, if you need to know exacly when player is holding down button/mouse the best way is to send packet containing key(int) and pressed(boolean).

- ClientTickEvent is called once on client per tick, so using it would be "fine", but not entirely, because you would also have to know (on client) if previous-tick button/mouse state is different (and if so - send state-changed packet), which requires additional fields (check is needed so you don't send packet with button state every tick).

- What you can utilize are input events, but I am not sure they work in all cases (might have to use ClientTick after all).

- If you would have to do that - simply hold list of previous states and send apcket only if you know state is different than one from prev-tick.

2. Yes, PlayerTickEvent is called for both sides for each EntityPlayer (mening on client it will be called for every loaded-by-client player). It is also (like other TickEvents) called twice with Phase.

3. Pretty much point 1.

Yeah, I was thinking along the same lines. I would like to be able to use the MouseEvent so that I would not need an additional check for the Mouse button being down and not down. Though, I see no way of actually checking is Mouse Button X is not down. Really what I need here is - if Mouse pressed Boolean=true, else if Mouse is not pressed Boolean = false. Send packet once each time to set Boolean to true / false. While Boolean is true, call code on both sides, else return.

 

I'll get to work on it straight away and will post with further progress / questions.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted

There's not really anything wrong with sending a packet each tick if that's really what your code requires - Minecraft sends dozens if not hundreds of packets each tick.

 

However, I don't see why you would need to send the same packet back to the client; can't you just run the code directly from the client side before or after you send the packet to the server, or are you relying on something happening on the server that gets sent in the response?

 

As a comparison, most Minecraft code that sends a packet to the server just sends it one way and runs the code directly on the client, e.g. when a player left-clicks an entity, the attack/action packet is sent to the server, and the client immediately starts processing the player's left click action without waiting for any further data. This is all under the expectation that client-side code is mostly irrelevant except for animations, particles, and the like, so any 'effects' such as damage mean nothing unless on the server.

 

TLDR; cut your packet numbers in half by eliminating the packet from server -> client.

Posted
  On 10/24/2015 at 12:21 AM, coolAlias said:

There's not really anything wrong with sending a packet each tick if that's really what your code requires - Minecraft sends dozens if not hundreds of packets each tick.

 

However, I don't see why you would need to send the same packet back to the client; can't you just run the code directly from the client side before or after you send the packet to the server, or are you relying on something happening on the server that gets sent in the response?

 

As a comparison, most Minecraft code that sends a packet to the server just sends it one way and runs the code directly on the client, e.g. when a player left-clicks an entity, the attack/action packet is sent to the server, and the client immediately starts processing the player's left click action without waiting for any further data. This is all under the expectation that client-side code is mostly irrelevant except for animations, particles, and the like, so any 'effects' such as damage mean nothing unless on the server.

 

TLDR; cut your packet numbers in half by eliminating the packet from server -> client.

 

That makes more sense. My code does require that a packet is sent every tick (or every X amount of ticks depending on the item's delay). The reason that I did not just call the code in the ClientTickEvent and then sending the packet to execute on the server side was because of pure aesthetics in the code itself - I handled everything in one packet and kind of kept key / mouse input separate from everything excluding networking, which is foolish now that you mention that it would cut the packets in half...that will change. Minimizing networking traffic seems great and efficient, though sending a packet each tick, or every X amount of ticks, would cut down on implementing IEEP - saving time.

 

For anyone who would want to not send a packet each tick, here is a bit on (untested) code that will allow you to do that:

@SubscribeEvent
public void onEvent(ClientTickEvent event)
{
	boolean pressed = Mouse.isButtonDown(0);
	boolean packetSent = false;
	if(!event.phase.equals(Phase.START)) return;
	if(pressed && !packetSent)
	{
		//Send packet to change boolean to true
		packetSent = true;
	}
	if(!pressed && packetSent)
	{
		//Send packet to change boolean to false
		packetSent = false;
	}
}

 

EDIT: Above code needs a minor fixing - the concept works but the reset (setting the Boolean back to false is broken). I'm sure someone can figure something out and use it.

 

One last question - if I need the code called on both sides while the player is actively in the world, and this check applies for any players with my item, why can't I just call the code in the PlayerTickEvent and check the Mouse button there and not have to send packets at all?

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Posted

Because the server side has no concept of the Mouse or what state it is in.

 

For the 'packetSent' variable, I might prefer to call it 'mouseClicked' or something, since it is tracking when the state of the mouse changes, but that's just a matter of how you look at it (not a big deal, obviously). Also, it would be wise to have the same logic on the server, so each time the packet is sent with the current mouse state, the server can validate it before processing anything else, this way if somehow the packet gets sent a bunch of times in a row with 'mouseClicked = true', it doesn't result in extra actions.

 

As for clean code - that's a good thing to strive for, and if you look again at vanilla, you'll notice that, in the example I gave earlier, the packet simply calls the same code that the client called, namely EntityPlayer#attackTargetEntityWithCurrentItem, with some extra validation server side, of course. This way all of the logic is contained in that one method, and either side can call it as need be, so there is no code duplication.

Posted

I actually ended up writing listeners that you implement. Pretty much like an event (considering the Listener you implement event handles for you), except unlike an event, you extend the specific Listener class and it gives you a few methods (depending on the listener type) that you must override. For example, I have a ListenerClientMouse class extending ListenerClient (which ultimately extends Listener, except ListenerClient is client side only, obviously). The ListenerClientMouse listens for when the user is holding down the mouse, when the mouse is not being held down (not doing anything), when the mouse was clicked (semi-automatic mouse click), and finally when the mouse was released (semi-automatic mouse released).

 

Using the 'MouseListener' that I wrote, I can now easily send a packet to the server once per click (regardless if user is holding, the method is called only once meaning only one packet is sent), and once per release (again, only called one, only one packet sent). A boolean is set upon click / release in IEEP and checked on the PlayerTickEvent. Everything worked like a charm, though it seemed like too much effort for a bit of optimization. The code is similar to the code shown above.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

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

    • Temu  bunch of Coupon Codes for Temu  to get FTemuREE GIFTS, DISCOUNTS, SAVINGS, and MORE. Check out below and download the Temu  app now !!! Temu  Coupon Code ( acy240173) 30% Off + 100€ OFF in Coupons + Free Shipping + More for Temu  NEW / EXISTING Users. Get 100€ OFF in Coupons + 30% OFF + More; Temu  promo code ( acy240173 ). Temu  Sitewide Sales up to 95% OFF sitewide. Temu  30% Off and 100€ Off in Coupons for NEW and EXISTING users. Use promo code ( acy240173) at checkout!!   Temu  coupon codes for New users 100€ Off - acy240173 Temu  discount code for New customers- acy240173 Temu  100€ coupon code- acy240173 what are Temu  codes - acy240173  does Temu  give you €300- acy240173 Yes Verified Temu  coupon code October2025- acy240173 Temu  New customer offer acy240173 Temu  discount code2025 acy240173 100 off coupon code Temu  acy240173 Temu  100 off any order acy240173 100 dollar off Temu  code acy240173 Temu  Coupon Code ( acy240173 ) 30% Off + 100€ OFF in Coupons + Free Shipping + More for Temu  NEW / EXISTING Users. Get 100€ OFF in Coupons + 30% OFF + More; Temu  promo code (acy240173 ) or ( acy240173 ). Temu  Sitewide Sales up to 95% OFF sitewide. Temu  30% Off and 100€ Off in Coupons for NEW and EXISTING users. Use promo code ( acy240173 ) at checkout!! Temu  coupon code for First Order - {acy240173} Temu  coupon code for New Users- {acy240173} Temu  coupon code for Existing Users- {acy240173} Temu  coupon code 100€ Off- {acy240173} Temu  coupon 30% Off code - {acy240173} - Temu  new user coupon code: acy240173 - Free gift on Temu : acy240173 - Temu  90% discount coupon code: acy240173 - Temu  100€ coupon code for first order: acy240173   Is the Temu  100€ Coupon Legit?  Yes, there are several legit Temu  coupon codes [ acy240173] available for 100€ off. Here are the options you can use: Code [acy240173]: This code provides a 100€ discount legit on your first order when you register and is reported to work effectively during checkout. Code [acy240173]: New users can also use this code to receive a 100€ discount on purchases over €249. Code [acy240173]: This code is available for both new and existing users, offering a 100€ discount on your order. Code [acy240173]: Another option for both new and existing users, this code allows you to save 100€ on your purchase.   Temu  Coupon code 100€ off for this month For October2025, several active Temu  coupon codes can help you save on your purchases: 40% Off Site-Wide: Use code "acy240173" to get 40% off everything. This code is widely used and verified for site-wide discounts on orders over €20. 40€ Off for New Customers: New customers can receive a €20 voucher by downloading the Temu  app and participating in an H5 page game. This voucher can be redeemed using a specific coupon “acy240173”. 40% Off Selected Items: There is also a 40% off coupon “acy240173” available for select items on the Temu  website. Remember to check the specific terms and conditions for each coupon, such as minimum purchase requirements and applicable product categories.   Temu  coupon code 100€ off for new and existing customer Temu  90% OFF promo code "acy240173 " will save you 100€ on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu  offers 100€ off coupon code [acy240173] Temu  Coupon code [acy240173 ] for existing users can get up to 50% discount on product during checkout. Temu  Coupon Codes for Existing Customers-[acy240173 ] Temu  values its loyal customers and offers various promo codes, including the Legit Temu  Coupon Code [acy240173 ] or [acy240173 ], which existing users can use. This ensures that repeat shoppers can also benefit from significant discounts on their purchases. Keep an eye out for special promotions and offers that are periodically available to enhance your shopping experience.   Temu  Coupon Code 100€ Off for all users  There are specific Temu  coupon codes [acy240173] mentioned for South Africa in the provided search results. The results focus on general Temu  coupon codes [acy240173] and discounts, as well as codes for other countries like the Germany, UK, Canada, Mexico, Kuwait, Austria, Italy, Australia, France , Switzerland, Poland, Saudi Arabia, Germany, Sweden, Portugal, New Zealand, UAE, Belgium, Germany, and France.   Temu  Coupon Code 30% Off: acy240173 Temu  Coupon Code 100€ Off: acy240173 Temu  Coupon Code 100€ Off United States : acy240173 Temu  Coupon Code 100€ Off Germany: acy240173 Temu  Coupon Code 100€ Off Sweden : acy240173 Temu  Coupon Code 100€ Off Finland : acy240173 Temu  Coupon Code 50% : acy240173 Temu  Coupon Code 100€ Off United Kingdom : acy240173 Temu  Coupon Code 100€ Off : acy240173 Temu  Coupon Code 100€ Off : acy240173 Temu  Coupon Code 100€ Off Italy : acy240173 Temu  Coupon Code  100€ Off : acy240173 Temu  Coupon Code 100€ Off Austria : acy240173 Temu  Coupon Code 100€ Off Belgium : acy240173 Temu  Coupon Code 100€ Off : acy240173 Temu  Coupon Code 100€ Off Canada : acy240173 Temu  Coupon Code 100€ Off : acy240173 Temu  Coupon Code 100€ Off Estonia : acy240173 Temu  Coupon Code 100€ Off Switzerland : acy240173 Temu  Coupon Code  100€ Off : acy240173 Temu  Coupon 30% Off + Free Shipping & More There are a bunch of Coupon Codes for Temu  to get FREE GIFTS, DISCOUNTS, SAVINGS, and MORE. Check out below and download the Temu  app now !!! Temu  Coupon Code ( acy240173) 30% Off + 100€ OFF in Coupons + Free Shipping + More for Temu  NEW / EXISTING Users. Get 100€ OFF in Coupons + 30% OFF + More; Temu  promo code (acy240173) \ Temu  Sitewide Sales up to 95% OFF sitewide. Temu  30% Off and 100€ Off in Coupons for NEW and EXISTING users. Use promo code ( acy240173) at checkout!!Temu  Coupon Code Mexico : acy240173 Temu  Coupon Code 100€ Off Ireland : acy240173 Temu  Coupon Code 100€ Off Norway: acy240173 Temu  Coupon Code 100€ Off New Zealand : acy240173 Temu  Coupon Code 100€ Off Poland : acy240173 Temu  Coupon Code 100€ Off Serbia : acy240173 Temu  Coupon Code 100€ Off Armenia : acy240173 Temu  Coupon Code 100€ Off Austria : acy240173 Temu  Coupon Code 100€ Off Greece : acy240173 Temu  Coupon Code 100€ Off Japan : acy240173 Temu  Coupon Code 100€ Off Iceland : acy240173 Temu  Coupon Code 100€ Off Bahrain : acy240173 Temu  Coupon Code 100€ Off Philippines : acy240173 Temu  Coupon Code 100€ Off Portugal : acy240173 Temu  Coupon Code 100€ Off Romania: acy240173 Temu  Coupon Code 100€ Off Slovakia : acy240173 Temu  Coupon Code 100€ Off Malta: acy240173 Temu  Coupon Code 100€ Off France  : acy240173 Temu  Coupon Code 100€ Off South Africa : acy240173 Temu  Coupon Code 100€ Off Hungary : acy240173 Temu  Coupon Code 100€ Off Brazil : acy240173 Temu  Coupon Code 100€ Off Finland : acy240173 Temu  Coupon Code 100€ Off Morocco : acy240173 Temu  Coupon Code 100€ Off Kazakhstan : acy240173 Temu  Coupon Code 100€ Off Colombia : acy240173 Temu  Coupon Code 100€ Off Chile : acy240173 Temu  Coupon Code 100€ Off Israel : acy240173 Temu  Coupon Code 100€ Off Qatar: acy240173 Temu  Coupon Code 100€ Off Slovenia : acy240173 Temu  Coupon Code 100€ Off Uruguay : acy240173 Temu  Coupon Code 100€ Off Latvia: acy240173 Temu  Coupon Code 100€ Off Jordan : acy240173 Temu  Coupon Code 100€ Off Ukraine : acy240173 Temu  Coupon Code 100€ Off Moldova : acy240173 Temu  Coupon Code 100€ Off Oman: acy240173 Temu  Coupon Code 100€ Off Mauritius : acy240173 Temu  Coupon Code 100€ Off Republic of Korea : acy240173 Temu  Coupon Code 100€ Off Dominican Republic: acy240173 Temu  Coupon Code 100€ Off Czech Republic : acy240173 Temu  Coupon Code 100€ Off United Arab Emirates : acy240173 Temu  Coupon Code 100€ Off Peru : acy240173 Temu  Coupon Code 100€ Off Azerbaijan : acy240173 Temu  Coupon Code 100€ Off Saudi Arabia : acy240173 Temu  Coupon Code 100€ Off Croatia : acy240173   Conclusion The Temu  Coupon Code 100€ Off "acy240173" provides a significant discount of 100€ for users in Bahrain. This offer is available for both new and existing customers, allowing them to save substantially on their purchases.In addition to the 100€ discount, customers can also enjoy a 50% off on their orders. To redeem this coupon, simply sign up for a Temu  account, add items worth 100€ or more to your cart, and enter the code during checkout to apply the discounts automatically.   FAQs about the 100€ Off Coupon Code Q1: Who can use the 100€ off coupon? A: The coupon is available for both new and existing users, although different codes may apply to each group. Q2: Can multiple coupon codes be used at once? A: Generally, only one coupon code can be applied per transaction. However, some codes may offer bundled benefits. Q3: Do these coupons expire? A: Many Temu  coupons do not have an expiration date, making them convenient for users to redeem at their leisure. Q4: Are there specific conditions for using these coupons? A: Yes, some coupons may require a minimum purchase amount or specific item categories to be eligible for the discount. Q5: How can I find the latest Temu  Coupon Code 100€ Off 100€ Offs? A: Users can check within their account under "Coupons & offers" or look for updates on promotional websites and forums.
    • You could try this script: https://inconnu-plugins.de/tutorial/server-auto-restart
    • I have already tried other versions of MCP, from 2841 to 2860.
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • The official documentation says next to nothing and I have had no success finding reference snippets (e.g. minimap mods and other stuff that involves directly drawing to the screen). Google searches and GPT outputs reference deprecated and/or removed content from older versions. Legends speak of a layered rendering system that also has next to no documentation. Any help is appreciated. Even drawing just a single pixel is enough.
  • Topics

×
×
  • Create New...

Important Information

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