mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
60 lines
3.5 KiB
Diff
60 lines
3.5 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 07686c678cd47defd9e0b742a71fd13e83142870..bd6a707962ac4d3961e1ce74570909e29ce4f4dd 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
|
|
}
|
|
|
|
// Purpur start
|
|
@@ -271,6 +273,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 2d42f36e9f1ce6bf064588d84ed7ae52563f0e7a..65ca6e4a1c99555842804e5e21415d5f3193d526 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1059,6 +1059,8 @@ public class PurpurWorldConfig {
|
|
public boolean villagerRidable = false;
|
|
public boolean villagerRidableInWater = false;
|
|
public double villagerMaxHealth = 20.0D;
|
|
+ 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);
|
|
@@ -1068,6 +1070,8 @@ public class PurpurWorldConfig {
|
|
set("mobs.villager.attributes.max_health", oldValue);
|
|
}
|
|
villagerMaxHealth = getDouble("mobs.villager.attributes.max_health", villagerMaxHealth);
|
|
+ villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
|
|
+ villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
|
|
}
|
|
|
|
public boolean vindicatorRidable = false;
|