2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
Date: Sat, 2 Apr 2016 05:09:16 -0400
|
|
|
|
Subject: [PATCH] Add PlayerUseUnknownEntityEvent
|
|
|
|
|
2023-08-16 09:58:07 +02:00
|
|
|
Adds the PlayerUseUnknownEntityEvent to be used by plugins dealing with
|
|
|
|
virtual entities/entities that are not actually known to the server.
|
|
|
|
|
|
|
|
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
2023-09-22 19:59:56 +02:00
|
|
|
index 644a0fdea6576647539b96528717dbaeab498d93..221e64a66ff12a8de5c75992fc26a54a03b317e7 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
2023-08-16 09:58:07 +02:00
|
|
|
@@ -169,4 +169,14 @@ public class ServerboundInteractPacket implements Packet<ServerGamePacketListene
|
|
|
|
buf.writeEnum(this.hand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start - PlayerUseUnknownEntityEvent
|
|
|
|
+ public int getEntityId() {
|
|
|
|
+ return this.entityId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean isAttack() {
|
|
|
|
+ return this.action.getType() == ActionType.ATTACK;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - PlayerUseUnknownEntityEvent
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-02-22 17:23:15 +01:00
|
|
|
index 37cba1e693490e42908f45dc68e60ac3afebbb49..801e1727bd291f647c91e2c325810ead070f3752 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
2024-02-22 17:23:15 +01:00
|
|
|
@@ -2404,7 +2404,26 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
2021-06-12 05:37:02 +02:00
|
|
|
});
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-16 09:58:07 +02:00
|
|
|
+ // Paper start - PlayerUseUnknownEntityEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
+ else {
|
2021-06-12 05:37:02 +02:00
|
|
|
+ packet.dispatch(new net.minecraft.network.protocol.game.ServerboundInteractPacket.Handler() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onInteraction(net.minecraft.world.InteractionHand hand) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, hand, null);
|
2021-06-12 05:37:02 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onInteraction(net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos) {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, hand, pos);
|
2021-06-12 05:37:02 +02:00
|
|
|
+ }
|
2024-02-01 10:15:57 +01:00
|
|
|
|
2021-06-12 05:37:02 +02:00
|
|
|
+ @Override
|
|
|
|
+ public void onAttack() {
|
2024-02-01 10:15:57 +01:00
|
|
|
+ CraftEventFactory.callPlayerUseUnknownEntityEvent(ServerGamePacketListenerImpl.this.player, packet, net.minecraft.world.InteractionHand.MAIN_HAND, null);
|
2021-06-12 05:37:02 +02:00
|
|
|
+ }
|
|
|
|
+ });
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2024-02-01 10:15:57 +01:00
|
|
|
+ // Paper end - PlayerUseUnknownEntityEvent
|
2023-03-23 22:57:03 +01:00
|
|
|
}
|
|
|
|
|
2021-06-12 05:37:02 +02:00
|
|
|
@Override
|
2024-02-01 10:15:57 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index 6571adf5285ab3f84513c2f5b32ff0523c2cccd6..c8f20543cb7f69af010e3fd53f31b7253426f2d0 100644
|
2024-02-01 10:15:57 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -1850,4 +1850,13 @@ public class CraftEventFactory {
|
|
|
|
|
|
|
|
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
|
2024-02-01 10:15:57 +01:00
|
|
|
}
|
|
|
|
+ // Paper start - PlayerUseUnknownEntityEvent
|
|
|
|
+ public static void callPlayerUseUnknownEntityEvent(net.minecraft.world.entity.player.Player player, net.minecraft.network.protocol.game.ServerboundInteractPacket packet, InteractionHand hand, @Nullable net.minecraft.world.phys.Vec3 vector) {
|
|
|
|
+ new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
|
|
|
+ (Player) player.getBukkitEntity(), packet.getEntityId(), packet.isAttack(),
|
|
|
|
+ CraftEquipmentSlot.getHand(hand),
|
|
|
|
+ vector != null ? CraftVector.toBukkit(vector) : null
|
|
|
|
+ ).callEvent();
|
|
|
|
+ }
|
|
|
|
+ // Paper end - PlayerUseUnknownEntityEvent
|
|
|
|
}
|