13
0
geforkt von Mirrors/Paper

net.minecraft.world.entity.monster.warden

Dieser Commit ist enthalten in:
Jake Potrebic 2024-12-13 16:08:40 -08:00
Ursprung f98d879f07
Commit cb5feced53
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
4 geänderte Dateien mit 38 neuen und 70 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,11 @@
--- a/net/minecraft/world/entity/monster/warden/AngerManagement.java
+++ b/net/minecraft/world/entity/monster/warden/AngerManagement.java
@@ -146,7 +_,7 @@
public int increaseAnger(Entity entity, int offset) {
boolean flag = !this.angerBySuspect.containsKey(entity);
- int i = this.angerBySuspect.computeInt(entity, (entity1, integer) -> Math.min(150, (integer == null ? 0 : integer) + offset));
+ int i = this.angerBySuspect.computeInt(entity, (entity1, integer) -> Math.min(150, (integer == null ? 0 : integer) + offset)); // Paper - diff on change (Warden#increaseAngerAt WardenAngerChangeEvent)
if (flag) {
int i1 = this.angerByUuid.removeInt(entity.getUUID());
i += i1;

Datei anzeigen

@ -0,0 +1,27 @@
--- a/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
@@ -407,7 +_,7 @@
public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) {
MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false);
- MobEffectUtil.addEffectToPlayersAround(level, source, pos, radius, mobEffectInstance, 200);
+ MobEffectUtil.addEffectToPlayersAround(level, source, pos, radius, mobEffectInstance, 200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WARDEN); // CraftBukkit - Add EntityPotionEffectEvent.Cause
}
@Override
@@ -469,6 +_,15 @@
@VisibleForTesting
public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) {
if (!this.isNoAi() && this.canTargetEntity(entity)) {
+ // Paper start - Add WardenAngerChangeEvent
+ int activeAnger = this.angerManagement.getActiveAnger(entity);
+ io.papermc.paper.event.entity.WardenAngerChangeEvent event = new io.papermc.paper.event.entity.WardenAngerChangeEvent((org.bukkit.entity.Warden) this.getBukkitEntity(), entity.getBukkitEntity(), activeAnger, Math.min(150, activeAnger + offset));
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ offset = event.getNewAnger() - activeAnger;
+ // Paper end - Add WardenAngerChangeEvent
WardenAi.setDigCooldown(this);
boolean flag = !(this.getTarget() instanceof Player);
int i = this.angerManagement.increaseAnger(entity, offset);

Datei anzeigen

@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/monster/warden/AngerManagement.java
+++ b/net/minecraft/world/entity/monster/warden/AngerManagement.java
@@ -146,7 +146,7 @@
public int increaseAnger(Entity entity, int amount) {
boolean bl = !this.angerBySuspect.containsKey(entity);
- int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount));
+ int i = this.angerBySuspect.computeInt(entity, (suspect, anger) -> Math.min(150, (anger == null ? 0 : anger) + amount)); // Paper - diff on change (Warden#increaseAngerAt WardenAngerChangeEvent)
if (bl) {
int j = this.angerByUuid.removeInt(entity.getUUID());
i += j;

Datei anzeigen

@ -1,59 +0,0 @@
--- a/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
@@ -375,7 +375,7 @@
@Override
public Brain<Warden> getBrain() {
- return super.getBrain();
+ return (Brain<Warden>) super.getBrain(); // CraftBukkit - decompile error
}
@Override
@@ -412,7 +412,7 @@
public static void applyDarknessAround(ServerLevel world, Vec3 pos, @Nullable Entity entity, int range) {
MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false);
- MobEffectUtil.addEffectToPlayersAround(world, entity, pos, (double) range, mobeffect, 200);
+ MobEffectUtil.addEffectToPlayersAround(world, entity, pos, range, mobeffect, 200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WARDEN); // CraftBukkit - Add EntityPotionEffectEvent.Cause
}
@Override
@@ -482,6 +482,15 @@
@VisibleForTesting
public void increaseAngerAt(@Nullable Entity entity, int amount, boolean listening) {
if (!this.isNoAi() && this.canTargetEntity(entity)) {
+ // Paper start - Add WardenAngerChangeEvent
+ int activeAnger = this.angerManagement.getActiveAnger(entity);
+ io.papermc.paper.event.entity.WardenAngerChangeEvent event = new io.papermc.paper.event.entity.WardenAngerChangeEvent((org.bukkit.entity.Warden) this.getBukkitEntity(), entity.getBukkitEntity(), activeAnger, Math.min(150, activeAnger + amount));
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ amount = event.getNewAnger() - activeAnger;
+ // Paper end - Add WardenAngerChangeEvent
WardenAi.setDigCooldown(this);
boolean flag1 = !(this.getTarget() instanceof Player);
int j = this.angerManagement.increaseAnger(entity, amount);
@@ -547,7 +556,7 @@
public void setAttackTarget(LivingEntity target) {
this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET);
- this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) target);
+ this.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, target); // CraftBukkit - decompile error
this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
SonicBoom.setCooldown(this, 200);
}
@@ -582,11 +591,11 @@
@Override
protected PathNavigation createNavigation(Level world) {
- return new GroundPathNavigation(this, this, world) {
+ return new GroundPathNavigation(this, world) { // CraftBukkit - decompile error
@Override
protected PathFinder createPathFinder(int range) {
this.nodeEvaluator = new WalkNodeEvaluator();
- return new PathFinder(this, this.nodeEvaluator, range) {
+ return new PathFinder(this.nodeEvaluator, range) { // CraftBukkit - decompile error
@Override
protected float distance(Node a, Node b) {
return a.distanceToXZ(b);