Files
Purpur/patches/server/0144-Lobotomize-stuck-villagers.patch
BillyGalbreath 1362f49b24 Updated Upstream (Paper, Tuinity, & Airplane)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
bca97a8f7 replace spaces in world key (touches #5397)
de94f6485 Refactor chat message composition (#5396)
e27f334bb [CI-SKIP] Fix makemcdevsrc.sh for nms relocations (#5389)
ae15e85da Updated Upstream (CraftBukkit)
26fe0ac5a Only set despawnTimer for Wandering Traders spawned by MobSpawnerTrader (#5391)
b748eb7b8 Fix VanillaMobGoalTest#testBukkitMap (#5390)
18dbbb578 [Auto] Updated Upstream (CraftBukkit)
fac9cc5d5 [CI-SKIP] Ignore .gitignore
087aa70e7 Deprecate ItemStack#setLore(List<String>) and ItemStack#getLore, add Component based alternatives
9889c651c apply fixup
c310f0a61 Updated Upstream (Bukkit/CraftBukkit)
f17560ab0 wtf is this t file -jmp
347f3a9b8 fix compile
700e9e6a5 rebase
cf4dc464a Revert de5f4e469...c270abe96
6870db613 script & POM fix
743c6533c Replace ** with * (BSD/macOS)
376d7b097 Don't remove the .java
fcb3fd42a Fix macOS/BSD support
8cfc05249 Link correctly
ba1031ca7 Rename work dir
c8d844ab7 Actually fix preloading this time
e62aa5e3e Fix class preloading
1c03cf898 It's mojang math, not minecraft math
1034873df Apply fixups
39b125771 Use revision file
956150da7 Welcome to 1.16.5-R0.2
ccb217c01 Change cache keys
0d217001c more work
f6d820f07 It compiles
0f78e9525 More work
1718f61bf Updated Upstream (CraftBukkit/Spigot)
b28d46114 Update scripts for NMS repackaging

Tuinity Changes:
9bdcb9b8e Delete work dir when running jar
6351d7ca7 Update Upstream (Paper)
932c199a6 Generate md-dev correctly
bf3e73778 Make packet limiter work from IDE
1686f3861 Fix packet limiter config
f40f7b425 Update README.md styling (#264)
da1c3ace5 GH Actions Changes (#213)
5f325ecf1 Update Upstream (Paper)
0f83fe48d Update Upstream (Paper)

Airplane Changes:
f94d39947 Merge pull request #18 from notOM3GA/upstream/nms-repackage
0fc622631 Force build for Flare update
08439d6a9 Update Upstream (Tuinity)
2021-03-21 23:00:01 -05:00

128 lines
6.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <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/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 4b4c6477122c51871ce98f34c6e5874048eaa227..904bca540a42204a9856765e333eee6c5de6a960 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -207,7 +207,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
public double lastY;
public double lastZ;
private Vec3D loc;
- private BlockPosition locBlock;
+ private BlockPosition locBlock; public BlockPosition getBlockLocation() { return locBlock; } // Purpur
private Vec3D mot;
public float yaw;
public float pitch;
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
index 48e6a4c588ef39a4bde067d79b96a656c68750ce..ac7bad10697c6fde7d512753992d59710aa1e032 100644
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
@@ -123,6 +123,7 @@ public abstract class NavigationAbstract {
}
@Nullable
+ public PathEntity calculateDestination(BlockPosition blockposition, int i) { return a(blockposition, i); } // Purpur - OBFHELPER
public PathEntity a(BlockPosition blockposition, int i) {
// Paper start - add target parameter
return this.a(blockposition, null, i);
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
index a0f0d5e0909da5cfe87078d4722b030635cfeadd..bc14e242f97f9f6d8e581d12319c95ae5f70f250 100644
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
@@ -89,6 +89,7 @@ import net.minecraft.world.level.IWorldReader;
import net.minecraft.world.level.World;
import net.minecraft.world.level.WorldAccess;
import net.minecraft.world.level.block.state.IBlockData;
+import net.minecraft.world.level.pathfinder.PathEntity;
import net.minecraft.world.phys.AxisAlignedBB;
import org.apache.logging.log4j.Logger;
@@ -260,11 +261,32 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
private int behaviorTick = 0;
+ // Purpur start
+ boolean lobotomized = false;
+
+ private boolean isLobotomized() {
+ if ((world.getTime() + brainTickOffset) % world.purpurConfig.villagerLobotomizeCheck == 0) {
+ this.lobotomized = !canTravelFrom(getBlockLocation().up());
+ }
+ return this.lobotomized;
+ }
+
+ private boolean canTravelFrom(BlockPosition pos) {
+ return canTravelTo(pos.east()) || canTravelTo(pos.west()) || canTravelTo(pos.north()) || canTravelTo(pos.south());
+ }
+
+ private boolean canTravelTo(BlockPosition pos) {
+ PathEntity to = navigation.calculateDestination(pos, 0);
+ return to != null && to.getPoints().size() > 1;
+ }
+ // Purpur end
+
@Override
protected void mobTick() { mobTick(false); }
protected void mobTick(boolean inactive) {
this.world.getMethodProfiler().enter("villagerBrain");
// Purpur start
+ if (world.purpurConfig.villagerLobotomizeEnabled) inactive = inactive || isLobotomized();
boolean tick = (world.getTime() + brainTickOffset) % world.purpurConfig.villagerBrainTicks == 0;
if (((WorldServer) world).getMinecraftServer().lagging ? tick : world.purpurConfig.villagerUseBrainTicksOnlyWhenLagging || tick)
// Purpur end
@@ -273,6 +295,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper
}
}
+ else if (shouldRestock()) doRestock(); // Purpur
this.world.getMethodProfiler().exit();
if (this.bF) {
this.bF = false;
@@ -404,6 +427,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
return true;
}
+ public void doRestock() { fb(); } // Purpur - OBFHELPER
public void fb() {
this.fp();
Iterator iterator = this.getOffers().iterator();
@@ -438,6 +462,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
return this.bD == 0 || this.bD < 2 && this.world.getTime() > this.bC + 2400L;
}
+ public boolean shouldRestock() { return fc(); } // Purpur - OBFHELPER
public boolean fc() {
long i = this.bC + 12000L;
long j = this.world.getTime();
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 5ad9b63e50137163ec7bab48560f618f165d676f..b2e4404e05ba304423803779321321292b306255 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1076,6 +1076,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);
@@ -1088,6 +1090,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 villagerTraderRidable = false;