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:b33b63908eSupport complex components in written book builder (#6337)bfb3d42b44Optimize entity tracker passenger checks (#6361)399710ff79Add reobf mappings patch for MinecraftServer#getLootTables (#6368)25cd8aba9fConfig option for Piglins guarding chests (#4829)80650e8936Added EntityItemDamageEvent (#4928) Tuinity Changes:8e7cc4dc96Do not submit profile lookups to worldgen threads
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 4752205ab570ab8f6ae7f0a15ae610b603ade2ea..ddfb060e229df3a11cef4e0cb08f0cd22122a66c 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() > 0;
|
|
+ }
|
|
// 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 b7d6a9d783d306a88e162bf13fa7d9d8f8a21fd0..076e0ebdcb5334a4d89d53e31aa751ccf7df2ea2 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1647,6 +1647,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);
|
|
@@ -1664,6 +1666,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;
|