mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
56 lines
3.2 KiB
Diff
56 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 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] Configurable villager brain ticks
|
|
|
|
|
|
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 27530389690ec329bd92a722e4faf87e367bce91..d9d12330e84f204f96761051e1d92984d8a96330 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -141,6 +141,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}, MemoryModuleType.MEETING_POINT, (entityvillager, villageplacetype) -> {
|
|
return villageplacetype == PoiType.MEETING;
|
|
});
|
|
+ private final int brainTickOffset; // Purpur
|
|
|
|
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
|
this(entityType, world, VillagerType.PLAINS);
|
|
@@ -153,6 +154,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
this.getNavigation().setCanFloat(true);
|
|
this.setCanPickUpLoot(true);
|
|
this.setVillagerData(this.getVillagerData().setType(type).setProfession(VillagerProfession.NONE));
|
|
+ this.brainTickOffset = getRandom().nextInt(100); // Purpur
|
|
}
|
|
|
|
@Override
|
|
@@ -249,6 +251,10 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
protected void customServerAiStep() { mobTick(false); }
|
|
protected void mobTick(boolean inactive) {
|
|
this.level.getProfiler().push("villagerBrain");
|
|
+ // Purpur start
|
|
+ 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
|
|
this.level.getProfiler().pop();
|
|
if (this.assignProfessionWhenSpawned) {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 3a4ac9c75b4517bb6fdad67d1db5e4ac805f3ee4..76bd14850cdabd2883611ebecaa8227efdd02a64 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -519,9 +519,13 @@ public class PurpurWorldConfig {
|
|
|
|
public boolean villagerRidable = false;
|
|
public boolean villagerRidableInWater = false;
|
|
+ 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);
|
|
+ villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
|
|
+ villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
|
|
}
|
|
|
|
public boolean vindicatorRidable = false;
|