13
0
geforkt von Mirrors/Paper

#1047: Support setting individual Wither head targets

By: Yannick Lamprecht <yannicklamprecht@live.de>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2022-05-17 19:27:01 +10:00
Ursprung 5e503c9e28
Commit 3bd1e295ea

Datei anzeigen

@ -1,10 +1,13 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.boss.wither.EntityWither;
import org.bukkit.boss.BossBar;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.boss.CraftBossBar;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Wither;
public class CraftWither extends CraftMonster implements Wither {
@ -38,4 +41,24 @@ public class CraftWither extends CraftMonster implements Wither {
public BossBar getBossBar() {
return bossBar;
}
@Override
public void setTarget(Head head, LivingEntity livingEntity) {
Preconditions.checkArgument(head != null, "head cannot be null");
int entityId = (livingEntity != null) ? livingEntity.getEntityId() : 0;
getHandle().setAlternativeTarget(head.ordinal(), entityId);
}
@Override
public LivingEntity getTarget(Head head) {
Preconditions.checkArgument(head != null, "head cannot be null");
int entityId = getHandle().getAlternativeTarget(head.ordinal());
if (entityId == 0) {
return null;
}
Entity target = getHandle().getLevel().getEntity(entityId);
return (target != null) ? (LivingEntity) target.getBukkitEntity() : null;
}
}