diff --git a/src/minecraft/biomesoplenty/BiomesOPlenty.java b/src/minecraft/biomesoplenty/BiomesOPlenty.java index 915ca09ac..a5081af5c 100644 --- a/src/minecraft/biomesoplenty/BiomesOPlenty.java +++ b/src/minecraft/biomesoplenty/BiomesOPlenty.java @@ -67,9 +67,6 @@ public class BiomesOPlenty { BOPConfiguration.init(event.getSuggestedConfigurationFile()); - SoundHandler soundHandler = new SoundHandler(); - soundHandler.installRecordTracks(); - Version.check(); tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty"); @@ -92,6 +89,8 @@ public class BiomesOPlenty } GameRegistry.registerCraftingHandler(new BOPCraftHandler()); + + MinecraftForge.EVENT_BUS.register(new SoundHandler()); } @Init diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPGlass.java b/src/minecraft/biomesoplenty/blocks/BlockBOPGlass.java index b87333795..e15394ca8 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPGlass.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPGlass.java @@ -3,6 +3,7 @@ package biomesoplenty.blocks; import java.util.List; import java.util.Random; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -72,29 +73,52 @@ public class BlockBOPGlass extends Block } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float par7, float par8, float par9) + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float par7, float par8, float par9) { ItemStack equippedItem = player.getCurrentEquippedItem(); - - if (equippedItem.itemID == Items.soulManipulator.get().itemID && equippedItem.getItemDamage() == 1) + Random rand = new Random(); + + if (equippedItem.itemID == Items.soulManipulator.get().itemID) { - if (world.getBlockMetadata(x, y, z) == 1) + if (equippedItem.getItemDamage() == 0) { - if (checkAltarStructreIntegrity(world, x, y, z)) + if (world.getBlockMetadata(x, y, z) == 3) { - if (!player.capabilities.isCreativeMode) + if (checkAltarStructreIntegrity(world, x, y, z)) { - player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 0)); + if (!player.capabilities.isCreativeMode) + { + player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 2)); + } + + FMLClientHandler.instance().getClient().sndManager.playSound("mods.BiomesOPlenty.audio.villager.no", (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, 1.0F, 1.0F); + + world.setBlockMetadataWithNotify(x, y, z, 1, 2); + + return true; } + } + } + else if (equippedItem.getItemDamage() == 1) + { + if (world.getBlockMetadata(x, y, z) == 1) + { + if (checkAltarStructreIntegrity(world, x, y, z)) + { + if (!player.capabilities.isCreativeMode) + { + player.setCurrentItemOrArmor(0, new ItemStack(Items.soulManipulator.get(), 1, 0)); + } - world.spawnEntityInWorld(new EntityLightningBolt(world, x + 1, y + 2, z)); - world.spawnEntityInWorld(new EntityLightningBolt(world, x -1, y + 2, z)); - world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z + 1)); - world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z - 1)); - - world.setBlockMetadataWithNotify(x, y, z, 2, 2); + world.spawnEntityInWorld(new EntityLightningBolt(world, x + 1, y + 2, z)); + world.spawnEntityInWorld(new EntityLightningBolt(world, x -1, y + 2, z)); + world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z + 1)); + world.spawnEntityInWorld(new EntityLightningBolt(world, x, y + 2, z - 1)); - return true; + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + + return true; + } } } } diff --git a/src/minecraft/biomesoplenty/handlers/EntityEventHandler.java b/src/minecraft/biomesoplenty/handlers/EntityEventHandler.java index 5756c1882..c63e1b671 100644 --- a/src/minecraft/biomesoplenty/handlers/EntityEventHandler.java +++ b/src/minecraft/biomesoplenty/handlers/EntityEventHandler.java @@ -95,18 +95,15 @@ public class EntityEventHandler @ForgeSubscribe public void lightningStrike(LivingHurtEvent event) { - if (event.source == DamageSource.inFire) - { - AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)event.entity.posX, (double)event.entity.posY, (double)event.entity.posZ, (double)(event.entity.posX + 1), (double)(event.entity.posY + 1), (double)(event.entity.posZ + 1)).expand(5, 5, 5); + AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)event.entity.posX, (double)event.entity.posY, (double)event.entity.posZ, (double)(event.entity.posX + 1), (double)(event.entity.posY + 1), (double)(event.entity.posZ + 1)).expand(5, 5, 5); - if (!event.entity.worldObj.getEntitiesWithinAABB(EntityLightningBolt.class, axisalignedbb).isEmpty()); + if (!event.entity.worldObj.getEntitiesWithinAABB(EntityLightningBolt.class, axisalignedbb).isEmpty()); + { + if (!event.entity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb).isEmpty()); { - if (!event.entity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb).isEmpty()); - { - if (isBlockInBB(event.entity.worldObj, axisalignedbb, Blocks.glass.get().blockID, 2)) - { - event.setCanceled(true); - } + if (isBlockInBB(event.entity.worldObj, axisalignedbb, Blocks.glass.get().blockID, 2) || isBlockInBB(event.entity.worldObj, axisalignedbb, Blocks.glass.get().blockID, 3)) + { + event.setCanceled(true); } } } diff --git a/src/minecraft/biomesoplenty/handlers/SoundHandler.java b/src/minecraft/biomesoplenty/handlers/SoundHandler.java index f44ebd7bc..88001fa57 100644 --- a/src/minecraft/biomesoplenty/handlers/SoundHandler.java +++ b/src/minecraft/biomesoplenty/handlers/SoundHandler.java @@ -7,52 +7,64 @@ import java.io.OutputStream; import java.util.logging.Level; import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.sound.PlayStreamingEvent; +import net.minecraftforge.client.event.sound.SoundLoadEvent; +import net.minecraftforge.event.ForgeSubscribe; import biomesoplenty.BiomesOPlenty; import biomesoplenty.ClientProxy; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class SoundHandler { - static String[] soundFiles = { "bopdisc.ogg", "bopdiscmud.ogg"}; + static String[] recordSoundFiles = { "mods/BiomesOPlenty/audio/record/" + "bopdisc.ogg", "mods/BiomesOPlenty/audio/record/" + "bopdiscmud.ogg"}; + static String[] soundFiles = { "mods/BiomesOPlenty/audio/villager/" + "no.ogg"}; - public void installRecordTracks() + @SideOnly(Side.CLIENT) + @ForgeSubscribe + public void onSoundLoad(SoundLoadEvent event) { - boolean isClient = BiomesOPlenty.proxy instanceof ClientProxy; - - if (isClient) + for (String soundFile : soundFiles) { - for (String soundFile : soundFiles) + try { - try - { - File file = new File(Minecraft.getMinecraftDir().getAbsolutePath() + "/resources/mod/streaming/" + soundFile); - if (!file.exists()) { - System.out.println("[BiomesOPlenty] " + soundFile + " doesn't exist, creating..."); - file.getParentFile().mkdirs(); - file.createNewFile(); - InputStream istream = getClass().getResourceAsStream("/mods/BiomesOPlenty/audio/" + soundFile); - OutputStream out = new FileOutputStream(file); - byte[] buf = new byte[1024]; - int size = 0; - int len; - while ((len = istream.read(buf)) > 0) { - out.write(buf, 0, len); - size += len; - } - out.close(); - istream.close(); - if (size == 0) { - file.delete(); - } - } - } - catch (Exception e) - { - FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed to load sound file: " + soundFile); - e.printStackTrace(); - } + event.manager.soundPoolSounds.addSound(soundFile, this.getClass().getResource("/" + soundFile)); } + + catch (Exception e) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed loading sound file: " + soundFile); + } + } + + for (String recordSoundFile : recordSoundFiles) + { + try + { + event.manager.soundPoolStreaming.addSound(recordSoundFile, this.getClass().getResource("/" + recordSoundFile)); + } + + catch (Exception e) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Failed loading sound file: " + recordSoundFile); + } + } + } + + @SideOnly(Side.CLIENT) + @ForgeSubscribe + public void onPlayStreaming(PlayStreamingEvent event) + { + if (event.name == "bopdisc") + { + FMLClientHandler.instance().getClient().sndManager.playStreaming("mods.BiomesOPlenty.audio.record.bopdisc", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F); + } + else if (event.name == "bopdiscmud") + { + FMLClientHandler.instance().getClient().sndManager.playStreaming("mods.BiomesOPlenty.audio.record.bopdiscmud", (float) event.x + 0.5F, (float) event.y + 0.5F, (float) event.z + 0.5F); } } } diff --git a/src/minecraft/biomesoplenty/items/ItemBOPBones.java b/src/minecraft/biomesoplenty/items/ItemBOPBones.java index 63ee73d4b..59bf34f34 100644 --- a/src/minecraft/biomesoplenty/items/ItemBOPBones.java +++ b/src/minecraft/biomesoplenty/items/ItemBOPBones.java @@ -37,7 +37,6 @@ public class ItemBOPBones extends ItemBlock public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { int id = world.getBlockId(x, y, z); - System.out.println(itemstack); if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) { diff --git a/src/minecraft/biomesoplenty/items/ItemSoulManipulator.java b/src/minecraft/biomesoplenty/items/ItemSoulManipulator.java index 6f53b01ab..b0994d712 100644 --- a/src/minecraft/biomesoplenty/items/ItemSoulManipulator.java +++ b/src/minecraft/biomesoplenty/items/ItemSoulManipulator.java @@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemSoulManipulator extends Item { - private static String[] manipulatorTypes = {"soulmanipulator_empty", "soulmanipulator_ghastlysoul"}; + private static String[] manipulatorTypes = {"soulmanipulator_empty", "soulmanipulator_ghastlysoul", "soulmanipulator_villager"}; @SideOnly(Side.CLIENT) private Icon[] textures; diff --git a/src/minecraft/mods/BiomesOPlenty/audio/bopdisc.ogg b/src/minecraft/mods/BiomesOPlenty/audio/record/bopdisc.ogg similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/audio/bopdisc.ogg rename to src/minecraft/mods/BiomesOPlenty/audio/record/bopdisc.ogg diff --git a/src/minecraft/mods/BiomesOPlenty/audio/bopdiscmud.ogg b/src/minecraft/mods/BiomesOPlenty/audio/record/bopdiscmud.ogg similarity index 100% rename from src/minecraft/mods/BiomesOPlenty/audio/bopdiscmud.ogg rename to src/minecraft/mods/BiomesOPlenty/audio/record/bopdiscmud.ogg diff --git a/src/minecraft/mods/BiomesOPlenty/audio/villager/no.ogg b/src/minecraft/mods/BiomesOPlenty/audio/villager/no.ogg new file mode 100644 index 000000000..4044813a6 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/audio/villager/no.ogg differ diff --git a/src/minecraft/mods/BiomesOPlenty/localizations/en_US.xml b/src/minecraft/mods/BiomesOPlenty/localizations/en_US.xml index 91a9e5948..4c34dcd68 100644 --- a/src/minecraft/mods/BiomesOPlenty/localizations/en_US.xml +++ b/src/minecraft/mods/BiomesOPlenty/localizations/en_US.xml @@ -319,6 +319,7 @@ Soul Manipulator Ghastly Soul Manipulator + Villager Soul Manipulator Enderporter diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/sacrificialfocus_villager.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sacrificialfocus_villager.png index 916e61020..b05d1416e 100644 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/sacrificialfocus_villager.png and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sacrificialfocus_villager.png differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/items/soulmanipulator_villager.png b/src/minecraft/mods/BiomesOPlenty/textures/items/soulmanipulator_villager.png new file mode 100644 index 000000000..f10e12b36 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/items/soulmanipulator_villager.png differ