Files
Purpur/patches/server/0044-Allow-leashing-villagers.patch
2019-07-28 09:45:50 -05:00

59 lines
3.0 KiB
Diff

From c846d739057ad00213a29f0c0372951d30791c14 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Wed, 10 Jul 2019 20:14:07 -0500
Subject: [PATCH] Allow leashing villagers
---
src/main/java/net/minecraft/server/EntityInsentient.java | 1 +
src/main/java/net/minecraft/server/EntityVillager.java | 7 +++++++
src/main/java/net/pl3x/purpur/PurpurWorldConfig.java | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 47090db890..67deda84bd 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -1036,6 +1036,7 @@ public abstract class EntityInsentient extends EntityLiving {
if (!this.isAlive()) {
return false;
} else if (this.getLeashHolder() == entityhuman) {
+ if (world.purpurConfig.allowLeashingVillagers && enumhand == EnumHand.OFF_HAND && this instanceof EntityVillager) return true; // Purpur
// CraftBukkit start - fire PlayerUnleashEntityEvent
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
index c2ccb85896..976473a678 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
@@ -982,4 +982,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
return optional.isPresent() && optional1.isPresent() ? i - ((MinecraftSerializableLong) optional.get()).a() < 24000L && i - ((MinecraftSerializableLong) optional1.get()).a() < 36000L : false;
}
+
+ // Purpur - start
+ @Override
+ public boolean a(EntityHuman entityhuman) {
+ return world.purpurConfig.allowLeashingVillagers && !this.isLeashed();
+ }
+ // Purpur - end
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index a33eb6773c..542e1b3299 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -107,6 +107,11 @@ public class PurpurWorldConfig {
allowSignColors = getBoolean("allow-sign-colors", allowSignColors);
}
+ public boolean allowLeashingVillagers = true;
+ private void allowLeashingVillagers() {
+ allowLeashingVillagers = getBoolean("allow-leashing-villagers", allowLeashingVillagers);
+ }
+
public boolean itemsCanBreakTurtleEggs = false;
private void itemsCanBreakTurtleEggs() {
itemsCanBreakTurtleEggs = getBoolean("items-can-break-turtle-eggs", itemsCanBreakTurtleEggs);
--
2.20.1