2019-05-26 03:58:11 +02:00
|
|
|
--- a/net/minecraft/server/BehaviorCareer.java
|
|
|
|
+++ b/net/minecraft/server/BehaviorCareer.java
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -2,6 +2,11 @@
|
2019-05-26 03:58:11 +02:00
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
2020-06-25 02:00:00 +02:00
|
|
|
import java.util.Optional;
|
2019-05-26 03:58:11 +02:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
|
|
|
|
public class BehaviorCareer extends Behavior<EntityVillager> {
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -19,7 +24,7 @@
|
|
|
|
GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get();
|
|
|
|
|
|
|
|
entityvillager.getBehaviorController().removeMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
|
|
|
|
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos);
|
|
|
|
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error
|
|
|
|
if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) {
|
|
|
|
MinecraftServer minecraftserver = worldserver.getMinecraftServer();
|
|
|
|
|
|
|
|
@@ -30,7 +35,14 @@
|
|
|
|
return villagerprofession.b() == villageplacetype;
|
|
|
|
}).findFirst();
|
|
|
|
}).ifPresent((villagerprofession) -> {
|
2019-05-26 03:58:11 +02:00
|
|
|
- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(villagerprofession));
|
|
|
|
+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed
|
|
|
|
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED);
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession())));
|
|
|
|
+ // CraftBukkit end
|
2020-06-25 02:00:00 +02:00
|
|
|
entityvillager.b(worldserver);
|
2019-05-26 03:58:11 +02:00
|
|
|
});
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|