geforkt von Mirrors/Paper
Add isCollidable methods to various places (#6870)
Dieser Commit ist enthalten in:
Ursprung
6197315429
Commit
0f52610a18
@ -249,3 +249,6 @@ public net.minecraft.world.item.SpawnEggItem BY_ID
|
||||
|
||||
# Zombie API - breaking doors
|
||||
public net.minecraft.world.entity.monster.Zombie supportsBreakDoorGoal()Z
|
||||
|
||||
# Add Material#hasCollision
|
||||
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
|
||||
|
82
patches/api/Add-isCollidable-methods-to-various-places.patch
Normale Datei
82
patches/api/Add-isCollidable-methods-to-various-places.patch
Normale Datei
@ -0,0 +1,82 @@
|
||||
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 isCollidable methods to various places
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata
|
||||
public com.google.common.collect.Multimap<org.bukkit.attribute.Attribute, org.bukkit.attribute.AttributeModifier> getItemAttributes(@NotNull EquipmentSlot equipmentSlot) {
|
||||
return Bukkit.getUnsafe().getItemAttributes(this, equipmentSlot);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this material is collidable.
|
||||
+ *
|
||||
+ * @return true if collidable
|
||||
+ * @throws IllegalArgumentException if {@link #isBlock()} is false
|
||||
+ */
|
||||
+ public boolean isCollidable() {
|
||||
+ return Bukkit.getUnsafe().isCollidable(this);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||
* @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first)
|
||||
*/
|
||||
@org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if this material is collidable.
|
||||
+ *
|
||||
+ * @param material the material to check
|
||||
+ * @return true if collidable
|
||||
+ * @throws IllegalArgumentException if {@link Material#isBlock()} is false
|
||||
+ */
|
||||
+ boolean isCollidable(@org.jetbrains.annotations.NotNull Material material);
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Block.java
|
||||
+++ b/src/main/java/org/bukkit/block/Block.java
|
||||
@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
|
||||
* @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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/BlockState.java
|
||||
+++ b/src/main/java/org/bukkit/block/BlockState.java
|
||||
@@ -0,0 +0,0 @@ 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
|
||||
}
|
55
patches/server/Add-isCollidable-methods-to-various-places.patch
Normale Datei
55
patches/server/Add-isCollidable-methods-to-various-places.patch
Normale Datei
@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 4 Nov 2021 11:50:40 -0700
|
||||
Subject: [PATCH] Add isCollidable methods to various places
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -0,0 +0,0 @@ public class CraftBlock implements Block {
|
||||
public boolean isSolid() {
|
||||
return getNMS().getMaterial().blocksMotion();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return getNMS().getBlock().hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
@@ -0,0 +0,0 @@ public class CraftBlockState implements BlockState {
|
||||
throw new IllegalStateException("The blockState must be placed to call this method");
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return this.data.getBlock().hasCollision;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable(Material material) {
|
||||
+ Preconditions.checkArgument(material.isBlock(), material + " is not a block");
|
||||
+ return getBlock(material).hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren