@Override public void handleFairyUpgrade(EntityItem item, EntityPlayer player, TileEntityDungeonCore core) { if (PlayerUtils.hasItem(player, ZSSItems.swordMasterTrue)) { item.setDead(); player.triggerAchievement(ZSSAchievements.shieldMirror); WorldUtils.spawnItemWithRandom( core.getWorldObj(), new ItemStack(ZSSItems.shieldMirror), core.xCoord, core.yCoord + 2, core.zCoord); core.getWorldObj() .playSoundEffect( core.xCoord + 0.5D, core.yCoord + 1, core.zCoord + 0.5D, Sounds.SECRET_MEDLEY, 1.0F, 1.0F); } else { core.getWorldObj() .playSoundEffect( core.xCoord + 0.5D, core.yCoord + 1, core.zCoord + 0.5D, Sounds.FAIRY_LAUGH, 1.0F, 1.0F); PlayerUtils.sendTranslatedChat(player, "chat.zss.fairy.laugh.sword"); } }
/** * Returns the nearest fairy spawner dungeon core to the position, or null if none exists * * @param requiresFairy if true, only returns a spawner with at least one fairy nearby */ public static TileEntityDungeonCore getNearbyFairySpawner( World world, double x, double y, double z, boolean requiresFairy) { List<TileEntityDungeonCore> list = WorldUtils.getTileEntitiesWithinAABB( world, TileEntityDungeonCore.class, AxisAlignedBB.getBoundingBox( x - 3.0D, y - 2.0D, z - 3.0D, x + 3.0D, y + 2.0D, z + 3.0D)); for (TileEntityDungeonCore core : list) { if (core.isSpawner() && (!requiresFairy || world .getEntitiesWithinAABB( EntityFairy.class, AxisAlignedBB.getBoundingBox( (double) core.xCoord - 5D, (double) core.yCoord - 1, (double) core.zCoord - 5D, (double) core.xCoord + 5D, (double) core.yCoord + 5.0D, (double) core.zCoord + 5D)) .size() > 0)) { return core; } } return null; }