NullValkyrie

Minecraft 1.19 multipurpose plugin for spigot servers with a lot of features where most modern servers have.
git clone https://codeberg.org/night0721/NullValkyrie
Log | Files | Refs | README | LICENSE

ZombiePet.java (1936B)


      1 package me.night.nullvalkyrie.entities.pets;
      2 
      3 import net.md_5.bungee.api.ChatColor;
      4 import net.minecraft.network.chat.Component;
      5 import net.minecraft.world.entity.EntityType;
      6 import net.minecraft.world.entity.ai.goal.FloatGoal;
      7 import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
      8 import net.minecraft.world.entity.monster.Zombie;
      9 import org.bukkit.Location;
     10 import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
     11 import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
     12 import org.bukkit.entity.Player;
     13 import org.bukkit.event.entity.EntityTargetEvent;
     14 
     15 public class ZombiePet extends Zombie {
     16     public ZombiePet(Location location, Player player) {
     17         super(EntityType.ZOMBIE, ((CraftWorld) location.getWorld()).getHandle());
     18         this.setBaby(true); // https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/monster/Zombie.html setBaby
     19         this.setInvulnerable(true);
     20         this.setPos(location.getX(), location.getY(), location.getZ()); // https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/Entity.html setPos
     21         this.setCustomName(Component.nullToEmpty(ChatColor.DARK_PURPLE + player.getName() + "'s Zombie")); //https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/Entity.html setCustomName
     22         this.setCustomNameVisible(true); // https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/Entity.html setCustomNameVisible
     23         this.setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, true); // https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/monster/Zombie.html setGoalTarget
     24     }
     25     @Override
     26     public void registerGoals() {
     27         this.goalSelector.addGoal(0, new PathFinderGoalPet(this, 1.0D, 15F));
     28         this.goalSelector.addGoal(1, new FloatGoal(this));
     29         this.goalSelector.addGoal(2, new LookAtPlayerGoal(this, net.minecraft.world.entity.player.Player.class, 8.0F));
     30     }
     31 }