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.

[1.8.9] PlayerInteractEvent - Client/Server - Right-clicking a ladder

Featured Replies

Posted

I have a question about the PlayerInteractEvent, specifically the different behavior on the Client and Server threads when the player is right-clicking on a previously-placed ladder block while holding another ladder.

 

Given the following test code snippet:

@SubscribeEvent
public void clickOnLadder(PlayerInteractEvent event) 
{		
   if (event.pos != null) {			
System.out.println(event.pos.getX() + " " + event.pos.getY() + " " +event.pos.getZ());	
System.out.println(event.world.getBlockState(event.pos).getBlock().getLocalizedName());
   }	
}

 

When right-clicking a placed ladder with an empty hand, I get:

[22:58:56] [Client thread/INFO] [sTDOUT]:  -324 82 412

[22:58:56] [Client thread/INFO] [sTDOUT]:  Ladder

[22:58:56] [server thread/INFO] [sTDOUT]: -324 82 412

[22:58:56] [server thread/INFO] [sTDOUT]: Ladder

 

When holding a ladder, I get:

[22:58:56] [Client thread/INFO] [sTDOUT]:  -324 82 412

[22:58:56] [Client thread/INFO] [sTDOUT]:  Ladder

[22:58:56] [server thread/INFO] [sTDOUT]: 0 0 0

[22:58:56] [server thread/INFO] [sTDOUT]: Stone

 

Is the client-side event somehow suppressing / not sending to the server as a result of holding a ladder?  When holding a ladder, on the Server-side, this makes it impossible to get the coordinates of the clicked block.  Could someone please explain why this would be?

 

Thanks!

 

Using Minecraft 1.8.9 with Forge 11.15.1.1902.

This may actually be a buggy behavior. I have rewritten this to 1.9.4:

    @SubscribeEvent
    public void clickOnLadder(PlayerInteractEvent event)
    {

        if (event.getPos() != null) {
            System.out.println(event.getPos().getX() + " " + event.getPos().getY() + " " +event.getPos().getZ());
            System.out.println(event.getWorld().getBlockState(event.getPos()).getBlock().getLocalizedName());
        }
    }

 

And it produces following output:

 

Empty handed:

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 85 5636

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: tile.air.name

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 85 5636

[08:55:44] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: tile.air.name

[08:55:44] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:55:44] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

[08:55:44] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:55:44] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

 

Ladder in hand:

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 85 5636

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: tile.air.name

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 85 5636

[08:56:06] [Client thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: tile.air.name

[08:56:06] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 85 5636

[08:56:06] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: tile.air.name

[08:56:06] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:68]: 4661 86 5637

[08:56:06] [server thread/INFO] [sTDOUT]: [com.fhfstudio.bot.AIController:clickOnLadder:69]: Ladder

 

It all looks  the same to me. I also tried right clicking the block with other placeable items and it produced the same output. Strange thing though is that the code snipped is apparently called multiple times.

As far as I know this is a vanilla MC bug, the same thing happens with fences. The code gets called in the client thread and in the server thread, making it effectively look like two calls on an integrated server (single player).

As far as I know this is a vanilla MC bug, the same thing happens with fences. The code gets called in the client thread and in the server thread, making it effectively look like two calls on an integrated server (single player).

That isn't OP's problem at at all, and it's not a bug either.

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.