From 1d48d639e8261ce2213b09e6cf1293d73bc279b8 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 23 Nov 2013 04:11:29 -0700 Subject: [PATCH] Fixed some issues with the Wither boss. --- BankEconomyMod/src/me/kaZep/Base/Main.java | 10 +- .../src/me/kaZep/Base/PlayerListener.java | 110 ++++++++++++++++-- 2 files changed, 108 insertions(+), 12 deletions(-) diff --git a/BankEconomyMod/src/me/kaZep/Base/Main.java b/BankEconomyMod/src/me/kaZep/Base/Main.java index bdc2a5f..208e8a2 100644 --- a/BankEconomyMod/src/me/kaZep/Base/Main.java +++ b/BankEconomyMod/src/me/kaZep/Base/Main.java @@ -1124,10 +1124,12 @@ public void runTick() { for (int i=0;il.getHealth()+5+(0.2*(l.getMaxHealth()/l.getHealth()))) { + DecimalFormat df = new DecimalFormat("#0.0"); + //Bukkit.broadcastMessage("Healing for "+(+5+(0.2*(l.getMaxHealth()/l.getHealth())))+" health. "+df.format(l.getHealth())+"/"+l.getMaxHealth()+" HP"); + l.setHealth(l.getHealth()+5+(0.2*(l.getMaxHealth()/l.getHealth()))); + } } } } diff --git a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java index 6c67c45..18dd28b 100644 --- a/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java +++ b/BankEconomyMod/src/me/kaZep/Base/PlayerListener.java @@ -2248,13 +2248,25 @@ implements Listener //Give the wither bonuses. if (e.getEntity() instanceof Wither) { Wither w = (Wither)e.getEntity(); - w.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING,999999,3)); - w.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,40)); - w.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); - w.setCustomName(ChatColor.GOLD+""+ChatColor.BOLD+"Mega Wither"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing true"); + if (Math.random()<=0.05) { + w.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,40)); + w.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + w.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,999999,1)); + w.setCustomName(ChatColor.GOLD+""+ChatColor.LIGHT_PURPLE+"Mythical Wither"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing true"); + } else { + w.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING,999999,3)); + w.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST,999999,40)); + w.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,999999,2)); + w.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,999999,1)); + w.setCustomName(ChatColor.GOLD+""+ChatColor.BOLD+"Mega Wither"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing true"); + } } } else { @@ -5228,6 +5240,10 @@ implements Listener } public ItemStack getGoodie() { + return getGoodie(0); + } + + public ItemStack getGoodie(int rar /*1=Mythical 0=Normal*/) { ItemStack item = null; if (Math.random()<0.33) { //Add a weapon/armor piece. @@ -5265,6 +5281,9 @@ implements Listener rarity=3; }break; } + if (rar==1) { + rarity=3; + } switch (rand) { case 0: { type = "LEATHER"; @@ -6023,6 +6042,27 @@ implements Listener } Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing false"); } + if (f.getCustomName().contains("Mythical Wither")) { + e.setDroppedExp(e.getDroppedExp()*4000); + boolean dropMythical=false; + for (int j=0;j<10;j++) { + Location dd = f.getLocation().add(Math.random()*4,Math.random()*4,Math.random()*4); + Bukkit.getWorld("world").getBlockAt(dd).setType(Material.CHEST); + Chest c=(Chest)Bukkit.getWorld("world").getBlockAt(dd).getState(); + for (int i=0;i<27;i++) { + ItemStack item = null; + if (Math.random()<=0.05 && !dropMythical) { + dropMythical=true; + item = getGoodie(2); + } + if (Math.random()<=0.2) { + item = getGoodie(); + c.getBlockInventory().setItem(i, item); + } + } + } + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule mobGriefing false"); + } if (f.getCustomName().contains(ChatColor.DARK_PURPLE+"")) { e.setDroppedExp(e.getDroppedExp()*20); f.setHealth(0); @@ -6887,7 +6927,61 @@ implements Listener } } if (e.getEntity() instanceof Wither) { - e.setDamage(e.getDamage()*0.075d); + if (l.getCustomName()!=null && l.getCustomName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE+"Mythical Wither")) { + e.setDamage(e.getDamage()*0.045d); + } else { + e.setDamage(e.getDamage()*0.065d); + } + try { + Iterator effects = l.getActivePotionEffects().iterator(); + //Figure out potion effects when player joins. + while (effects.hasNext()) { + PotionEffect nexteffect = effects.next(); + if (nexteffect.getType().getName().compareTo(PotionEffectType.NIGHT_VISION.getName())==0 && l.getHealth()