Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix villagers being unable to spawn when mobs.villager.follow-emerald-blocks was enabled #1611

Merged
merged 6 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 63 additions & 13 deletions patches/server/0047-Villagers-follow-emerald-blocks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Date: Fri, 29 Nov 2019 22:10:12 -0600
Subject: [PATCH] Villagers follow emerald blocks


diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java b/src/main/java/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
index 157fe8979c780300b6f72cbaa17729031e3b386d..0bb08af954d224a2b4404615bee720ac4bdbac55 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
@@ -161,7 +161,7 @@ public class DefaultAttributes {
.put(EntityType.VILLAGER, Villager.createAttributes().build())
.put(EntityType.VINDICATOR, Vindicator.createAttributes().build())
.put(EntityType.WARDEN, Warden.createAttributes().build())
- .put(EntityType.WANDERING_TRADER, Mob.createMobAttributes().build())
+ .put(EntityType.WANDERING_TRADER, net.minecraft.world.entity.npc.WanderingTrader.createAttributes().build()) // Purpur
.put(EntityType.WITCH, Witch.createAttributes().build())
.put(EntityType.WITHER, WitherBoss.createAttributes().build())
.put(EntityType.WITHER_SKELETON, AbstractSkeleton.createAttributes().build())
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java
index 84ab90dd1fe693da71732533ccff940c1007e1b6..179fdf7b7f68db610925a9d7b88879289b1b98b8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/TemptGoal.java
Expand All @@ -30,22 +43,55 @@ index 5f656fc726a1dc5f42657095a2f2b7cf85b92d7c..6c74cf1dea99b3b967b8c3d76f405f82
// CraftBukkit start
@Override
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 37c26008486ffdf7f1d6bdfd0253067a1c6bf942..448f3cacd0c599eb1841b31b1c3bfc60ba3da7d3 100644
index 37c26008486ffdf7f1d6bdfd0253067a1c6bf942..aad307477e687db1a7868cca6674b1226dfd5035 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -154,6 +154,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
this.getNavigation().setRequiredPathLength(48.0F);
this.setCanPickUpLoot(true);
this.setVillagerData(this.getVillagerData().setType(type).setProfession(VillagerProfession.NONE));
@@ -175,6 +175,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this));
+ if (level().purpurConfig.villagerFollowEmeraldBlock) this.goalSelector.addGoal(3, new net.minecraft.world.entity.ai.goal.TemptGoal(this, 1.0D, TEMPT_ITEMS, false));
}
// Purpur end

@@ -182,6 +183,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
public void initAttributes() {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.villagerMaxHealth);
this.getAttribute(Attributes.SCALE).setBaseValue(this.level().purpurConfig.villagerScale);
+ this.getAttribute(Attributes.TEMPT_RANGE).setBaseValue(this.level().purpurConfig.villagerTemptRange); // Purpur
}

@Override
@@ -245,7 +247,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
}

// Purpur start
public static AttributeSupplier.Builder createAttributes() {
- return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.5D);
+ return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.5D).add(Attributes.TEMPT_RANGE, 10.0D); // Purpur - add TEMPT_RANGE
}

public boolean assignProfessionWhenSpawned() {
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index f741aca818bc983b034b3ac9864c1d71c714f9b4..c8f6a6fd0d954346e8651b83e05063e09b53f7f9 100644
index f741aca818bc983b034b3ac9864c1d71c714f9b4..a821a7bc7de7458ceb8afdb61bde32f74534f012 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -114,6 +114,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
@@ -92,8 +92,15 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
@Override
public void initAttributes() {
this.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.wanderingTraderMaxHealth);
+ this.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.TEMPT_RANGE).setBaseValue(this.level().purpurConfig.wanderingTraderTemptRange); // Purpur
}

