mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
b62dfa0bf9
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: 39ce5d3a SPIGOT-4399: ItemMeta.equals broken with AttributeModifiers CraftBukkit Changes:1cf8b5dc
SPIGOT-4400: Populators running on existing chunks116cb9a1
SPIGOT-4399: Add attribute modifier equality test5ee1c18a
SPIGOT-4398: Set ASM7_EXPERIMENTAL flag
77 lines
4.0 KiB
Diff
77 lines
4.0 KiB
Diff
From 49bb1bff3fa47cdfc21ea8969f09a81547fb163f Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
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/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index c051200da8..1328f88898 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2813,6 +2813,22 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
// Paper start
|
|
+ public MovingObjectPosition getRayTrace(int maxDistance) {
|
|
+ return getRayTrace(maxDistance, FluidCollisionOption.NEVER);
|
|
+ }
|
|
+
|
|
+ public MovingObjectPosition getRayTrace(int maxDistance, FluidCollisionOption fluidCollisionOption) {
|
|
+ if (maxDistance < 1 || maxDistance > 120) {
|
|
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
|
+ }
|
|
+
|
|
+ Vec3D start = new Vec3D(locX, locY + getHeadHeight(), locZ);
|
|
+ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
|
|
+ Vec3D end = new Vec3D(start.x + dir.getX(), start.y + dir.getY(), start.z + dir.getZ());
|
|
+
|
|
+ return world.rayTrace(start, end, fluidCollisionOption);
|
|
+ }
|
|
+
|
|
public int shieldBlockingDelay = world.paperConfig.shieldBlockingDelay;
|
|
|
|
public int getShieldBlockingDelay() {
|
|
diff --git a/src/main/java/net/minecraft/server/MovingObjectPosition.java b/src/main/java/net/minecraft/server/MovingObjectPosition.java
|
|
index 6d5dbe89a6..a31f9f6072 100644
|
|
--- a/src/main/java/net/minecraft/server/MovingObjectPosition.java
|
|
+++ b/src/main/java/net/minecraft/server/MovingObjectPosition.java
|
|
@@ -28,6 +28,7 @@ public class MovingObjectPosition {
|
|
this.pos = vec3d;
|
|
}
|
|
|
|
+ public BlockPosition getBlockPosition() { return a(); } // Paper - OBFHELPER
|
|
public BlockPosition a() {
|
|
return this.e;
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
index 0860f2334d..028495700f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -169,6 +169,23 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
return blocks.get(0);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public Block getTargetBlock(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
|
+ return rayTrace == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().world, rayTrace.getBlockPosition());
|
|
+ }
|
|
+
|
|
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
|
+ return rayTrace == null ? null : net.minecraft.server.MCUtil.toBukkitBlockFace(rayTrace.direction);
|
|
+ }
|
|
+
|
|
+ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
|
+ return rayTrace == null ? null : new com.destroystokyo.paper.block.TargetBlockInfo(org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().world, rayTrace.getBlockPosition()), net.minecraft.server.MCUtil.toBukkitBlockFace(rayTrace.direction));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
|
return getLineOfSight(transparent, maxDistance, 2);
|
|
}
|
|
--
|
|
2.19.0
|
|
|