mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +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.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
@@ -40,6 +41,10 @@ public class BossEntityUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id.equalsIgnoreCase("charged_creeper")) {
|
||||||
|
return new VanillaBossType(Creeper.class, true);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
|
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) EntityType.valueOf(id.toUpperCase()).getEntityClass();
|
||||||
assert type != null;
|
assert type != null;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
package com.willfp.ecobosses.bosses.util.bosstype;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -12,6 +13,11 @@ class VanillaBossType extends BossType {
|
|||||||
*/
|
*/
|
||||||
private final Class<? extends LivingEntity> entityClass;
|
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.
|
* Create new vanilla boss type.
|
||||||
*
|
*
|
||||||
@@ -19,10 +25,24 @@ class VanillaBossType extends BossType {
|
|||||||
*/
|
*/
|
||||||
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass) {
|
VanillaBossType(@NotNull final Class<? extends LivingEntity> entityClass) {
|
||||||
this.entityClass = 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
|
@Override
|
||||||
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
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