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
|
|
|
|
|
2022-11-20 00:53:20 +01:00
|
|
|
== AT ==
|
|
|
|
public net.minecraft.world.level.block.state.BlockBehaviour hasCollision
|
2021-11-06 20:43:24 +01:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2023-09-10 04:28:03 +02:00
|
|
|
index 50469bbd710375c6046647203435330c5bc21a4f..e649c3296363ea2f8429593e33a7833143bcabba 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
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -482,6 +482,11 @@ public class CraftBlock implements Block {
|
2021-11-06 20:43:24 +01:00
|
|
|
public boolean isSolid() {
|
2023-06-08 04:12:38 +02:00
|
|
|
return this.getNMS().blocksMotion();
|
2021-11-06 20:43:24 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
2023-06-13 01:51:45 +02:00
|
|
|
index b722a207c0e745bb172d93b90e1241d7bfa173ce..792bfc7eab33b26462e76a1912bd712e8af70073 100644
|
2021-11-06 20:43:24 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -317,4 +317,11 @@ public class CraftBlockState implements BlockState {
|
|
|
|
protected void requirePlaced() {
|
|
|
|
Preconditions.checkState(this.isPlaced(), "The blockState must be placed to call this method");
|
2021-11-06 20:43:24 +01:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
2023-06-13 09:10:07 +02:00
|
|
|
index 53e40ab7d37ef707151c165831b24737a9f3683c..bbc3724769497e7687a27d800cd7511c5f1fe667 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
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -580,6 +580,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2022-12-08 04:24:00 +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.registries.BuiltInRegistries.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
2021-11-06 20:43:24 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
/**
|