Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


chupybara
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.