2021-11-06 20:43:24 +01:00
|
|
|
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
|
2022-05-05 00:29:15 +02:00
|
|
|
index b2628b1698ef2a235e7b465f09747cafbb133b7a..2881bcb570dc86a7602309e1f540ecd1c7f00284 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2022-03-13 08:47:54 +01:00
|
|
|
@@ -480,6 +480,11 @@ public class CraftBlock implements Block {
|
2021-11-06 20:43:24 +01:00
|
|
|
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 7b9e943b391c061782fccd2b8d705ceec8db50fe..966ac60daebb7bb211ab8096fc0c5f33db67320a 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
@@ -324,4 +324,11 @@ 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
|
2022-08-08 17:25:41 +02:00
|
|
|
index 51ecfd4c4afe6dfc42c3aa85e6fc55d0e965a5dc..0a3d447f87698dc786d6cab6ded27eb1b5780204 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2022-05-27 17:42:36 +02:00
|
|
|
@@ -574,6 +574,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2021-11-06 20:43:24 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
/**
|