+ // Purpur start
+ public static net.minecraft.world.entity.ai.attributes.AttributeSupplier.Builder createAttributes() {
+ return Mob.createMobAttributes().add(net.minecraft.world.entity.ai.attributes.Attributes.TEMPT_RANGE, 10.0D);
+ }
+ // Purpur end
+
@Override
protected void registerGoals() {
this.goalSelector.addGoal(0, new FloatGoal(this));
@@ -114,6 +121,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
this.goalSelector.addGoal(1, new PanicGoal(this, 0.5D));
this.goalSelector.addGoal(1, new LookAtTradingPlayerGoal(this));
this.goalSelector.addGoal(2, new WanderingTrader.WanderToPositionGoal(this, 2.0D, 0.35D));
Expand All @@ -54,38 +100,42 @@ index f741aca818bc983b034b3ac9864c1d71c714f9b4..c8f6a6fd0d954346e8651b83e05063e0
this.goalSelector.addGoal(8, new WaterAvoidingRandomStrollGoal(this, 0.35D));
this.goalSelector.addGoal(9, new InteractGoal(this, Player.class, 3.0F, 1.0F));
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index df21a5f89b1c659bc0dfea8f42362ef09b368d81..228ad3c9186d7128430be0edcd4447b168206721 100644
index df21a5f89b1c659bc0dfea8f42362ef09b368d81..a36fd98b7acaa8bf9107f5f1a7091437eb2ea829 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1575,6 +1575,7 @@ public class PurpurWorldConfig {
@@ -1575,6 +1575,8 @@ public class PurpurWorldConfig {
public boolean villagerControllable = true;
public double villagerMaxHealth = 20.0D;
public double villagerScale = 1.0D;
+ public boolean villagerFollowEmeraldBlock = false;
+ public double villagerTemptRange = 10.0D;
private void villagerSettings() {
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -1586,6 +1587,7 @@ public class PurpurWorldConfig {
@@ -1586,6 +1588,8 @@ public class PurpurWorldConfig {
}
villagerMaxHealth = getDouble("mobs.villager.attributes.max_health", villagerMaxHealth);
villagerScale = Mth.clamp(getDouble("mobs.villager.attributes.scale", villagerScale), 0.0625D, 16.0D);
+ villagerFollowEmeraldBlock = getBoolean("mobs.villager.follow-emerald-blocks", villagerFollowEmeraldBlock);
+ villagerTemptRange = getDouble("mobs.villager.attributes.tempt_range", villagerTemptRange);
}

public boolean vindicatorRidable = false;
@@ -1611,6 +1613,7 @@ public class PurpurWorldConfig {
@@ -1611,6 +1615,8 @@ public class PurpurWorldConfig {
public boolean wanderingTraderControllable = true;
public double wanderingTraderMaxHealth = 20.0D;
public double wanderingTraderScale = 1.0D;
+ public boolean wanderingTraderFollowEmeraldBlock = false;
+ public double wanderingTraderTemptRange = 10.0D;
private void wanderingTraderSettings() {
wanderingTraderRidable = getBoolean("mobs.wandering_trader.ridable", wanderingTraderRidable);
wanderingTraderRidableInWater = getBoolean("mobs.wandering_trader.ridable-in-water", wanderingTraderRidableInWater);
@@ -1622,6 +1625,7 @@ public class PurpurWorldConfig {
@@ -1622,6 +1628,8 @@ public class PurpurWorldConfig {
}
wanderingTraderMaxHealth = getDouble("mobs.wandering_trader.attributes.max_health", wanderingTraderMaxHealth);
wanderingTraderScale = Mth.clamp(getDouble("mobs.wandering_trader.attributes.scale", wanderingTraderScale), 0.0625D, 16.0D);
+ wanderingTraderFollowEmeraldBlock = getBoolean("mobs.wandering_trader.follow-emerald-blocks", wanderingTraderFollowEmeraldBlock);
+ wanderingTraderTemptRange = getDouble("mobs.wandering_trader.attributes.tempt_range", wanderingTraderTemptRange);
}

public boolean wardenRidable = false;
24 changes: 12 additions & 12 deletions patches/server/0048-Allow-leashing-villagers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ index 1e639ab3e48d884ee6e2c33be85dde51e24183b6..75b0a66be9f94c82a02f714860ae8bee
// Paper start - Expand EntityUnleashEvent
org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.hasInfiniteMaterials());
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 448f3cacd0c599eb1841b31b1c3bfc60ba3da7d3..9008eeae3187024862bef886801d197c4c425df3 100644
index aad307477e687db1a7868cca6674b1226dfd5035..329db0049e0792b2c066349849ebd7c26a9178d7 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -177,6 +177,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
protected void registerGoals() {
this.goalSelector.addGoal(0, new org.purpurmc.purpur.entity.ai.HasRider(this));
if (level().purpurConfig.villagerFollowEmeraldBlock) this.goalSelector.addGoal(3, new net.minecraft.world.entity.ai.goal.TemptGoal(this, 1.0D, TEMPT_ITEMS, false));
}
+
+ @Override
Expand All @@ -33,7 +33,7 @@ index 448f3cacd0c599eb1841b31b1c3bfc60ba3da7d3..9008eeae3187024862bef886801d197c

@Override
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index c8f6a6fd0d954346e8651b83e05063e09b53f7f9..7b8b5a7b1fea50c7b238afc4b3d79746da08b641 100644
index a821a7bc7de7458ceb8afdb61bde32f74534f012..738df68a988a8ba428bf2c74a12cb8d9dd525bee 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -87,6 +87,11 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
Expand All @@ -49,37 +49,37 @@ index c8f6a6fd0d954346e8651b83e05063e09b53f7f9..7b8b5a7b1fea50c7b238afc4b3d79746

@Override
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 228ad3c9186d7128430be0edcd4447b168206721..21c2b19f40f43ec78ff891c6333d8773f84ec85b 100644
index a36fd98b7acaa8bf9107f5f1a7091437eb2ea829..daf3b319422d22cb33a945033aa45e55a0f4e116 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1576,6 +1576,7 @@ public class PurpurWorldConfig {
public double villagerMaxHealth = 20.0D;
@@ -1577,6 +1577,7 @@ public class PurpurWorldConfig {
public double villagerScale = 1.0D;
public boolean villagerFollowEmeraldBlock = false;
public double villagerTemptRange = 10.0D;
+ public boolean villagerCanBeLeashed = false;
private void villagerSettings() {
villagerRidable = getBoolean("mobs.villager.ridable", villagerRidable);
villagerRidableInWater = getBoolean("mobs.villager.ridable-in-water", villagerRidableInWater);
@@ -1588,6 +1589,7 @@ public class PurpurWorldConfig {
villagerMaxHealth = getDouble("mobs.villager.attributes.max_health", villagerMaxHealth);
@@ -1590,6 +1591,7 @@ public class PurpurWorldConfig {
villagerScale = Mth.clamp(getDouble("mobs.villager.attributes.scale", villagerScale), 0.0625D, 16.0D);
villagerFollowEmeraldBlock = getBoolean("mobs.villager.follow-emerald-blocks", villagerFollowEmeraldBlock);
villagerTemptRange = getDouble("mobs.villager.attributes.tempt_range", villagerTemptRange);
+ villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed);
}

public boolean vindicatorRidable = false;
@@ -1614,6 +1616,7 @@ public class PurpurWorldConfig {
public double wanderingTraderMaxHealth = 20.0D;
@@ -1617,6 +1619,7 @@ public class PurpurWorldConfig {
public double wanderingTraderScale = 1.0D;
public boolean wanderingTraderFollowEmeraldBlock = false;
public double wanderingTraderTemptRange = 10.0D;
+ public boolean wanderingTraderCanBeLeashed = false;
private void wanderingTraderSettings() {
wanderingTraderRidable = getBoolean("mobs.wandering_trader.ridable", wanderingTraderRidable);
wanderingTraderRidableInWater = getBoolean("mobs.wandering_trader.ridable-in-water", wanderingTraderRidableInWater);
@@ -1626,6 +1629,7 @@ public class PurpurWorldConfig {
wanderingTraderMaxHealth = getDouble("mobs.wandering_trader.attributes.max_health", wanderingTraderMaxHealth);
@@ -1630,6 +1633,7 @@ public class PurpurWorldConfig {
wanderingTraderScale = Mth.clamp(getDouble("mobs.wandering_trader.attributes.scale", wanderingTraderScale), 0.0625D, 16.0D);
wanderingTraderFollowEmeraldBlock = getBoolean("mobs.wandering_trader.follow-emerald-blocks", wanderingTraderFollowEmeraldBlock);
wanderingTraderTemptRange = getDouble("mobs.wandering_trader.attributes.tempt_range", wanderingTraderTemptRange);
+ wanderingTraderCanBeLeashed = getBoolean("mobs.wandering_trader.can-be-leashed", wanderingTraderCanBeLeashed);
}

Expand Down
14 changes: 7 additions & 7 deletions patches/server/0063-Configurable-jockey-options.patch
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ index ba1ce7e0ed888bd47312e9d7da5426f5c1015d07..650f9e1ca3a5ddec5123133c9604f331
public void setPersistentAngerTarget(@Nullable UUID angryAt) {
this.persistentAngerTarget = angryAt;
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a7038f8901a 100644
index 17cac265378429f1cdcc9d183cc5588660c7f92e..3f6288eff7f38e17115916521f17fa53b520ae01 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -636,6 +636,9 @@ public class PurpurWorldConfig {
Expand Down Expand Up @@ -210,7 +210,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
}

public boolean illusionerRidable = false;
@@ -1824,6 +1836,9 @@ public class PurpurWorldConfig {
@@ -1828,6 +1840,9 @@ public class PurpurWorldConfig {
public double zombieMaxHealth = 20.0D;
public double zombieScale = 1.0D;
public double zombieSpawnReinforcements = 0.1D;
Expand All @@ -220,7 +220,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
private void zombieSettings() {
zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable);
zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater);
@@ -1836,6 +1851,9 @@ public class PurpurWorldConfig {
@@ -1840,6 +1855,9 @@ public class PurpurWorldConfig {
zombieMaxHealth = getDouble("mobs.zombie.attributes.max_health", zombieMaxHealth);
zombieScale = Mth.clamp(getDouble("mobs.zombie.attributes.scale", zombieScale), 0.0625D, 16.0D);
zombieSpawnReinforcements = getDouble("mobs.zombie.attributes.spawn_reinforcements", zombieSpawnReinforcements);
Expand All @@ -230,7 +230,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
}

public boolean zombieHorseRidable = false;
@@ -1873,6 +1891,9 @@ public class PurpurWorldConfig {
@@ -1877,6 +1895,9 @@ public class PurpurWorldConfig {
public double zombieVillagerMaxHealth = 20.0D;
public double zombieVillagerScale = 1.0D;
public double zombieVillagerSpawnReinforcements = 0.1D;
Expand All @@ -240,7 +240,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
private void zombieVillagerSettings() {
zombieVillagerRidable = getBoolean("mobs.zombie_villager.ridable", zombieVillagerRidable);
zombieVillagerRidableInWater = getBoolean("mobs.zombie_villager.ridable-in-water", zombieVillagerRidableInWater);
@@ -1885,6 +1906,9 @@ public class PurpurWorldConfig {
@@ -1889,6 +1910,9 @@ public class PurpurWorldConfig {
zombieVillagerMaxHealth = getDouble("mobs.zombie_villager.attributes.max_health", zombieVillagerMaxHealth);
zombieVillagerScale = Mth.clamp(getDouble("mobs.zombie_villager.attributes.scale", zombieVillagerScale), 0.0625D, 16.0D);
zombieVillagerSpawnReinforcements = getDouble("mobs.zombie_villager.attributes.spawn_reinforcements", zombieVillagerSpawnReinforcements);
Expand All @@ -250,7 +250,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
}

public boolean zombifiedPiglinRidable = false;
@@ -1893,6 +1917,9 @@ public class PurpurWorldConfig {
@@ -1897,6 +1921,9 @@ public class PurpurWorldConfig {
public double zombifiedPiglinMaxHealth = 20.0D;
public double zombifiedPiglinScale = 1.0D;
public double zombifiedPiglinSpawnReinforcements = 0.0D;
Expand All @@ -260,7 +260,7 @@ index 0766f4cb00caac477e7ee0d537dc1f5304cd7d1a..7c1f903c41839251a69d38ba58fb4a70
private void zombifiedPiglinSettings() {
zombifiedPiglinRidable = getBoolean("mobs.zombified_piglin.ridable", zombifiedPiglinRidable);
zombifiedPiglinRidableInWater = getBoolean("mobs.zombified_piglin.ridable-in-water", zombifiedPiglinRidableInWater);
@@ -1905,5 +1932,8 @@ public class PurpurWorldConfig {
@@ -1909,5 +1936,8 @@ public class PurpurWorldConfig {
zombifiedPiglinMaxHealth = getDouble("mobs.zombified_piglin.attributes.max_health", zombifiedPiglinMaxHealth);
zombifiedPiglinScale = Mth.clamp(getDouble("mobs.zombified_piglin.attributes.scale", zombifiedPiglinScale), 0.0625D, 16.0D);
zombifiedPiglinSpawnReinforcements = getDouble("mobs.zombified_piglin.attributes.spawn_reinforcements", zombifiedPiglinSpawnReinforcements);
Expand Down
Loading