-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
581 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...s/minecraft/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java | ||
@@ -8,6 +_,9 @@ | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.npc.Villager; | ||
import net.minecraft.world.entity.npc.VillagerProfession; | ||
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftVillager; | ||
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory; | ||
+import org.bukkit.event.entity.VillagerCareerChangeEvent; | ||
|
||
public class AssignProfessionFromJobSite { | ||
public static BehaviorControl<Villager> create() { | ||
@@ -32,7 +_,14 @@ | ||
return p_217125_.heldJobSite().test(p_258313_); | ||
}).findFirst(); | ||
}).ifPresent((p_22464_) -> { | ||
- p_258310_.setVillagerData(p_258310_.getVillagerData().setProfession(p_22464_)); | ||
+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed | ||
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(p_258310_, CraftVillager.CraftProfession.minecraftToBukkit(p_22464_), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); | ||
+ if (event.isCancelled()) { | ||
+ return; | ||
+ } | ||
+ | ||
+ p_258310_.setVillagerData(p_258310_.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); | ||
+ // CraftBukkit end | ||
p_258310_.refreshBrain(p_258309_); | ||
}); | ||
return true; |
36 changes: 36 additions & 0 deletions
36
patches/minecraft/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/BabyFollowAdult.java | ||
@@ -7,6 +_,10 @@ | ||
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder; | ||
import net.minecraft.world.entity.ai.memory.MemoryModuleType; | ||
import net.minecraft.world.entity.ai.memory.WalkTarget; | ||
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftLivingEntity; | ||
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory; | ||
+import org.bukkit.event.entity.EntityTargetEvent; | ||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; | ||
|
||
public class BabyFollowAdult { | ||
public static OneShot<AgeableMob> create(UniformInt p_260109_, float p_259621_) { | ||
@@ -22,9 +_,21 @@ | ||
if (!p_258327_.isBaby()) { | ||
return false; | ||
} else { | ||
- AgeableMob ageablemob = p_258331_.get(p_258317_); | ||
+ LivingEntity ageablemob = p_258331_.get(p_258317_); // CraftBukkit - type | ||
if (p_258327_.closerThan(ageablemob, (double)(p_259321_.getMaxValue() + 1)) && !p_258327_.closerThan(ageablemob, (double)p_259321_.getMinValue())) { | ||
+ // CraftBukkit start | ||
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(p_258327_, ageablemob, EntityTargetEvent.TargetReason.FOLLOW_LEADER); | ||
+ if (event.isCancelled()) { | ||
+ return false; | ||
+ } | ||
+ if (event.getTarget() == null) { | ||
+ p_258317_.erase(); | ||
+ return true; | ||
+ } | ||
+ ageablemob = ((CraftLivingEntity) event.getTarget()).getHandle(); | ||
+ // CraftBukkit end | ||
WalkTarget walktarget = new WalkTarget(new EntityTracker(ageablemob, false), p_259190_.apply(p_258327_), p_259321_.getMinValue() - 1); | ||
+ | ||
p_258318_.set(new EntityTracker(ageablemob, true)); | ||
p_258319_.set(walktarget); | ||
return true; |
24 changes: 24 additions & 0 deletions
24
patches/minecraft/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java | ||
@@ -86,6 +_,7 @@ | ||
} | ||
|
||
public static void throwItem(LivingEntity p_217134_, ItemStack p_217135_, Vec3 p_217136_, Vec3 p_217137_, float p_217138_) { | ||
+ if (p_217135_.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot | ||
double d0 = p_217134_.getEyeY() - (double)p_217138_; | ||
ItemEntity itementity = new ItemEntity(p_217134_.level(), p_217134_.getX(), d0, p_217134_.getZ(), p_217135_); | ||
itementity.setThrower(p_217134_.getUUID()); | ||
@@ -93,6 +_,13 @@ | ||
vec3 = vec3.normalize().multiply(p_217137_.x, p_217137_.y, p_217137_.z); | ||
itementity.setDeltaMovement(vec3); | ||
itementity.setDefaultPickUpDelay(); | ||
+ // CraftBukkit start | ||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(p_217134_.getBukkitEntity(), (org.bukkit.entity.Item) itementity.getBukkitEntity()); | ||
+ p_217134_.level().getCraftServer().getPluginManager().callEvent(event); | ||
+ if (event.isCancelled()) { | ||
+ return; | ||
+ } | ||
+ // CraftBukkit end | ||
p_217134_.level().addFreshEntity(itementity); | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
patches/minecraft/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/GoToWantedItem.java | ||
@@ -23,7 +_,22 @@ | ||
return (p_258380_, p_258381_, p_258382_) -> { | ||
ItemEntity itementity = p_258371_.get(p_258389_); | ||
if (p_258371_.tryGet(p_258390_).isEmpty() && p_259490_.test(p_258381_) && itementity.closerThan(p_258381_, (double)p_259054_) && p_258381_.level().getWorldBorder().isWithinBounds(itementity.blockPosition())) { | ||
+ // CraftBukkit start | ||
+ if (p_258381_ instanceof net.minecraft.world.entity.animal.allay.Allay) { | ||
+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callEntityTargetEvent(p_258381_, itementity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); | ||
+ | ||
+ if (event.isCancelled()) { | ||
+ return false; | ||
+ } | ||
+ if (!(event.getTarget() instanceof ItemEntity)) { | ||
+ p_258389_.erase(); | ||
+ } | ||
+ | ||
+ itementity = (ItemEntity) ((org.bukkit.craftbukkit.v1_20_R2.entity.CraftEntity) event.getTarget()).getHandle(); | ||
+ } | ||
+ // CraftBukkit end | ||
WalkTarget walktarget = new WalkTarget(new EntityTracker(itementity, false), p_260346_, 0); | ||
+ | ||
p_258387_.set(new EntityTracker(itementity, true)); | ||
p_258388_.set(walktarget); | ||
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
patches/minecraft/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/InteractWithDoor.java | ||
@@ -54,6 +_,13 @@ | ||
})) { | ||
DoorBlock doorblock = (DoorBlock)blockstate.getBlock(); | ||
if (!doorblock.isOpen(blockstate)) { | ||
+ // CraftBukkit start - entities opening doors | ||
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_258470_.getBukkitEntity(), org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock.at(p_258470_.level(), blockpos)); | ||
+ p_258470_.level().getCraftServer().getPluginManager().callEvent(event); | ||
+ if (event.isCancelled()) { | ||
+ return false; | ||
+ } | ||
+ // CraftBukkit end | ||
doorblock.setOpen(p_258470_, p_258469_, blockstate, blockpos, true); | ||
} | ||
|
||
@@ -67,6 +_,13 @@ | ||
})) { | ||
DoorBlock doorblock1 = (DoorBlock)blockstate1.getBlock(); | ||
if (!doorblock1.isOpen(blockstate1)) { | ||
+ // CraftBukkit start - entities opening doors | ||
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(p_258470_.getBukkitEntity(), org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock.at(p_258470_.level(), blockpos1)); | ||
+ p_258470_.level().getCraftServer().getPluginManager().callEvent(event); | ||
+ if (event.isCancelled()) { | ||
+ return false; | ||
+ } | ||
+ // CraftBukkit end | ||
doorblock1.setOpen(p_258470_, p_258469_, blockstate1, blockpos1, true); | ||
optional = rememberDoorToClose(p_258461_, optional, p_258469_, blockpos1); | ||
} |
34 changes: 34 additions & 0 deletions
34
patches/minecraft/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java | ||
@@ -10,6 +_,7 @@ | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.server.level.ServerLevel; | ||
+import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.util.Mth; | ||
@@ -25,6 +_,9 @@ | ||
import net.minecraft.world.level.pathfinder.Path; | ||
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; | ||
import net.minecraft.world.phys.Vec3; | ||
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftLivingEntity; | ||
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory; | ||
+import org.bukkit.event.entity.EntityTargetEvent; | ||
|
||
public class PrepareRamNearestTarget<E extends PathfinderMob> extends Behavior<E> { | ||
public static final int TIME_OUT_DURATION = 160; | ||
@@ -56,6 +_,13 @@ | ||
return this.ramTargeting.test(p_147737_, p_147789_); | ||
}); | ||
}).ifPresent((p_147778_) -> { | ||
+ // CraftBukkit start | ||
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(p_147737_, p_147778_, (p_147778_ instanceof ServerPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY); | ||
+ if (event.isCancelled() || event.getTarget() == null) { | ||
+ return; | ||
+ } | ||
+ p_147778_ = ((CraftLivingEntity) event.getTarget()).getHandle(); | ||
+ // CraftBukkit end | ||
this.chooseRamPosition(p_147737_, p_147778_); | ||
}); | ||
} |
28 changes: 28 additions & 0 deletions
28
patches/minecraft/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- a/net/minecraft/world/entity/ai/behavior/ResetProfession.java | ||
+++ b/net/minecraft/world/entity/ai/behavior/ResetProfession.java | ||
@@ -5,6 +_,9 @@ | ||
import net.minecraft.world.entity.npc.Villager; | ||
import net.minecraft.world.entity.npc.VillagerData; | ||
import net.minecraft.world.entity.npc.VillagerProfession; | ||
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftVillager; | ||
+import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory; | ||
+import org.bukkit.event.entity.VillagerCareerChangeEvent; | ||
|
||
public class ResetProfession { | ||
public static BehaviorControl<Villager> create() { | ||
@@ -13,7 +_,14 @@ | ||
return (p_260244_, p_260084_, p_259597_) -> { | ||
VillagerData villagerdata = p_260084_.getVillagerData(); | ||
if (villagerdata.getProfession() != VillagerProfession.NONE && villagerdata.getProfession() != VillagerProfession.NITWIT && p_260084_.getVillagerXp() == 0 && villagerdata.getLevel() <= 1) { | ||
- p_260084_.setVillagerData(p_260084_.getVillagerData().setProfession(VillagerProfession.NONE)); | ||
+ // CraftBukkit start | ||
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(p_260084_, CraftVillager.CraftProfession.minecraftToBukkit(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); | ||
+ if (event.isCancelled()) { | ||
+ return false; | ||
+ } | ||
+ | ||
+ p_260084_.setVillagerData(p_260084_.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); | ||
+ // CraftBukkit end | ||
p_260084_.refreshBrain(p_260244_); | ||
return true; | ||
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.