mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Tuinity Changes: f7c42491a Fix dangerous end portal logic Airplane Changes: 8c5012517 Switch bitset to long storage 617dfe27a Patch Paper to use fast item merge raytracing 16104e8a0 Update Upstream (Tuinity)
128 lines
6.6 KiB
Diff
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 a586f486996b3bb59067a6d25ace100c24b63ecf..829dc166548c7fc2890aa4abb5906586b448306f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -206,7 +206,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 a9a2caadca0f93438a4ad8e21d2e5ff5a98aa3fd..539a338081bd532779b7f6ec15cc91ab5bd1cca9 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 3e2898e3582efc00764885739e1df3a2ab5d5f6e..6f4aab0495e168afe3927b994e9c42ddce59dc20 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1134,6 +1134,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);
|
|
@@ -1146,6 +1148,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;
|