mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
#1047: Support setting individual Wither head targets
By: Yannick Lamprecht <yannicklamprecht@live.de>
This commit is contained in:
parent
5e503c9e28
commit
3bd1e295ea
1 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue