Create an entity by instantiating it with an EntityType:
import net.minestom.server.entity.Entity;import net.minestom.server.entity.EntityType;import net.minestom.server.coordinate.Pos;// Create a zombie entityEntity zombie = new Entity(EntityType.ZOMBIE);// Create a living entity with healthLivingEntity ghast = new LivingEntity(EntityType.HAPPY_GHAST);ghast.setNoGravity(true);
// Spawn entity in player's instancePlayer player = event.getPlayer();Instance instance = player.getInstance();// Create and spawn a copper golemLivingEntity copperGolem = new LivingEntity(EntityType.COPPER_GOLEM);copperGolem.setNoGravity(true);copperGolem.setItemInMainHand(ItemStack.of(Material.STICK));// Set metadataCopperGolemMeta meta = (CopperGolemMeta) copperGolem.getEntityMeta();meta.setState(CopperGolemMeta.State.GETTING_ITEM);// Spawn at positionPos spawnPos = new Pos(-10, 40, 5, -133, 0);copperGolem.setInstance(instance, spawnPos);
// Set items in handentity.setItemInMainHand(ItemStack.of(Material.DIAMOND_SWORD));entity.setItemInOffHand(ItemStack.of(Material.SHIELD));// Set armorLivingEntity living = (LivingEntity) entity;living.setHelmet(ItemStack.of(Material.DIAMOND_HELMET));living.setChestplate(ItemStack.of(Material.DIAMOND_CHESTPLATE));living.setLeggings(ItemStack.of(Material.DIAMOND_LEGGINGS));living.setBoots(ItemStack.of(Material.DIAMOND_BOOTS));// Set body equipmentliving.setBodyEquipment(ItemStack.of(Material.GREEN_HARNESS));
EntityCreature creature = new EntityCreature(EntityType.ZOMBIE);// Set target entitycreature.setTarget(player);// Get current targetEntity target = creature.getTarget();
EntityCreature creature = new EntityCreature(EntityType.ZOMBIE);// Create AI groupEntityAIGroup aiGroup = new EntityAIGroup();// Add goals (executed in order of priority)aiGroup.getGoalSelectors().add(new MeleeAttackGoal(creature, 1.2, 20, TimeUnit.SERVER_TICK));aiGroup.getGoalSelectors().add(new RandomStrollGoal(creature, 15));creature.addAIGroup(aiGroup);