1.8.8 Control a entities movement way

Discussion in 'Spigot Plugin Development' started by DekoLP, Feb 9, 2020.

  1. Hello,

    I want to make a Sheep, which moves towards a Team (its a bedwars plugin) and has TNT on it. I dont know how I can make, that the Sheep moves towards a team. Does anyone has a code for this?

  2. By using pathfinder goals targeting players with the specific team (team != spawneTeam)
  3. Im using this Pathfinder Method:
    Code (Text):
    package net.Deko.bw.api;

    import net.minecraft.server.v1_8_R3.EntityInsentient;
    import net.minecraft.server.v1_8_R3.Navigation;
    import net.minecraft.server.v1_8_R3.PathEntity;
    import net.minecraft.server.v1_8_R3.PathfinderGoal;
    import org.bukkit.Location;

    public class PathfinderWalkTO extends PathfinderGoal {

        private double speed;

        private EntityInsentient entity;

        private Location loc;

        private Navigation navigation;

        public PathfinderWalkTO(EntityInsentient entity, Location loc, double speed)
            this.entity = entity;
            this.loc = loc;
            this.navigation = (Navigation) this.entity.getNavigation();
            this.speed = speed;

        public boolean a() {
            return true;

        public void c()
            PathEntity pathEntity = this.navigation.a(loc.getX(), loc.getY(), loc.getZ());

            this.navigation.a(pathEntity, speed);
    And when using this method:
    Code (Text):
     PathfinderWalkTO path = new PathfinderWalkTO(?, p.getLocation(), 2);
    I need a EntityInsentient. I dont know what I should insert for it.
  4. You are diving into NMS.
    Code (Text):
    EntityInsentient ei = ((CraftCreature)creature).getHandle()
    The Creature is your sheep.
  5. Ok and how can I now "say" the mob, that it should target a specific team?
    Code (Text):
    import net.minecraft.server.v1_8_R3.EntityInsentient;
    import org.bukkit.Bukkit;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
    import org.bukkit.entity.*;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.EntityExplodeEvent;
    import org.bukkit.event.entity.EntityTargetEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.util.Vector;

    import java.util.ArrayList;

    public class TNT_Sheep implements Listener {

        public void onInteract(final PlayerInteractEvent e) {
            final Player p = e.getPlayer();
            if ((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && p.getItemInHand().getType() == Material.MONSTER_EGG) {
                if (p.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("§7Mediteys TNT-Schaf")) {
                    if (p.getItemInHand().getAmount() == 1) {
                    p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
                    final Sheep s = (Sheep) Bukkit.getWorld(p.getWorld().getName()).spawnCreature(p.getLocation(), CreatureType.SHEEP);
                    s.setCustomName("§7Mediteys §4TNT-Schaf");
                    EntityInsentient ei = ((CraftCreature)s).getHandle();
                    PathfinderWalkTO path = new PathfinderWalkTO(ei, p.getLocation(), 2);
                    final Entity tnt = s.getWorld().spawn(s.getLocation(), (Class) TNTPrimed.class);
                    Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) Main.getInstance(), (Runnable) new Runnable() {
                        public void run() {
                    }, 100L);
                else {

        public void onExplode(final EntityExplodeEvent e) {
            if (e.getEntity().getType() == EntityType.PRIMED_TNT && Material.RED_SANDSTONE != null) {