mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
b68b282439
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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes:c4a67eed
SPIGOT-4556: Fix plugins closing inventory during drop events5be2ddcb
Replace version constants with methods to prevent compiler inlininga5b9c7b3
Use API method to create offset command completions2bc7d1df
SPIGOT-3747: Add API for force loaded chunksa408f375
SPIGOT-3538: Add getHitBlockFace for ProjectileHitEventb54b9409
SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock79ded7a8
SPIGOT-1811: Death message not shown on respawn screenb4a4f15d
SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory0afed592
SPIGOT-794: Call EntityPlaceEvent for Minecart placement2b2d084a
Add InventoryView#getSlotType01a9959a
Do not use deprecated ItemSpawnEvent constructor9642498d
SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event963f4a5f
Add PlayerItemDamageEvent63db0445
Add API to get / set base arrow damage531c25d7
Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS pluginsd05c8b14
Mappings Updatebd36e200
SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
184 lines
8.7 KiB
Diff
184 lines
8.7 KiB
Diff
From 22d4b81ba25bdc12d01a51f36099eb14376de6ae Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sat, 22 Sep 2018 00:33:08 -0500
|
|
Subject: [PATCH] Add LivingEntity#getTargetEntity
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/AxisAlignedBB.java b/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
index c5e541985..d6a5c7407 100644
|
|
--- a/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
+++ b/src/main/java/net/minecraft/server/AxisAlignedBB.java
|
|
@@ -95,6 +95,7 @@ public class AxisAlignedBB {
|
|
return new AxisAlignedBB(d3, d4, d5, d6, d7, d8);
|
|
}
|
|
|
|
+ public AxisAlignedBB expand(double x, double y, double z) { return b(x, y, z); } // Paper - OBFHELPER
|
|
public AxisAlignedBB b(double d0, double d1, double d2) {
|
|
double d3 = this.minX;
|
|
double d4 = this.minY;
|
|
@@ -124,6 +125,12 @@ public class AxisAlignedBB {
|
|
return new AxisAlignedBB(d3, d4, d5, d6, d7, d8);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public AxisAlignedBB grow(double d0) {
|
|
+ return grow(d0, d0, d0);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public AxisAlignedBB grow(double d0, double d1, double d2) {
|
|
double d3 = this.minX - d0;
|
|
double d4 = this.minY - d1;
|
|
@@ -181,6 +188,7 @@ public class AxisAlignedBB {
|
|
return this.minX < d3 && this.maxX > d0 && this.minY < d4 && this.maxY > d1 && this.minZ < d5 && this.maxZ > d2;
|
|
}
|
|
|
|
+ public boolean contains(Vec3D vec3d) { return b(vec3d); } // Paper - OBFHELPER
|
|
public boolean b(Vec3D vec3d) {
|
|
return this.e(vec3d.x, vec3d.y, vec3d.z);
|
|
}
|
|
@@ -205,6 +213,7 @@ public class AxisAlignedBB {
|
|
return this.g(-d0);
|
|
}
|
|
|
|
+ public MovingObjectPosition calculateIntercept(Vec3D vec3d, Vec3D vec3d1) { return b(vec3d, vec3d1); } // Paper - OBFHELPER
|
|
@Nullable
|
|
public MovingObjectPosition b(Vec3D vec3d, Vec3D vec3d1) {
|
|
return this.a(vec3d, vec3d1, (BlockPosition) null);
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index f26056dd5..35715e434 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1517,6 +1517,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
return new Vec3D((double) (f5 * f6), (double) (-f7), (double) (f4 * f6));
|
|
}
|
|
|
|
+ public Vec3D getEyePosition(float partialTicks) { return i(partialTicks); } // Paper - OBFHELPER
|
|
public Vec3D i(float f) {
|
|
if (f == 1.0F) {
|
|
return new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
|
|
@@ -2180,10 +2181,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
return this.bP().size() < 1;
|
|
}
|
|
|
|
+ public float getCollisionBorderSize() { return aM(); } // Paper - OBFHELPER
|
|
public float aM() {
|
|
return 0.0F;
|
|
}
|
|
|
|
+ public Vec3D getLookVec() { return aN(); } // Paper - OBFHELPER
|
|
public Vec3D aN() {
|
|
return this.d(this.pitch, this.yaw);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 60aaf0547..710ad8b17 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -3,6 +3,8 @@ package net.minecraft.server;
|
|
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
|
|
import com.google.common.base.Objects;
|
|
import com.google.common.collect.Maps;
|
|
+
|
|
+import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.ConcurrentModificationException;
|
|
import java.util.Iterator;
|
|
@@ -16,6 +18,8 @@ import org.apache.logging.log4j.Logger;
|
|
|
|
// CraftBukkit start
|
|
import java.util.ArrayList;
|
|
+import java.util.stream.Collectors;
|
|
+
|
|
import com.google.common.base.Function;
|
|
import com.google.common.collect.Lists;
|
|
import org.bukkit.Location;
|
|
@@ -2862,6 +2866,36 @@ public abstract class EntityLiving extends Entity {
|
|
return world.rayTrace(start, end, fluidCollisionOption);
|
|
}
|
|
|
|
+ public MovingObjectPosition getTargetEntity(int maxDistance) {
|
|
+ if (maxDistance < 1 || maxDistance > 120) {
|
|
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
|
+ }
|
|
+
|
|
+ Vec3D start = getEyePosition(1.0F);
|
|
+ Vec3D direction = getLookVec();
|
|
+ Vec3D end = start.add(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance);
|
|
+
|
|
+ List<Entity> entityList = world.getEntities(this, getBoundingBox().expand(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance).grow(1.0D, 1.0D, 1.0D), IEntitySelector.notSpectator().and(Entity::isInteractable));
|
|
+
|
|
+ double distance = 0.0D;
|
|
+ MovingObjectPosition rayTraceResult = null;
|
|
+
|
|
+ for (Entity entity : entityList) {
|
|
+ AxisAlignedBB aabb = entity.getBoundingBox().grow((double) entity.getCollisionBorderSize());
|
|
+ MovingObjectPosition rayTrace = aabb.calculateIntercept(start, end);
|
|
+
|
|
+ if (rayTrace != null) {
|
|
+ double distanceTo = start.distanceSquared(rayTrace.pos);
|
|
+ if (distanceTo < distance || distance == 0.0D) {
|
|
+ rayTraceResult = new MovingObjectPosition(entity, rayTrace.pos);
|
|
+ distance = distanceTo;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return rayTraceResult;
|
|
+ }
|
|
+
|
|
public int shieldBlockingDelay = world.paperConfig.shieldBlockingDelay;
|
|
|
|
public int getShieldBlockingDelay() {
|
|
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
index f6916fd45..71f08d53c 100644
|
|
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
@@ -19,6 +19,7 @@ public final class IEntitySelector {
|
|
public static final Predicate<Entity> e = (entity) -> {
|
|
return !(entity instanceof EntityHuman) || !((EntityHuman) entity).isSpectator() && !((EntityHuman) entity).u();
|
|
};
|
|
+ public static Predicate<Entity> notSpectator() { return f; } // Paper - OBFHELPER
|
|
public static final Predicate<Entity> f = (entity) -> {
|
|
return !(entity instanceof EntityHuman) || !((EntityHuman) entity).isSpectator();
|
|
};
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
index eeab59379..d6a4bc64a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
|
@@ -186,6 +186,33 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|
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));
|
|
}
|
|
+
|
|
+ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = rayTraceEntity(maxDistance, ignoreBlocks);
|
|
+ return rayTrace == null ? null : rayTrace.entity.getBukkitEntity();
|
|
+ }
|
|
+
|
|
+ public com.destroystokyo.paper.entity.TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = rayTraceEntity(maxDistance, ignoreBlocks);
|
|
+ return rayTrace == null ? null : new com.destroystokyo.paper.entity.TargetEntityInfo(rayTrace.entity.getBukkitEntity(), new org.bukkit.util.Vector(rayTrace.pos.x, rayTrace.pos.y, rayTrace.pos.z));
|
|
+ }
|
|
+
|
|
+ public net.minecraft.server.MovingObjectPosition rayTraceEntity(int maxDistance, boolean ignoreBlocks) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTrace = getHandle().getTargetEntity(maxDistance);
|
|
+ if (rayTrace == null) {
|
|
+ return null;
|
|
+ }
|
|
+ if (!ignoreBlocks) {
|
|
+ net.minecraft.server.MovingObjectPosition rayTraceBlocks = getHandle().getRayTrace(maxDistance, net.minecraft.server.FluidCollisionOption.NEVER);
|
|
+ if (rayTraceBlocks != null) {
|
|
+ net.minecraft.server.Vec3D eye = getHandle().getEyePosition(1.0F);
|
|
+ if (eye.distanceSquared(rayTraceBlocks.pos) <= eye.distanceSquared(rayTrace.pos)) {
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return rayTrace;
|
|
+ }
|
|
// Paper end
|
|
|
|
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
|
|
--
|
|
2.20.1
|
|
|