mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 16:09:24 +00:00
Added ability to use "charged_creeper" as 'base-mob:' or in 'summon:' effect to spawn charged creepers
This commit is contained in:
@@ -5,6 +5,7 @@ import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Zombie;
|
||||
@@ -40,6 +41,10 @@ public class BossEntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (id.equalsIgnoreCase("charged_creeper")) {
|
||||
return new VanillaBossType(Creeper.class, true);
|
||||
}
|
||||
|
||||
try {
|
||||
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
|
||||
assert type != null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -12,6 +13,11 @@ class VanillaBossType extends BossType {
|
||||
*/
|
||||
private final Class<? extends LivingEntity> entityClass;
|
||||
|
||||
/**
|
||||
* If the entity is Creeper and should or should not be charged.
|
||||
*/
|
||||
private final boolean creeperCharged;
|
||||
|
||||
/**
|
||||
* Create new vanilla boss type.
|
||||
*
|
||||
@@ -19,10 +25,24 @@ class VanillaBossType extends BossType {
|
||||
*/
|
||||
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
this.creeperCharged = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new vanilla boss type.
|
||||
*
|
||||
* @param entityClass The entity class.
|
||||
* @param creeperCharged The creeper power state.
|
||||
*/
|
||||
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass, boolean creeperCharged) {
|
||||
this.entityClass = entityClass;
|
||||
this.creeperCharged = creeperCharged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
||||
return Objects.requireNonNull(location.getWorld()).spawn(location, entityClass);
|
||||
LivingEntity result = Objects.requireNonNull(location.getWorld()).spawn(location, entityClass);
|
||||
if (result instanceof Creeper creeper && creeperCharged) creeper.setPowered(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user