Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
ec9fa36908
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: 149527f7 SPIGOT-5782: Set Arrow Launched From Crossbow CraftBukkit Changes:be6aaf04
SPIGOT-5782: Set Arrow Launched From Crossbow833da9c4
SPIGOT-5799: InventoryCloseEvent fires after PlayerQuitEvent26c0084f
SPIGOT-5675, SPIGOT-5798, MC-149563: Fix tracking of entities across dimensions7f3e7c3f
SPIGOT-5797: Zombie(Villagers) Instant Convert based on their lifetime
68 Zeilen
4.3 KiB
Diff
68 Zeilen
4.3 KiB
Diff
From 0000000000000000000000000000000000000000 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 0c3a776e207d84943fd90482a650d0c74b5ca65d..516631b4f4b8d7a9dd5d9d558d199f71d0d7ced6 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -3258,6 +3258,23 @@ public abstract class EntityLiving extends Entity {
|
|
this.broadcastItemBreak(enumhand == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND);
|
|
}
|
|
// Paper start
|
|
+ public MovingObjectPosition getRayTrace(int maxDistance) {
|
|
+ return getRayTrace(maxDistance, RayTrace.FluidCollisionOption.NONE);
|
|
+ }
|
|
+
|
|
+ public MovingObjectPosition getRayTrace(int maxDistance, RayTrace.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());
|
|
+ RayTrace raytrace = new RayTrace(start, end, RayTrace.BlockCollisionOption.OUTLINE, fluidCollisionOption, this);
|
|
+
|
|
+ return world.rayTrace(raytrace);
|
|
+ }
|
|
+
|
|
public int shieldBlockingDelay = world.paperConfig.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 3a87c6574bbad9e6c2d7573eb447194c931d7ec4..9e082d4514eb57667cb50a390bef7ab72b94e838 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -196,6 +196,28 @@ 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) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
|
+ return !(rayTrace instanceof net.minecraft.server.MovingObjectPositionBlock) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().world, ((net.minecraft.server.MovingObjectPositionBlock)rayTrace).getBlockPosition());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ 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 instanceof net.minecraft.server.MovingObjectPositionBlock) ? null : net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.server.MovingObjectPositionBlock)rayTrace).getDirection());
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ 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 instanceof net.minecraft.server.MovingObjectPositionBlock) ? null :
|
|
+ new com.destroystokyo.paper.block.TargetBlockInfo(org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().world, ((net.minecraft.server.MovingObjectPositionBlock)rayTrace).getBlockPosition()),
|
|
+ net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.server.MovingObjectPositionBlock)rayTrace).getDirection()));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
|
return getLineOfSight(transparent, maxDistance, 2);
|