SPIGOT-7957: Fix setTarget method for Breeze

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot 2024-11-17 11:22:36 +11:00
parent ac56ea8d83
commit c7707ece4c
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/world/entity/monster/breeze/Breeze.java
+++ b/net/minecraft/world/entity/monster/breeze/Breeze.java
@@ -77,7 +77,7 @@
@Override
public BehaviorController<Breeze> getBrain() {
- return super.getBrain();
+ return (BehaviorController<Breeze>) super.getBrain(); // CraftBukkit - decompile error
}
@Override
@@ -255,6 +255,7 @@
@Override
public boolean canAttackType(EntityTypes<?> entitytypes) {
+ if (this.getTarget() != null) return this.getTarget().getType() == entitytypes; // SPIGOT-7957: Allow attack if target from brain was set
return entitytypes == EntityTypes.PLAYER || entitytypes == EntityTypes.IRON_GOLEM;
}

View file

@ -1,7 +1,10 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Breeze;
import org.bukkit.entity.LivingEntity;
public class CraftBreeze extends CraftMonster implements Breeze {
@ -14,6 +17,13 @@ public class CraftBreeze extends CraftMonster implements Breeze {
return (net.minecraft.world.entity.monster.breeze.Breeze) entity;
}
@Override
public void setTarget(LivingEntity target) {
super.setTarget(target);
EntityLiving entityLivingTarget = (target instanceof CraftLivingEntity craftLivingEntity) ? craftLivingEntity.getHandle() : null;
this.getHandle().getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, entityLivingTarget); // SPIGOT-7957: We need override memory for set target and trigger attack behaviours
}
@Override
public String toString() {
return "CraftBreeze";