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: eb11845f8 Fix creating worlds with "invalid" names (Fixes #5331) e4d8a6279 Implement Keyed on World bcb63dab7 [CI-SKIP] [Auto] Rebuild Patches 48342b06c Allow signs that are inside of the spawn protection to be right clicked to use their run_command tag c229f90c1 Add Block#isValidTool 20e709c1d Add recipe to cook events 2dcf8bff4 legacy formatting will be the death of me f597fea0d legacy formatting is worse than walking around in wet socks 7f72c4675 Use implementation-provided legacy serializer for events 27a8d99ec Adventure 4.7.0 e65bd35a1 Respect teams in legacy chat name if configured (#5321) b31089a92 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5325) a52b30814 Fix title swapping fadeIn and stay 54ec85949 Prevent grindstones from overstacking items d7795080c Fix NPE for AIR in meta operations in ItemStack 2e70796c7 [CI-SKIP] Improve documentation of PreCreatureSpawnEvent (#5244) 7bb92e750 [CI-SKIP] Add JavaDoc links to Tag class pointing to custom Paper tags (#5285) 28cd686bf fix per-world difficulty command (#5306) be7cde2c7 [CI-SKIP] Always check PATH for JDK (#5315)
56 lines
3.3 KiB
Diff
56 lines
3.3 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/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
|
|
index 90154d2180ebb6a54536884bf89187ca17d11da5..1c87bc91515490e2f8579a5321058845c7d30a56 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityVillager.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
|
|
@@ -56,6 +56,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
}, MemoryModuleType.MEETING_POINT, (entityvillager, villageplacetype) -> {
|
|
return villageplacetype == VillagePlaceType.s;
|
|
});
|
|
+ private final int brainTickOffset; // Purpur
|
|
|
|
public EntityVillager(EntityTypes<? extends EntityVillager> entitytypes, World world) {
|
|
this(entitytypes, world, VillagerType.PLAINS);
|
|
@@ -68,6 +69,7 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
this.getNavigation().d(true);
|
|
this.setCanPickupLoot(true);
|
|
this.setVillagerData(this.getVillagerData().withType(villagertype).withProfession(VillagerProfession.NONE));
|
|
+ this.brainTickOffset = getRandom().nextInt(100); // Purpur
|
|
}
|
|
|
|
@Override
|
|
@@ -164,7 +166,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
|
protected void mobTick() { mobTick(false); }
|
|
protected void mobTick(boolean inactive) {
|
|
this.world.getMethodProfiler().enter("villagerBrain");
|
|
- if (!inactive) this.getBehaviorController().Wa((WorldServer) this.world, this); // CraftBukkit - decompile error // Paper
|
|
+ // 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.bF) {
|
|
this.bF = false;
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index c441fcea9b2b5a77b801c8a69541cf42050927dc..c7fb5a737cab0083c39732247acb8f4e87562894 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -74,4 +74,11 @@ public class PurpurWorldConfig {
|
|
playerSpawnInvulnerableTicks = getInt("gameplay-mechanics.player.spawn-invulnerable-ticks", playerSpawnInvulnerableTicks);
|
|
playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
|
|
}
|
|
+
|
|
+ public int villagerBrainTicks = 1;
|
|
+ public boolean villagerUseBrainTicksOnlyWhenLagging = true;
|
|
+ private void villagerSettings() {
|
|
+ villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
|
|
+ villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
|
|
+ }
|
|
}
|