aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch')
-rw-r--r--patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch b/patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch
new file mode 100644
index 0000000000..7cb609e3e7
--- /dev/null
+++ b/patches/server/0243-Add-ray-tracing-methods-to-LivingEntity.patch
@@ -0,0 +1,68 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: BillyGalbreath <[email protected]>
+Date: Mon, 3 Sep 2018 18:20:03 -0500
+Subject: [PATCH] Add ray tracing methods to LivingEntity
+
+
+diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+index 2900326a87d21c8a92edb303ed42fd11ea7f3010..b9d202cb06672f0791792ac676761c404ffb02bc 100644
+--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
+@@ -3841,6 +3841,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
+ }
+
+ // Paper start - Make shield blocking delay configurable
++ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
++ if (maxDistance < 1 || maxDistance > 120) {
++ throw new IllegalArgumentException("maxDistance must be between 1-120");
++ }
++
++ Vec3 start = new Vec3(getX(), getY() + getEyeHeight(), getZ());
++ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
++ Vec3 end = new Vec3(start.x + dir.getX(), start.y + dir.getY(), start.z + dir.getZ());
++ ClipContext raytrace = new ClipContext(start, end, ClipContext.Block.OUTLINE, fluidCollisionOption, this);
++
++ return this.level().clip(raytrace);
++ }
++
+ public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay;
+
+ public int getShieldBlockingDelay() {
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+index 8ac3beab73904db7362caa3054994b214c997cf7..1510b4d8fc08f4455b38ad4edb6bdf91ad317c96 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+@@ -201,6 +201,33 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+ return blocks.get(0);
+ }
+
++ // Paper start
++ @Override
++ public Block getTargetBlock(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
++ return this.getTargetBlockExact(maxDistance, fluidMode.bukkit);
++ }
++
++ @Override
++ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
++ return this.getTargetBlockFace(maxDistance, fluidMode.bukkit);
++ }
++
++ @Override
++ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, org.bukkit.FluidCollisionMode fluidMode) {
++ RayTraceResult result = this.rayTraceBlocks(maxDistance, fluidMode);
++ return result != null ? result.getHitBlockFace() : null;
++ }
++
++ @Override
++ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
++ RayTraceResult result = this.rayTraceBlocks(maxDistance, fluidMode.bukkit);
++ if (result != null && result.getHitBlock() != null && result.getHitBlockFace() != null) {
++ return new com.destroystokyo.paper.block.TargetBlockInfo(result.getHitBlock(), result.getHitBlockFace());
++ }
++ return null;
++ }
++ // Paper end
++
+ @Override
+ public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
+ return this.getLineOfSight(transparent, maxDistance, 2);