Paper/patches/api/0140-Add-ray-tracing-methods-to-LivingEntity.patch

183 lines
6.9 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Mon, 3 Sep 2018 18:13:53 -0500
Subject: [PATCH] Add ray tracing methods to LivingEntity
diff --git a/src/main/java/com/destroystokyo/paper/block/TargetBlockInfo.java b/src/main/java/com/destroystokyo/paper/block/TargetBlockInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..bb12061985cdffbacfa2d113beaa35b2c92df567
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/block/TargetBlockInfo.java
@@ -0,0 +1,67 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.block;
+
+import org.bukkit.FluidCollisionMode;
2021-06-11 14:02:28 +02:00
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Represents information about a targeted block
+ * @deprecated use {@link org.bukkit.util.RayTraceResult}
2021-06-11 14:02:28 +02:00
+ */
+@Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+public class TargetBlockInfo {
+ private final Block block;
+ private final BlockFace blockFace;
+
+ public TargetBlockInfo(@NotNull Block block, @NotNull BlockFace blockFace) {
+ this.block = block;
+ this.blockFace = blockFace;
+ }
+
+ /**
+ * Get the block that is targeted
+ *
+ * @return Targeted block
+ */
+ @NotNull
+ public Block getBlock() {
+ return block;
+ }
+
+ /**
+ * Get the targeted BlockFace
+ *
+ * @return Targeted blockface
+ */
+ @NotNull
+ public BlockFace getBlockFace() {
+ return blockFace;
+ }
+
+ /**
+ * Get the relative Block to the targeted block on the side it is targeted at
+ *
+ * @return Block relative to targeted block
+ */
+ @NotNull
+ public Block getRelativeBlock() {
+ return block.getRelative(blockFace);
+ }
+
+ /**
+ * @deprecated use {@link org.bukkit.FluidCollisionMode}
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ public enum FluidMode {
+ NEVER(FluidCollisionMode.NEVER),
+ SOURCE_ONLY(FluidCollisionMode.SOURCE_ONLY),
+ ALWAYS(FluidCollisionMode.ALWAYS);
+
+ public final FluidCollisionMode bukkit;
+
+ FluidMode(FluidCollisionMode bukkit) {
+ this.bukkit = bukkit;
+ }
2021-06-11 14:02:28 +02:00
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
2024-10-22 18:23:19 +02:00
index 434ad8b07b6ee0b0919de8044d14fe3c789e203f..09b0dd1b14e2848253c1d3bfecb98951764737ee 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
2023-12-25 23:51:56 +01:00
@@ -85,6 +85,98 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
2021-06-11 14:02:28 +02:00
@NotNull
public Block getTargetBlock(@Nullable Set<Material> transparent, int maxDistance);
+ // Paper start
+ /**
+ * Gets the block that the living entity has targeted, ignoring fluids
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @return block that the living entity has targeted,
+ * or null if no block is within maxDistance
+ * @deprecated use {@link #getTargetBlockExact(int)}
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ @Nullable
+ public default Block getTargetBlock(int maxDistance) {
+ return getTargetBlock(maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
+ }
+
+ /**
+ * Gets the block that the living entity has targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param fluidMode whether to check fluids or not
+ * @return block that the living entity has targeted,
+ * or null if no block is within maxDistance
+ * @deprecated use {@link #getTargetBlockExact(int, FluidCollisionMode)}
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ @Nullable
+ public Block getTargetBlock(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+
+ /**
+ * Gets the blockface of that block that the living entity has targeted, ignoring fluids
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @return blockface of the block that the living entity has targeted,
+ * or null if no block is targeted
+ */
+ @Nullable
+ public default org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance) {
+ return getTargetBlockFace(maxDistance, org.bukkit.FluidCollisionMode.NEVER);
2021-06-11 14:02:28 +02:00
+ }
+
+ /**
+ * Gets the blockface of that block that the living entity has targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param fluidMode whether to check fluids or not
+ * @return blockface of the block that the living entity has targeted,
+ * or null if no block is targeted
+ * @deprecated use {@link #getTargetBlockFace(int, FluidCollisionMode)}
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ @Nullable
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+
+ /**
+ * Gets the blockface of that block that the living entity has targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param fluidMode whether to check fluids or not
+ * @return blockface of the block that the living entity has targeted,
+ * or null if no block is targeted
+ */
+ @Nullable
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, @NotNull FluidCollisionMode fluidMode);
+
+ /**
2021-06-11 14:02:28 +02:00
+ * Gets information about the block the living entity has targeted, ignoring fluids
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @return TargetBlockInfo about the block the living entity has targeted,
+ * or null if no block is targeted
+ * @deprecated use {@link #rayTraceBlocks(double)}
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ @Nullable
+ public default com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance) {
+ return getTargetBlockInfo(maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
+ }
+
+ /**
+ * Gets information about the block the living entity has targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param fluidMode whether to check fluids or not
+ * @return TargetBlockInfo about the block the living entity has targeted,
+ * or null if no block is targeted
+ * @deprecated use {@link #rayTraceBlocks(double, FluidCollisionMode)}
2021-06-11 14:02:28 +02:00
+ */
+ @Deprecated(forRemoval = true, since = "1.19.3")
2021-06-11 14:02:28 +02:00
+ @Nullable
+ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+ // Paper end
+
/**
* Gets the last two blocks along the living entity's line of sight.
* <p>