use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class EntityTracker method unregisterEliteEntity.
public static void unregisterEliteEntity(Entity entity, RemovalReason removalReason) {
EliteEntity eliteEntity = getEliteMobEntity(entity);
if (eliteEntity == null)
return;
// Removal from the hashmap is not guaranteed here as some forms of removal don't completely wipe the elite entity out
eliteEntity.remove(removalReason);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class Explosion method generateExplosion.
private static void generateExplosion(List<Block> blockList, Entity entity, ElitePower elitePower, Location explosionSource) {
if (!DefaultConfig.isDoExplosionRegen())
return;
if (EliteMobs.worldGuardIsEnabled && explosionSource != null && !WorldGuardFlagChecker.doExplosionRegenFlag(explosionSource))
return;
ArrayList<BlockState> blockStates = new ArrayList<>();
for (Block block : blockList) {
if (block.getType().isAir() || block.getType().equals(Material.FIRE) || block.isLiquid() || EntityTracker.isTemporaryBlock(block))
continue;
nearbyBlockScan(blockStates, block.getState());
}
Entity shooter = EntityFinder.filterRangedDamagers(entity);
EliteEntity eliteEntity = null;
if (shooter != null)
eliteEntity = EntityTracker.getEliteMobEntity(shooter);
EliteExplosionEvent eliteExplosionEvent = null;
// for projectiles
if (entity instanceof Projectile) {
eliteExplosionEvent = new EliteExplosionEvent(eliteEntity, elitePower = ElitePower.getElitePower(EliteProjectile.readExplosivePower((Projectile) entity)), entity.getLocation(), blockStates);
} else {
eliteExplosionEvent = new EliteExplosionEvent(eliteEntity, elitePower, entity.getLocation(), blockStates);
}
if (eliteExplosionEvent.isCancelled())
return;
if (explosionSource != null)
eliteExplosionEvent.setExplosionSourceLocation(explosionSource);
eliteExplosionEvent.visualExplosionEffect(elitePower);
for (BlockState blockState : blockStates) {
blockState.getBlock().setType(Material.AIR);
blockState.getBlock().getState().update(true);
}
new Explosion(blockStates);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class VisualEffectObfuscator method onDamageByPlayer.
@EventHandler
public void onDamageByPlayer(EntityDamageByEntityEvent event) {
if (!(EntityFinder.getRealDamager(event) instanceof Player))
return;
EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(event.getEntity());
if (eliteEntity == null)
return;
eliteEntity.setVisualEffectObfuscated(false);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class EntityTracker method wipeShutdown.
public static void wipeShutdown() {
for (EliteEntity eliteEntity : ((HashMap<UUID, EliteEntity>) eliteMobEntities.clone()).values()) eliteEntity.remove(RemovalReason.SHUTDOWN);
getEliteMobEntities().clear();
for (NPCEntity npcEntity : ((HashMap<UUID, NPCEntity>) npcEntities.clone()).values()) npcEntity.remove(RemovalReason.SHUTDOWN);
getNpcEntities().clear();
for (Block block : temporaryBlocks) block.setType(Material.AIR);
temporaryBlocks.clear();
// Necessary for things such as visual effects which are not stored in memory, only tagged
for (World world : Bukkit.getWorlds()) for (Entity entity : world.getEntities()) unregister(entity, RemovalReason.SHUTDOWN);
SimplePersistentEntity.getPersistentEntities().clear();
CustomBossEntity.getTrackableCustomBosses().clear();
CrashFix.knownSessionChunks.clear();
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class ChannelHealing method doPower.
private void doPower(EliteEntity eliteEntity) {
for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) {
EliteEntity parsedEntity = EntityTracker.getEliteMobEntity(entity);
if (parsedEntity == null)
continue;
if (parsedEntity.getHealth() / parsedEntity.getMaxHealth() > .8)
continue;
channelHealing(eliteEntity, parsedEntity);
return;
}
}
Aggregations