Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cancelling PlayerInteractAtEntityEvent causes impossible entities #11496

Open
miniking1000 opened this issue Oct 16, 2024 · 3 comments
Open

cancelling PlayerInteractAtEntityEvent causes impossible entities #11496

miniking1000 opened this issue Oct 16, 2024 · 3 comments
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1

Comments

@miniking1000
Copy link

Expected behavior

To not get some wierd entities. To be precise I want nothing to happen with my "minecraft:interaction" so it will stay as it spawned, like this: Image

Observed/Actual behavior

It does this:
Image
In normal game its impossible to spawn this kind of interaction, and in my case it really matters as the eye line(or whatever this blue line is) is where passengers sit, and after this wierd rotation they go up.

Steps/models to reproduce

  1. setup server and any plugin that cancels the PlayerInteractAtEntityEvent , for example this plugin:
    package com.example.bug;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractAtEntityEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    public final class Bug extends JavaPlugin implements Listener {
    @OverRide
    public void onEnable() {
    getServer().getPluginManager().registerEvents(this, this);
    }
    @OverRide
    public void onDisable() {}
    @eventhandler
    public void onEvent(PlayerInteractAtEntityEvent event){event.setCancelled(true);}
    }
  2. interact with any "minecraft:interaction"
  3. done. now this entity is bugged.
    Intresting fact:
    If you reload chunks in which entity is, it will go back to normal, I couldn't find other way to fix this bug.

Plugin and Datapack List

only one plugin, which code is above, no datapacks

Paper version

version
[15:55:18 INFO]: Checking version, please wait...
[15:55:18 INFO]: This server is running Paper version 1.21.1-122-master@4430e96 (2024-10-12T21:18:42Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.1-2324-e12a4de (MC: 1.21.1)

Other

I'm not sure that cancelling event is what causes the bug, as in another plugin I do not cancel event, but it still happening, but cancelling is one way of doing it, so If you will fix it, then my original bug will probably go away anyway. I also checked it on spigot and it worked as intended and no entity was rotated (at least in my 5 minute check)

@miniking1000 miniking1000 added status: needs triage type: bug Something doesn't work as it was intended to. labels Oct 16, 2024
@lynxplay lynxplay added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Oct 16, 2024
@lynxplay
Copy link
Contributor

This is kind of just a very funny minecraft bug that is exposed by us resending all entity data to correctly sync entities.

TDLR is that the "correct" state you are describing is completely incorrect.
The eye height being 0 on the client is only the case because the pose data is never sent by the server as the default is never changed.
The interaction entities dimension is never recomputed on the client from its default of 0/0, even if the width and height are changed.

I think this is still a worthwhile fix/compliance with mojang logic (mostly because it should be easy) but be aware that the existing code does not actively define the eyeheight of interaction entities to be 0, hence you are relying on a bug.

@miniking1000
Copy link
Author

Is there a way to set eyeheight to 0/0? Or can I manually send client data on how to display it? I don't really care too much where the eyeheight will be. All I really need is to make it consistent after spawning and after clicking it, is there something that might help?

@lynxplay
Copy link
Contributor

The client computes the eyeheight as 85% of the height when it refreshes its dimension.
So no, you'd have to resend the entity data with a height/width of 0 and re-resend the correct width/height afterwards.

Alternatively, a quick hack fix might be

diff --git a/patches/server/1013-Properly-resend-entities.patch b/patches/server/1013-Properly-resend-entities.patch
index 148750ed5..671b436cb 100644
--- a/patches/server/1013-Properly-resend-entities.patch
+++ b/patches/server/1013-Properly-resend-entities.patch
@@ -102,7 +102,7 @@ index 0034483685ba626e5883b857de96ffd36e57e150..4c04eb531b6989f7e618d201ecaa8429
                              }
  
 diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
-index 3a90dd1289d393426151d4457edaf99731cc34db..ec058eb6a10500831f173dcb47576c32c7516318 100644
+index 65f2cad4b5df6a89373fb69edfc7d488d0fdcbed..613e66e1abb2cddb9f39f8ac255b1eb493915beb 100644
 --- a/src/main/java/net/minecraft/server/players/PlayerList.java
 +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
 @@ -393,7 +393,7 @@ public abstract class PlayerList {
@@ -134,7 +134,7 @@ index 3a90dd1289d393426151d4457edaf99731cc34db..ec058eb6a10500831f173dcb47576c32
  
      }
 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
-index 52f3d0d4ce28cc6566166ae9a5a1b236ff8c027d..74231cb1c89079473d1727aa3ae2a539d4250317 100644
+index b83599c873aad58c23d96f20f93ed171a73de6c4..08644404bb1d64328e03fb713094b20360be4b13 100644
 --- a/src/main/java/net/minecraft/world/entity/Entity.java
 +++ b/src/main/java/net/minecraft/world/entity/Entity.java
 @@ -684,13 +684,45 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -142,7 +142,7 @@ index 52f3d0d4ce28cc6566166ae9a5a1b236ff8c027d..74231cb1c89079473d1727aa3ae2a539
      // CraftBukkit start
      public void refreshEntityData(ServerPlayer to) {
 -        List<SynchedEntityData.DataValue<?>> list = this.getEntityData().getNonDefaultValues();
-+        List<SynchedEntityData.DataValue<?>> list = this.entityData.packAll(); // Paper - Update EVERYTHING not just not default
++        List<SynchedEntityData.DataValue<?>> list = this.type == EntityType.INTERACTION ? getEntityData().getNonDefaultValues() : this.entityData.packAll(); // Paper - Update EVERYTHING not just not default
  
 -        if (list != null) {
 +        if (list != null && to.getBukkitEntity().canSee(this.getBukkitEntity())) { // Paper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1
Projects
Status: ✅ Accepted
Development

No branches or pull requests

2 participants