mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
64 lines
3.5 KiB
Diff
64 lines
3.5 KiB
Diff
From c7c80f357a335240d763c8f9a0306e2541d151e3 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Tue, 23 Jul 2019 08:28:21 -0500
|
|
Subject: [PATCH] Implement configurable villager brain ticks
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/EntityVillager.java | 6 ++++++
|
|
src/main/java/net/pl3x/purpur/PurpurWorldConfig.java | 4 ++++
|
|
2 files changed, 10 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
|
|
index 5b0de0d9d8..843f22260b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityVillager.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
|
|
@@ -53,6 +53,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
}, MemoryModuleType.MEETING_POINT, (entityvillager, villageplacetype) -> {
|
|
return villageplacetype == VillagePlaceType.r;
|
|
});
|
|
+ private final int brainTickOffset; // Purpur
|
|
|
|
public EntityVillager(EntityTypes<? extends EntityVillager> entitytypes, World world) {
|
|
this(entitytypes, world, VillagerType.PLAINS);
|
|
@@ -66,6 +67,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
this.setCanPickupLoot(true);
|
|
this.setVillagerData(this.getVillagerData().withType(villagertype).withProfession(VillagerProfession.NONE));
|
|
this.bo = this.a(new Dynamic(DynamicOpsNBT.a, new NBTTagCompound()));
|
|
+ brainTickOffset = getRandom().nextInt(100); // Purpur
|
|
}
|
|
|
|
// Purpur start
|
|
@@ -180,6 +182,10 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
protected void mobTick(boolean inactive) {
|
|
// Paper end
|
|
this.world.getMethodProfiler().enter("brain");
|
|
+ // Purpur start
|
|
+ boolean tick = (world.getTime() + brainTickOffset) % world.purpurConfig.villagerBrainTicks == 0;
|
|
+ if (((WorldServer) world).getMinecraftServer().lagging ? tick : world.purpurConfig.villagerUseBrainTicksOnlyWhenLagging || tick)
|
|
+ // Purpur end
|
|
if (!inactive) this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper
|
|
this.world.getMethodProfiler().exit();
|
|
if (!this.et() && this.bB > 0) {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 9c60855d66..f1ed653b3a 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -737,10 +737,14 @@ public class PurpurWorldConfig {
|
|
public boolean villagerRidable = false;
|
|
public boolean villagerRidableInWater = false;
|
|
public boolean villagerRequireShiftToMount = true;
|
|
+ public int villagerBrainTicks = 1;
|
|
+ public boolean villagerUseBrainTicksOnlyWhenLagging = true;
|
|
private void villagerSettings() {
|
|
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
|
|
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
|
|
villagerRequireShiftToMount = getBoolean("mobs.villager.require-shift-to-mount", villagerRequireShiftToMount);
|
|
+ villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
|
|
+ villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
|
|
}
|
|
|
|
public boolean villagerTraderRidable = false;
|
|
--
|
|
2.24.0
|
|
|