spawn entities
This commit is contained in:
parent
734936d882
commit
0f49aaf119
1 changed files with 22 additions and 1 deletions
|
@ -14,6 +14,7 @@ import me.unurled.sacredrealms.sr.components.player.PotionEffectDeserializer;
|
||||||
import me.unurled.sacredrealms.sr.data.DataHandler;
|
import me.unurled.sacredrealms.sr.data.DataHandler;
|
||||||
import me.unurled.sacredrealms.sr.data.DataManager;
|
import me.unurled.sacredrealms.sr.data.DataManager;
|
||||||
import me.unurled.sacredrealms.sr.managers.Manager;
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Mob;
|
import org.bukkit.entity.Mob;
|
||||||
|
@ -123,9 +124,29 @@ public class EntityManager extends Manager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnEntity(
|
public List<SREntity> spawnEntity(
|
||||||
@NotNull SREntityType type, int amount, double x, double y, double z, @NotNull World world) {
|
@NotNull SREntityType type, int amount, double x, double y, double z, @NotNull World world) {
|
||||||
// spawn entity
|
// spawn entity
|
||||||
|
List<SREntity> srEntities = new ArrayList<>();
|
||||||
|
for (int i = 0; i < amount; i++) {
|
||||||
|
Entity e = world.spawnEntity(new Location(world, x, y, z), type.getType());
|
||||||
|
if (e instanceof Mob mob) {
|
||||||
|
if (type.getItem() != null) {
|
||||||
|
mob.getEquipment().setItemInMainHand(type.getItem());
|
||||||
|
}
|
||||||
|
if (!type.getArmor().isEmpty()) {
|
||||||
|
mob.getEquipment().setArmorContents(type.getArmor().toArray(new ItemStack[0]));
|
||||||
|
}
|
||||||
|
if (type.getSecondHandItem() != null) {
|
||||||
|
mob.getEquipment().setItemInOffHand(type.getSecondHandItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SREntity srEntity = new SREntity(e);
|
||||||
|
addEntity(srEntity);
|
||||||
|
srEntities.add(srEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return srEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue