mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 07:39:16 +01:00
e1c0033552
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: 2b4b6d14 PR-1023: Convert InventoryView to interface CraftBukkit Changes: 68603b1c1 Use expanded interaction ranges for traced interact events eae9f760c PR-1414: Convert InventoryView to interface ee9eafe67 Fix Implementation for DamageSource#isIndirect for internal custom causing entity
48 lines
4.2 KiB
Diff
48 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: TheMolkaPL <themolkapl@gmail.com>
|
|
Date: Sun, 21 Jun 2020 17:21:46 +0200
|
|
Subject: [PATCH] Fix interact event not being called sometimes
|
|
|
|
* Call PlayerInteractEvent when left-clicking on a block in adventure
|
|
mode.
|
|
* Call PlayerInteractEvent when left-clicking an Entity that is out of
|
|
range in adventure/survival (entity reach is 3.0).
|
|
|
|
Co-authored-by: Moulberry <james.jenour@protonmail.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index a0bac2fe6222964b098cfaf9470f09c43328fcf5..09e40d6e50b7c1ddd1451981d05ecbbef43cfed2 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1771,7 +1771,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED);
|
|
|
|
this.player.sendSystemMessage(ichatmutablecomponent, true);
|
|
- } else if (enuminteractionresult.shouldSwing()) {
|
|
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper - Call interact event
|
|
this.player.swing(enumhand, true);
|
|
}
|
|
}
|
|
@@ -2392,13 +2392,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
double d3 = Math.max(this.player.blockInteractionRange(), this.player.entityInteractionRange());
|
|
// SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time
|
|
// SPIGOT-7429: Make sure to call PlayerInteractEvent for spectators and non-pickable entities
|
|
- org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.1, entity -> {
|
|
+ org.bukkit.util.RayTraceResult result = this.player.level().getWorld().rayTrace(origin, origin.getDirection(), d3, org.bukkit.FluidCollisionMode.NEVER, false, 0.0, entity -> { // Paper - Call interact event; change raySize from 0.1 to 0.0
|
|
Entity handle = ((CraftEntity) entity).getHandle();
|
|
return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player);
|
|
});
|
|
if (result == null) {
|
|
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
|
- }
|
|
+ } else { // Paper start - Call interact event
|
|
+ GameType gameType = this.player.gameMode.getGameModeForPlayer();
|
|
+ if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) {
|
|
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
|
+ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) {
|
|
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
|
+ }
|
|
+ } // Paper end - Call interact event
|
|
|
|
// Arm swing animation
|
|
PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packet.getHand() == InteractionHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
|