Deprecate TargetBlock/EntityInfo and assocated methods (#7381)

This commit is contained in:
Jake Potrebic 2022-12-15 09:10:03 -08:00 committed by GitHub
parent 3aec8630bb
commit 0262de0ddb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 158 additions and 110 deletions

View file

@ -6,19 +6,22 @@ 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
index 0000000000000000000000000000000000000000..c896d172519a8552a132031cb956378db272878f
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/block/TargetBlockInfo.java
@@ -0,0 +1,54 @@
@@ -0,0 +1,67 @@
+package com.destroystokyo.paper.block;
+
+import org.bukkit.FluidCollisionMode;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Represents information about a targeted block
+ * @deprecated use {@link org.bukkit.util.RayTraceResult}
+ */
+@Deprecated(forRemoval = true)
+public class TargetBlockInfo {
+ private final Block block;
+ private final BlockFace blockFace;
@ -58,17 +61,27 @@ index 0000000000000000000000000000000000000000..18a96dbb01d3b34476652264b2d6be37
+ return block.getRelative(blockFace);
+ }
+
+ /**
+ * @deprecated use {@link org.bukkit.FluidCollisionMode}
+ */
+ @Deprecated(forRemoval = true)
+ public enum FluidMode {
+ NEVER,
+ SOURCE_ONLY,
+ ALWAYS
+ NEVER(FluidCollisionMode.NEVER),
+ SOURCE_ONLY(FluidCollisionMode.SOURCE_ONLY),
+ ALWAYS(FluidCollisionMode.ALWAYS);
+
+ public final FluidCollisionMode bukkit;
+
+ FluidMode(FluidCollisionMode bukkit) {
+ this.bukkit = bukkit;
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a4f092a6d 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -83,6 +83,77 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -83,6 +83,98 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@NotNull
public Block getTargetBlock(@Nullable Set<Material> transparent, int maxDistance);
@ -79,7 +92,9 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ * @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
+ * @deprecated use {@link #getTargetBlockExact(int)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public default Block getTargetBlock(int maxDistance) {
+ return getTargetBlock(maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
@ -92,7 +107,9 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ * @param fluidMode whether to check fluids or not
+ * @return block that the living entity has targeted,
+ * or null if no block is within maxDistance
+ * @deprecated use {@link #getTargetBlockExact(int, FluidCollisionMode)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public Block getTargetBlock(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+
@ -105,7 +122,7 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ */
+ @Nullable
+ public default org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance) {
+ return getTargetBlockFace(maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
+ return getTargetBlockFace(maxDistance, org.bukkit.FluidCollisionMode.NEVER);
+ }
+
+ /**
@ -115,9 +132,22 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ * @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
+ * @deprecated use {@link #getTargetBlockFace(int, FluidCollisionMode)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+
+ /**
+ * 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);
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, @NotNull FluidCollisionMode fluidMode);
+
+ /**
+ * Gets information about the block the living entity has targeted, ignoring fluids
@ -125,7 +155,9 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ * @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
+ * @deprecated use {@link #rayTraceBlocks(double)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public default com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance) {
+ return getTargetBlockInfo(maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode.NEVER);
@ -138,7 +170,9 @@ index c80e75b72ac863db19e3d234e349876dd8797924..c29846df0469535870e1743eee25325a
+ * @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
+ * @deprecated use {@link #rayTraceBlocks(double, FluidCollisionMode)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+ // Paper end

View file

@ -6,10 +6,10 @@ Subject: [PATCH] Add LivingEntity#getTargetEntity
diff --git a/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java b/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..f52644fab1522bdf83ff4f489e9805b274421094
index 0000000000000000000000000000000000000000..af8765b213390cf75fe02a6eb68aecf7a06d5acf
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/TargetEntityInfo.java
@@ -0,0 +1,38 @@
@@ -0,0 +1,40 @@
+package com.destroystokyo.paper.entity;
+
+import org.bukkit.entity.Entity;
@ -18,7 +18,9 @@ index 0000000000000000000000000000000000000000..f52644fab1522bdf83ff4f489e9805b2
+
+/**
+ * Represents information about a targeted entity
+ * @deprecated use {@link org.bukkit.util.RayTraceResult}
+ */
+@Deprecated(forRemoval = true)
+public class TargetEntityInfo {
+ private final Entity entity;
+ private final Vector hitVec;
@ -49,11 +51,11 @@ index 0000000000000000000000000000000000000000..f52644fab1522bdf83ff4f489e9805b2
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index c29846df0469535870e1743eee25325a4f092a6d..63b39fe0f2c8c529e289c69969588a98dd7fc758 100644
index 70c0512a5875533c9b8ce7a1b21cc799772c5ef4..98484c748db12dbdcdbe456befa30ad87864420b 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -152,6 +152,50 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
@@ -173,6 +173,77 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@Deprecated(forRemoval = true)
@Nullable
public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, @NotNull com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode);
+
@ -84,7 +86,9 @@ index c29846df0469535870e1743eee25325a4f092a6d..63b39fe0f2c8c529e289c69969588a98
+ * @param maxDistance this is the maximum distance to scan
+ * @return TargetEntityInfo about the entity being targeted,
+ * or null if no entity is targeted
+ * @deprecated use {@link #rayTraceEntities(int)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public default com.destroystokyo.paper.entity.TargetEntityInfo getTargetEntityInfo(int maxDistance) {
+ return getTargetEntityInfo(maxDistance, false);
@ -94,12 +98,37 @@ index c29846df0469535870e1743eee25325a4f092a6d..63b39fe0f2c8c529e289c69969588a98
+ * Gets information about the entity being targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param ignoreBlocks true to scan through blocks
+ * @return TargetEntityInfo about the entity being targeted,
+ * @return RayTraceResult about the entity being targeted,
+ * or null if no entity is targeted
+ */
+ @Nullable
+ default RayTraceResult rayTraceEntities(int maxDistance) {
+ return this.rayTraceEntities(maxDistance, false);
+ }
+
+ /**
+ * Gets information about the entity being targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param ignoreBlocks true to scan through blocks
+ * @return TargetEntityInfo about the entity being targeted,
+ * or null if no entity is targeted
+ * @deprecated use {@link #rayTraceEntities(int, boolean)}
+ */
+ @Deprecated(forRemoval = true)
+ @Nullable
+ public com.destroystokyo.paper.entity.TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks);
+
+ /**
+ * Gets information about the entity being targeted
+ *
+ * @param maxDistance this is the maximum distance to scan
+ * @param ignoreBlocks true to scan through blocks
+ * @return RayTraceResult about the entity being targeted,
+ * or null if no entity is targeted
+ */
+ @Nullable
+ RayTraceResult rayTraceEntities(int maxDistance, boolean ignoreBlocks);
// Paper end
/**

View file

@ -57,10 +57,10 @@ index 0000000000000000000000000000000000000000..f0067c2e953d18e1a33536980071ba3f
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 63b39fe0f2c8c529e289c69969588a98dd7fc758..54046c5810f9f6f3f28e815a210617683139509d 100644
index 98484c748db12dbdcdbe456befa30ad87864420b..3618a138a602fde4d3f045e9982dd95c0376b30d 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -878,5 +878,25 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -926,5 +926,25 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
@NotNull
org.bukkit.inventory.EquipmentSlot getHandRaised();

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add playPickupItemAnimation to LivingEntity
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 54046c5810f9f6f3f28e815a210617683139509d..2c559c590b96753aa5dc2db2bacca32d8afad352 100644
index 3618a138a602fde4d3f045e9982dd95c0376b30d..4b2bbeebe724682a53850f92872169d7cfbeb552 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -898,5 +898,28 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -946,5 +946,28 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param jumping entity jump state
*/
void setJumping(boolean jumping);

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add LivingEntity#clearActiveItem
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 2c559c590b96753aa5dc2db2bacca32d8afad352..8375cbdb79e82afebbcc18f85e874238f18cda50 100644
index 4b2bbeebe724682a53850f92872169d7cfbeb552..f52c7d2ac653dde284de8d83ebe034afa2cde90a 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -849,6 +849,13 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -897,6 +897,13 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@NotNull
org.bukkit.inventory.ItemStack getActiveItem();

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Expose LivingEntity hurt direction
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 8375cbdb79e82afebbcc18f85e874238f18cda50..a6c0b5e55adadd78619d251d979e9e46068a637e 100644
index f52c7d2ac653dde284de8d83ebe034afa2cde90a..f44f510b3194c9716ec59caa195f83dde2b2773a 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -928,5 +928,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -976,5 +976,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param quantity quantity of item
*/
void playPickupItemAnimation(@NotNull Item item, int quantity);

View file

@ -23,10 +23,10 @@ index aa534b1a9a1fb84a2fbd4b372f313bb4b63325fa..43b53c21af01e0f496c8aaacff82dfdf
// Paper end
}
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index a6c0b5e55adadd78619d251d979e9e46068a637e..d47706a915ae1bfaa3187a83cb6d35ea202c03d0 100644
index f44f510b3194c9716ec59caa195f83dde2b2773a..21ca1df6b484390a644d1f0894ebcac0080ff570 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -484,6 +484,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -532,6 +532,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
public boolean hasLineOfSight(@NotNull Entity other);

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Stinger API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index d47706a915ae1bfaa3187a83cb6d35ea202c03d0..4af5e8d0cba6555f7615e4e809d9aff221c0dc4d 100644
index 21ca1df6b484390a644d1f0894ebcac0080ff570..6f7483a86b713b7b85e595f55b167e1547bc4b8e 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -337,6 +337,36 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -385,6 +385,36 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
public void setArrowsInBody(int count);

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add LivingEntity#swingHand(EquipmentSlot) convenience method
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 4af5e8d0cba6555f7615e4e809d9aff221c0dc4d..435e214af7f09b3f1da078e6517cd14bb5ad2b87 100644
index 6f7483a86b713b7b85e595f55b167e1547bc4b8e..475fdef28596cf8454da58d04d4c4153719a4a68 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -985,5 +985,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -1033,5 +1033,23 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param hurtDirection hurt direction
*/
void setHurtDirection(float hurtDirection);

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add entity knockback API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 435e214af7f09b3f1da078e6517cd14bb5ad2b87..3bd1d100d0c481ae7edaa251869640ab370aeb42 100644
index 475fdef28596cf8454da58d04d4c4153719a4a68..1999cd1b1aaa23589da4e11cf80139b8e7a2a539 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1003,5 +1003,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -1051,5 +1051,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
this.swingOffHand();
}
}

View file

@ -8,10 +8,10 @@ to simulate damage done to an itemstack and all
the logic associated with damaging them
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 3bd1d100d0c481ae7edaa251869640ab370aeb42..f6cbada38ca48638e5ad0bd99d0b6ea65f6b02de 100644
index 1999cd1b1aaa23589da4e11cf80139b8e7a2a539..c27aaec51ae4de593da4443e1e8a773e1b59aafa 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1015,5 +1015,48 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
@@ -1063,5 +1063,48 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
* @param directionZ The relative z position of the knockback source direction
*/
void knockback(double strength, double directionX, double directionZ);