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: PaperMC/Paper@ffcb7b22 Update Parchment (#13177) PaperMC/Paper@c33a9ce1 Fix incorrect variable use in Entity#startRiding PaperMC/Paper@c710b667 Add MapPalette.getNearestColor (#13104) PaperMC/Paper@b57d6410 Expose isReplaceable on BlockData (#13180) PaperMC/Paper@af1823d4 Reduce impact of tick time calculations (#13188) PaperMC/Paper@89ca94ab [ci/skip] Rebuild patches PaperMC/Paper@e5cc2560 [ci/skip] Update CONTRIBUTING.md for Gradle and Windows Docs (#13190) PaperMC/Paper@ab99393c Fix charged creeper explosions not dropping mob skulls (#13167) PaperMC/Paper@81b7a578 Fixed Ender Dragon using wrong tracking range (#13046)
103 lines
7.1 KiB
Diff
103 lines
7.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Fri, 29 Nov 2019 22:10:12 -0600
|
|
Subject: [PATCH] Villagers follow emerald blocks
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
|
|
index d9aefe5777fa545d67621bc1ce2ef6a11ca9b27c..48be4530b25d273032ff1a055406c7cca928d678 100644
|
|
--- a/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
|
|
+++ b/net/minecraft/world/entity/ai/attributes/DefaultAttributes.java
|
|
@@ -167,7 +167,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 - Villagers follow emerald blocks
|
|
.put(EntityType.WITCH, Witch.createAttributes().build())
|
|
.put(EntityType.WITHER, WitherBoss.createAttributes().build())
|
|
.put(EntityType.WITHER_SKELETON, AbstractSkeleton.createAttributes().build())
|
|
diff --git a/net/minecraft/world/entity/ai/goal/TemptGoal.java b/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
|
index dae935cc68e2e571d50e56ac8913c099a11cf771..a805c9426630c2c46db9d0dd536f1d16769395d3 100644
|
|
--- a/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
|
+++ b/net/minecraft/world/entity/ai/goal/TemptGoal.java
|
|
@@ -71,7 +71,7 @@ public class TemptGoal extends Goal {
|
|
}
|
|
|
|
private boolean shouldFollow(LivingEntity entity) {
|
|
- return this.items.test(entity.getMainHandItem()) || this.items.test(entity.getOffhandItem());
|
|
+ return (this.items.test(entity.getMainHandItem()) || this.items.test(entity.getOffhandItem())) && (!(this.mob instanceof net.minecraft.world.entity.npc.Villager villager) || !villager.isSleeping()); // Purpur - Villagers follow emerald blocks
|
|
}
|
|
|
|
@Override
|
|
diff --git a/net/minecraft/world/entity/npc/AbstractVillager.java b/net/minecraft/world/entity/npc/AbstractVillager.java
|
|
index 6bb17ecbd93f6ced5436cf75f3695f44eedd4bd9..e60387c4ef2aa0fc35a559d75b1a7c1539dda57b 100644
|
|
--- a/net/minecraft/world/entity/npc/AbstractVillager.java
|
|
+++ b/net/minecraft/world/entity/npc/AbstractVillager.java
|
|
@@ -35,6 +35,7 @@ import net.minecraft.world.level.storage.ValueOutput;
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
public abstract class AbstractVillager extends AgeableMob implements InventoryCarrier, Npc, Merchant {
|
|
+ static final net.minecraft.world.item.crafting.Ingredient TEMPT_ITEMS = net.minecraft.world.item.crafting.Ingredient.of(net.minecraft.world.level.block.Blocks.EMERALD_BLOCK.asItem()); // Purpur - Villagers follow emerald blocks
|
|
private static final EntityDataAccessor<Integer> DATA_UNHAPPY_COUNTER = SynchedEntityData.defineId(AbstractVillager.class, EntityDataSerializers.INT);
|
|
public static final int VILLAGER_SLOT_OFFSET = 300;
|
|
private static final int VILLAGER_INVENTORY_SIZE = 8;
|
|
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
|
index 05d748a7de077694b1035d3e73f35f1f98419902..b7b290e9870f8f51af7e44f71b1e04ce9c552626 100644
|
|
--- a/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -268,6 +268,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 - Villagers follow emerald blocks
|
|
}
|
|
// Purpur end - Ridables
|
|
|
|
@@ -276,6 +277,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 - Villagers follow emerald blocks
|
|
}
|
|
// Purpur end - Configurable entity base attributes
|
|
|
|
@@ -344,7 +346,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
|
|
public static AttributeSupplier.Builder createAttributes() {
|
|
- return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.5);
|
|
+ return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.5).add(Attributes.TEMPT_RANGE, 10.0D); // Purpur - Villagers follow emerald blocks
|
|
}
|
|
|
|
public boolean assignProfessionWhenSpawned() {
|
|
diff --git a/net/minecraft/world/entity/npc/WanderingTrader.java b/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
index b06ea793e0008c68d85d8112415fbc011131984d..e5a6cc63d29be742be039053c39f983ed9c6a1e1 100644
|
|
--- a/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
+++ b/net/minecraft/world/entity/npc/WanderingTrader.java
|
|
@@ -88,9 +88,16 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
|
@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 - Villagers follow emerald blocks
|
|
}
|
|
// Purpur end - Configurable entity base attributes
|
|
|
|
+ // Purpur start - Villagers follow emerald blocks
|
|
+ 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 - Villagers follow emerald blocks
|
|
+
|
|
@Override
|
|
protected void registerGoals() {
|
|
this.goalSelector.addGoal(0, new FloatGoal(this));
|
|
@@ -125,6 +132,7 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over
|
|
this.goalSelector.addGoal(1, new PanicGoal(this, 0.5));
|
|
this.goalSelector.addGoal(1, new LookAtTradingPlayerGoal(this));
|
|
this.goalSelector.addGoal(2, new WanderingTrader.WanderToPositionGoal(this, 2.0, 0.35));
|
|
+ if (level().purpurConfig.wanderingTraderFollowEmeraldBlock) this.goalSelector.addGoal(3, new net.minecraft.world.entity.ai.goal.TemptGoal(this, 1.0D, TEMPT_ITEMS, false)); // Purpur - Villagers follow emerald blocks
|
|
this.goalSelector.addGoal(4, new MoveTowardsRestrictionGoal(this, 0.35));
|
|
this.goalSelector.addGoal(8, new WaterAvoidingRandomStrollGoal(this, 0.35));
|
|
this.goalSelector.addGoal(9, new InteractGoal(this, Player.class, 3.0F, 1.0F));
|