-
-
Save aikar/099cb149bcc6ec636ed8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.empireminecraft.features.survival.mobs.uncommon; | |
import com.empireminecraft.entityai.EntityAIApi; | |
import com.empireminecraft.features.survival.mobs.CustomMob; | |
import com.empireminecraft.features.survival.mobs.CustomMobSettings; | |
import com.empireminecraft.util.Util; | |
import org.bukkit.Location; | |
import org.bukkit.Material; | |
import org.bukkit.Sound; | |
import org.bukkit.World; | |
import org.bukkit.entity.*; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.entity.EntityDeathEvent; | |
import org.bukkit.event.entity.EntityTameEvent; | |
import org.bukkit.event.entity.EntityTargetEvent; | |
import org.bukkit.potion.PotionEffectType; | |
import java.util.ArrayList; | |
import java.util.List; | |
import static com.empireminecraft.features.survival.LootPool.LootItem; | |
import static com.empireminecraft.config.RareItems.RareDrop.RareDrop; | |
@CustomMobSettings ( | |
name = "&cNetherhound", | |
key = "NETHERHOUND", | |
mobType = EntityType.WOLF, | |
minSpawnFromPlayer = 32, | |
spawnRate = 10, | |
respawnRate = 5, | |
bonusXpMin = 1, | |
bonusXpMax = 4 | |
) | |
public class Netherhound extends CustomMob<Wolf> { | |
{ | |
setLootPool( | |
LootItem(50, RareDrop(Material.COOKED_BEEF).withRange(3, 8)), | |
LootItem(20, RareDrop(Material.NETHER_BRICK_ITEM).withRange(2, 6)), | |
LootItem(10, RareDrop(Material.QUARTZ).withRange(3, 15)), | |
LootItem(100, RareDrop(Material.SULPHUR).withRange(2, 6)) | |
); | |
} | |
@Override | |
protected boolean canSpawn(Location loc) { | |
World world = loc.getWorld(); | |
return world.getEnvironment() == World.Environment.NETHER; | |
} | |
@Override | |
protected void onSpawn(Wolf entity) { | |
entity.setAngry(true); | |
increaseHealth(entity, 4); | |
if (getWolfpack(entity, 16).size() < 1) { | |
int numSpawn = Util.rand(3, 6); | |
for (int i = 0; i < numSpawn; i++) { | |
NETHERHOUND.spawn(entity.getLocation()); | |
} | |
} | |
} | |
@Override | |
protected void onInitialize(Wolf entity) { | |
makeFlaming(entity); | |
EntityAIApi.makeAggressive(entity, 16); | |
EntityAIApi.setTargetRange(entity, 16); | |
EntityAIApi.setEntityMaxPathfindingRange(entity, 48); | |
} | |
@EventHandler | |
public void onTame(EntityTameEvent event) { | |
event.setCancelled(true); | |
} | |
@EventHandler | |
public void onTarget(EntityTargetEvent event) { | |
final Entity target = event.getTarget(); | |
if (target instanceof Player && event.getTarget() != ((Wolf) event.getEntity()).getTarget()) { | |
target.getWorld().playSound(target.getLocation(), Sound.WOLF_GROWL, 1, -3); | |
if (!cooldownReady(event.getEntity(), "lastHowl", 30)) { | |
return; | |
} | |
Long now = System.currentTimeMillis(); | |
target.getWorld().playSound(target.getLocation(), Sound.WOLF_HOWL, 6, 0); | |
announce(event.getEntity(), 64, "&cNetherhound howls for assistance."); | |
enrageWolf((Wolf) event.getEntity()); | |
Util.setMetadata(event.getEntity(), "lastHowl", now); | |
for (final Wolf wolf : getWolfpack((Wolf) event.getEntity(), 128)) { | |
Util.setMetadata(wolf, "lastHowl", now); | |
wolf.setTarget((LivingEntity) target); | |
enrageWolf(wolf); | |
} | |
} | |
} | |
public static void enrageWolf(Wolf wolf) { | |
makeFlaming(wolf); | |
Util.addPotion(wolf, PotionEffectType.SPEED, 20, 2); | |
Util.addPotion(wolf, PotionEffectType.INCREASE_DAMAGE, 15, 3); | |
} | |
@EventHandler | |
public void onDeath(EntityDeathEvent event) { | |
if (Util.RANDOM.nextInt(100) < 33) { | |
final Location loc = event.getEntity().getLocation(); | |
loc.getWorld().createExplosion(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 1.5F, false, false); | |
} | |
} | |
public static List<Wolf> getWolfpack(Wolf entity, int range) { | |
List<Wolf> list = new ArrayList<>(10); | |
for (Entity entity1 : entity.getNearbyEntities(range, 32, range)) { | |
if (entity1 instanceof Wolf && getType(entity1) == NETHERHOUND) { | |
list.add((Wolf) entity1); | |
} | |
} | |
return list; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment