All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bukkit.craftbukkit.entity.CraftCreature Maven / Gradle / Ivy

The newest version!
package org.bukkit.craftbukkit.entity;

import net.minecraft.server.EntityCreature;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;

public class CraftCreature extends CraftLivingEntity implements Creature {
  public CraftCreature(CraftServer server, EntityCreature entity) {
    super(server, entity);
  }

  public CraftLivingEntity getTarget() {
    if (getHandle().getGoalTarget() == null) return null;

    return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity();
  }

  public void setTarget(LivingEntity target) {
    EntityCreature entity = getHandle();
    if (target == null) {
      entity.setGoalTarget(null, null, false);
    } else if (target instanceof CraftLivingEntity) {
      entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false);
    }
  }

  @Override
  public EntityCreature getHandle() {
    return (EntityCreature) entity;
  }

  @Override
  public String toString() {
    return "CraftCreature";
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy