mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
82 lines
4.5 KiB
Diff
82 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 3 Dec 2020 17:56:18 -0600
|
|
Subject: [PATCH] Lobotomize stuck villagers
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
index 1e05cc98a332e5b115c4670e5331e679117c6629..84142a42111ff03827297c522b7ce164b9a28276 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -142,6 +142,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
return villageplacetype == PoiType.MEETING;
|
|
});
|
|
private final int brainTickOffset; // Purpur
|
|
+ boolean lobotomized = false; // Purpur
|
|
|
|
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
|
this(entityType, world, VillagerType.PLAINS);
|
|
@@ -183,6 +184,22 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
public boolean canBeLeashed(Player player) {
|
|
return level.purpurConfig.villagerCanBeLeashed && !this.isLeashed();
|
|
}
|
|
+
|
|
+ private boolean isLobotomized() {
|
|
+ if ((level.getGameTime() + brainTickOffset) % level.purpurConfig.villagerLobotomizeCheck == 0) {
|
|
+ this.lobotomized = !canTravelFrom(blockPosition().above());
|
|
+ }
|
|
+ return this.lobotomized;
|
|
+ }
|
|
+
|
|
+ private boolean canTravelFrom(BlockPos pos) {
|
|
+ return canTravelTo(pos.east()) || canTravelTo(pos.west()) || canTravelTo(pos.north()) || canTravelTo(pos.south());
|
|
+ }
|
|
+
|
|
+ private boolean canTravelTo(BlockPos pos) {
|
|
+ net.minecraft.world.level.pathfinder.Path to = navigation.createPath(pos, 0);
|
|
+ return to != null && to.nodes.size() > 1;
|
|
+ }
|
|
// Purpur end
|
|
|
|
@Override
|
|
@@ -280,10 +297,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
protected void mobTick(boolean inactive) {
|
|
this.level.getProfiler().push("villagerBrain");
|
|
// Purpur start
|
|
+ if (level.purpurConfig.villagerLobotomizeEnabled) inactive = inactive || isLobotomized();
|
|
boolean tick = (level.getGameTime() + brainTickOffset) % level.purpurConfig.villagerBrainTicks == 0;
|
|
if (((ServerLevel) level).getServer().lagging ? tick : level.purpurConfig.villagerUseBrainTicksOnlyWhenLagging || tick)
|
|
// Purpur end
|
|
if (!inactive) this.getBrain().tick((ServerLevel) this.level, this); // CraftBukkit - decompile error // Paper
|
|
+ else if (shouldRestock()) restock(); // Purpur
|
|
this.level.getProfiler().pop();
|
|
if (this.assignProfessionWhenSpawned) {
|
|
this.assignProfessionWhenSpawned = false;
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 607d569f73e41dafc0c0f0f27fa9e2edbc247626..c313fce9497908fcbdff4148f20bbb8ab0d5864b 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1627,6 +1627,8 @@ public class PurpurWorldConfig {
|
|
public int villagerSpawnIronGolemLimit = 0;
|
|
public boolean villagerCanBreed = true;
|
|
public int villagerBreedingTicks = 6000;
|
|
+ public boolean villagerLobotomizeEnabled = false;
|
|
+ public int villagerLobotomizeCheck = 60;
|
|
private void villagerSettings() {
|
|
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
|
|
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
|
|
@@ -1644,6 +1646,13 @@ public class PurpurWorldConfig {
|
|
villagerSpawnIronGolemLimit = getInt("mobs.villager.spawn-iron-golem.limit", villagerSpawnIronGolemLimit);
|
|
villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
|
|
villagerBreedingTicks = getInt("mobs.villager.breeding-delay-ticks", villagerBreedingTicks);
|
|
+ if (PurpurConfig.version < 9) {
|
|
+ boolean oldValue = getBoolean("mobs.villager.lobotomize-1x1", villagerLobotomizeEnabled);
|
|
+ set("mobs.villager.lobotomize.enabled", oldValue);
|
|
+ set("mobs.villager.lobotomize-1x1", null);
|
|
+ }
|
|
+ villagerLobotomizeEnabled = getBoolean("mobs.villager.lobotomize.enabled", villagerLobotomizeEnabled);
|
|
+ villagerLobotomizeCheck = getInt("mobs.villager.lobotomize.check-interval", villagerLobotomizeCheck);
|
|
}
|
|
|
|
public boolean vindicatorRidable = false;
|