From 852360dbc2b0ac818f75a51292a20c75e60fdad7 Mon Sep 17 00:00:00 2001 From: Yeregorix Date: Tue, 4 Oct 2022 13:59:44 +0200 Subject: [PATCH] Fix removing leash holder --- .../common/data/provider/entity/MobData.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/common/data/provider/entity/MobData.java b/src/main/java/org/spongepowered/common/data/provider/entity/MobData.java index 87b3b5cca09..238408bd55d 100644 --- a/src/main/java/org/spongepowered/common/data/provider/entity/MobData.java +++ b/src/main/java/org/spongepowered/common/data/provider/entity/MobData.java @@ -48,7 +48,13 @@ public static void register(final DataProviderRegistrator registrator) { .set((h, v) -> h.setLeftHanded(v.equals(HandPreferences.LEFT.get()))) .create(Keys.LEASH_HOLDER) .get(h -> ((Entity) h.getLeashHolder())) - .set((h, v) -> h.setLeashedTo((net.minecraft.world.entity.Entity) v, true)) + .set((h, v) -> { + if (v == null) { + h.dropLeash(true, false); + } else { + h.setLeashedTo((net.minecraft.world.entity.Entity) v, true); + } + }) .create(Keys.TARGET_ENTITY) .get(h -> (Living) h.getTarget()) .setAnd((h, v) -> {