Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
* Copyright (c) 2017. Starlis LLC / dba Empire Minecraft
*
* This source code is proprietary software and must not be redistributed without Starlis LLC's approval
*
*/
package com.empireminecraft.features.survival.mobs.enraged;
import com.empireminecraft.Worlds;
import com.empireminecraft.events.EntityLaunchProjectileEvent;
import com.empireminecraft.events.EntityLaunchedFireballExplodeEvent;
import com.empireminecraft.features.survival.mobs.CustomMobSettings;
import com.empireminecraft.features.survival.mobs.MobSpawnAttemptContext;
import com.empireminecraft.items.categories.MobHeads;
import com.empireminecraft.util.BlockUtil;
import org.bukkit.Location;
import org.bukkit.World.Environment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Monster;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.potion.PotionEffectType;
import static com.empireminecraft.items.categories.SurvivalUncommonItems.GHAST_HEART;
import static com.empireminecraft.systems.loot.LootBonus.LRG_1;
import static com.empireminecraft.systems.loot.LootBonus.LRG_5;
import static com.empireminecraft.systems.loot.LootBonus.MED_1;
import static org.bukkit.Material.GHAST_TEAR;
import static org.bukkit.Material.GUNPOWDER;
@CustomMobSettings(
name = "&cEnraged Ghast",
key = "ENRAGED_GHAST",
baseType = EntityType.GHAST,
spawnRate = 5,
worldRespawnRateMins = 15,
playerRespawnRateMins = 300,
bonusXpMin = 50,
bonusXpMax = 150,
baseTokens = 80
)
public class EnragedGhast extends EnragedFlyingMob<Ghast> {
@Override
protected void onRegister() {
super.onRegister();
//COMMON
addLootItem(GHAST_TEAR, LRG_5)
.at(7, 100).qtyRange(2, 4)
.at(1, 100).qtyRange(1, 2);
addLootItem(GUNPOWDER, LRG_5)
.at(7, 100).qtyRange(16, 25)
.at(1, 100).qtyRange(6, 25);
//CUSTOM
addLootItem(GHAST_HEART, MED_1)
.at(10, 75, LRG_1).qtyRange(2, 3)
.at(9, 65, LRG_1).qtyRange(3)
.at(8, 40, LRG_1).qtyRange(2)
.at(7, 35).qtyRange(2)
.at(6, 25)
.at(5, 15)
.any(8);
//MISC
addBoostedMobHeadLoot(MobHeads.GHAST_HEAD);
}
@Override
public boolean canSpawn(Location loc, MobSpawnAttemptContext context) {
Environment env = loc.getWorld().getEnvironment();
return env == Environment.NETHER || (env == Environment.NORMAL && BlockUtil.isAboveGround(loc.getBlock())
&& Monster.class.isAssignableFrom(context.replacingType.getEntityClass())
&& BlockUtil.isAreaAir(loc.getBlock().getRelative(0, 4, 0), 3)
);
}
@Override
protected double getSpawnRate(MobSpawnAttemptContext context) {
return Worlds.isWilderness(context.location.getWorld()) ? 0.5 : super.getSpawnRate(context);
}
@Override
protected void onSpawn() {
super.onSpawn();
increaseHealth(7);
}
@EventHandler
public void onEntityLaunchProjectile(EntityLaunchProjectileEvent event) {
Fireball fireball = (Fireball) event.getProjectile();
fireball.setIsIncendiary(false);
fireball.setYield(2);
}
@EventHandler
public void onEntityLaunchedFireballExplode(EntityLaunchedFireballExplodeEvent event) {
ExplosionPrimeEvent explodeEvent = event.getEvent();
explodeEvent.setFire(true);
explodeEvent.setRadius(3);
}
@Override
protected void onInitialize() {
super.onInitialize();
entity.setFireballCooldown(20);
setTargetRange(100);
addPermaPotion(PotionEffectType.DAMAGE_RESISTANCE, 0);
addPermaPotion(PotionEffectType.FIRE_RESISTANCE, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.