From 02ebbcfc81c323857c31c018cb153a55457a19e6 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 12 Jun 2021 21:07:45 +0100 Subject: [PATCH] #855: Add HumanEntity#getItemInUse and Material#getSlipperiness By: konsolas --- .../org/bukkit/craftbukkit/entity/CraftHumanEntity.java | 6 ++++++ paper-server/src/test/java/org/bukkit/PerMaterialTest.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index eaec9b2b23..952f2d5119 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -450,6 +450,12 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getHandle().isHandRaised(); } + @Override + public ItemStack getItemInUse() { + net.minecraft.world.item.ItemStack item = getHandle().getActiveItem(); + return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); + } + @Override public boolean setWindowProperty(InventoryView.Property prop, int value) { return false; diff --git a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java index ab00359f92..3190c01952 100644 --- a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java @@ -242,6 +242,13 @@ public class PerMaterialTest extends AbstractTestingBase { } } + @Test + public void testSlipperiness() { + if (material.isBlock()) { + assertThat(material.getSlipperiness(), is(CraftMagicNumbers.getBlock(material).getFrictionFactor())); + } + } + @Test public void testBlockDataCreation() { if (material.isBlock()) {