diff --git a/build-data/paper.at b/build-data/paper.at index d259e9a3f1..51c7de20a0 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -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 diff --git a/patches/api/Add-isCollidable-methods-to-various-places.patch b/patches/api/Add-isCollidable-methods-to-various-places.patch new file mode 100644 index 0000000000..ce821d3df4 --- /dev/null +++ b/patches/api/Add-isCollidable-methods-to-various-places.patch @@ -0,0 +1,82 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +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 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 + } diff --git a/patches/server/Add-isCollidable-methods-to-various-places.patch b/patches/server/Add-isCollidable-methods-to-various-places.patch new file mode 100644 index 0000000000..c03be9f476 --- /dev/null +++ b/patches/server/Add-isCollidable-methods-to-various-places.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +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) 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 + + /**