mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
899bc53b79
Upstream has released updates that appears 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: f47abd88 SPIGOT-6242: Fix some file line endings de96535b SPIGOT-6234: enum classes don't serialize properly when implementing ConfigurationSerializable CraftBukkit Changes: 4475707d SPIGOT-6244: /spawnpoint ignores angle 8b3b096d SPIGOT-6242: Fix some file line endings 4b33c749 SPIGOT-6186: Canceling a CreatureSpawnEvent results in a "Unable to summon entity due to duplicate UUIDs" error 2b3ca726 SPIGOT-6236: Vehicle passenger portal cooldown does not change
149 lines
5.3 KiB
Diff
149 lines
5.3 KiB
Diff
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..18a96dbb01d3b34476652264b2d6be3782a154ec
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/block/TargetBlockInfo.java
|
|
@@ -0,0 +1,54 @@
|
|
+package com.destroystokyo.paper.block;
|
|
+
|
|
+import org.bukkit.block.Block;
|
|
+import org.bukkit.block.BlockFace;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+
|
|
+/**
|
|
+ * Represents information about a targeted block
|
|
+ */
|
|
+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);
|
|
+ }
|
|
+
|
|
+ public enum FluidMode {
|
|
+ NEVER,
|
|
+ SOURCE_ONLY,
|
|
+ ALWAYS
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
index 8b89c0701dd557bcab0c05c1593354ee704b9fe4..8fe7ccf12339355554835542cc1068d9f6c3a435 100644
|
|
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
@@ -82,6 +82,77 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
|
@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
|
|
+ */
|
|
+ @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
|
|
+ */
|
|
+ @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, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * 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 com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
+ */
|
|
+ @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
|
|
+ */
|
|
+ @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>
|