Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

 

I found that the PlayerInteractEvent had a pretty strange behaviour.

 

Let me be a bit more precise.

Here's the minimalistic piece of code I used :

@SubscribeEvent
public void onPlayerBreakBlock(PlayerInteractEvent event) {
    System.out.println("PlayerInteractEvent => " + event);
}

 

Here's the behaviour of this event :

    - In singleplayer, left clicking a block triggers this event with event.action = LEFT_CLICK_BLOCK

    - In singleplayer, right clicking (or placing) a block triggers this event with event.action = RIGHT_CLICK_BLOCK

    - In multiplayer, left clicking a block DOES NOT triggers this event at all.

    - In multiplayer, right clicking (or placing) a block triggers this event with event.action = RIGHT_CLICK_BLOCK

 

Why does this event isn't triggered in multiplayer when left-clicking a block ?

 

This disfunctionment is happening with the two 1.7.10 Forge builds available at this day :

The recommended one (10.13.0.1180) and the latest one (10.13.0.1205).

 

PS : I'm sorry for my English, I'm French.

When you say multiplayer, you have a vagueness in your description. You have 1) integrated server, 2) standalone server, and 3) client connecting to standalone server.

 

So, please describe in which scenario from those do you experience the oddness.

  • Author

Thank you for your response.

 

You're right, i'm totally unclear.

Sorry for the inconvenience.

 

I'm working on a simple inventory manager plugin that select automatically the best tool when you start digging a block.

To do so, I need to know which block I dig, that's why I use the PlayerInteractEvent.

 

That means that i'm working exclusively on the client, and that multiplayer means when i'm connected to a regular Vanilla 1.7.10 server with the client.

 

I hope these informations will be useful.

  • Author

Thank you for your help, the MouseEvent is a brilliant replacement for the PlayerInteractEvent.

 

Unfortunately, this one don't have the X, Y and Z coordinates of the block I'm aiming.

The X and Y values provided by this event are not corresponding to what I'm looking for.

That's why I used a raytrace with the player's position and camera angles to find the right values.

 

Thread solved.

LEFT_CLICK_BLOCK only fires on the server, not the client. You could try using MouseEvent to intercept client side mouse clicks and determine if the player is about to start mining a block.

 

Why not send a packet to client?

 

Also, it does seem a bit weird that these events aren't consistent in their firing.  I mean it kinda makes sense based on the type of click, but it wouldn't really have hurt to fire on both sides...like what if you wanted to add visual effect on left clicks or something?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Why not send a packet to client?

Sometimes, that's just too slow, especially when dealing with things like mouse-clicks. Client clicks mouse -> sends packet to server -> fires interact event -> processes -> sends packet back to client... it's too late, as the server already did its work (barring some convoluted coding).

 

Also, it does seem a bit weird that these events aren't consistent in their firing.  I mean it kinda makes sense based on the type of click, but it wouldn't really have hurt to fire on both sides...like what if you wanted to add visual effect on left clicks or something?

I agree - RIGHT_CLICK_BLOCK is fired on both sides, so why not LEFT_CLICK_BLOCK? It may just be a poor choice of event placement, sort of like the one diesieben07 submitted a PR for last time, or it may be a deeper issue... I haven't looked into it other than noting its behavior.

 

EDIT: Check it out, a PR for this issue: https://github.com/MinecraftForge/MinecraftForge/pull/1121

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.