geforkt von Mirrors/Paper
87 Zeilen
3.2 KiB
Diff
87 Zeilen
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Thu, 4 Nov 2021 11:50:35 -0700
|
|
Subject: [PATCH] Add hasCollision methods to various places
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
|
index 1df815c2e430a308baea08c9a7f3ca43377dc16e..195bd298cfc2d43720550d5bf5a3347c064e9a7a 100644
|
|
--- a/src/main/java/org/bukkit/Material.java
|
|
+++ b/src/main/java/org/bukkit/Material.java
|
|
@@ -4788,6 +4788,21 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
|
}
|
|
// Paper end - item default attributes API
|
|
|
|
+ // Paper start - isCollidable API
|
|
+ /**
|
|
+ * Checks if this material is collidable.
|
|
+ *
|
|
+ * @return true if collidable
|
|
+ * @throws IllegalArgumentException if {@link #isBlock()} is false
|
|
+ */
|
|
+ public boolean isCollidable() {
|
|
+ if (this.isBlock()) {
|
|
+ return this.asBlockType().hasCollision();
|
|
+ }
|
|
+ throw new IllegalArgumentException(this + " isn't a block type");
|
|
+ }
|
|
+ // Paper end - isCollidable API
|
|
+
|
|
/**
|
|
* Do not use for any reason.
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
|
index b5fe76a6353816a2d009dfa5921f8ada92984f34..42cc4f2ee960c0abf9c6688aeee4150754612c32 100644
|
|
--- a/src/main/java/org/bukkit/block/Block.java
|
|
+++ b/src/main/java/org/bukkit/block/Block.java
|
|
@@ -482,6 +482,13 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr
|
|
* @return true if block is solid
|
|
*/
|
|
boolean isSolid();
|
|
+
|
|
+ /**
|
|
+ * Checks if this block is collidable.
|
|
+ *
|
|
+ * @return true if collidable
|
|
+ */
|
|
+ boolean isCollidable();
|
|
// Paper end
|
|
|
|
/**
|
|
diff --git a/src/main/java/org/bukkit/block/BlockState.java b/src/main/java/org/bukkit/block/BlockState.java
|
|
index fd4a9bdcfb6775dfbdb7492e6c9eb90722d2ecdc..e573e70d9e74e444783a7363e6cdac126124d86d 100644
|
|
--- a/src/main/java/org/bukkit/block/BlockState.java
|
|
+++ b/src/main/java/org/bukkit/block/BlockState.java
|
|
@@ -245,4 +245,13 @@ public interface BlockState extends Metadatable {
|
|
* or 'virtual' (e.g. on an itemstack)
|
|
*/
|
|
boolean isPlaced();
|
|
+
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Checks if this block state is collidable.
|
|
+ *
|
|
+ * @return true if collidable
|
|
+ */
|
|
+ boolean isCollidable();
|
|
+ // Paper end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java
|
|
index d4e824ad18714b951cf161031a9566e6796ab507..61a73e813f7c14c61fac358e96aaaa64c41e560b 100644
|
|
--- a/src/main/java/org/bukkit/block/BlockType.java
|
|
+++ b/src/main/java/org/bukkit/block/BlockType.java
|
|
@@ -3611,4 +3611,13 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran
|
|
@Override
|
|
@NotNull String getTranslationKey();
|
|
// Paper end - add Translatable
|
|
+
|
|
+ // Paper start - hasCollision API
|
|
+ /**
|
|
+ * Checks if this block type has collision.
|
|
+ * <p>
|
|
+ * @return false if this block never has collision, true if it <b>might</b> have collision
|
|
+ */
|
|
+ boolean hasCollision();
|
|
+ // Paper end - hasCollision API
|
|
}
|