Added the Villager Soul Manipulator and switched to a non-hacky way of adding sounds

This commit is contained in:
Adubbz G 2013-06-16 10:30:58 +10:00
parent 13c7d207d3
commit 3b0ec1ec85
12 changed files with 95 additions and 63 deletions

View File

@ -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

View File

@ -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;
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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)
{

View File

@ -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;

Binary file not shown.

View File

@ -319,6 +319,7 @@
<entry key="item.bop.soulManipulator.soulmanipulator_empty.name">Soul Manipulator</entry>
<entry key="item.bop.soulManipulator.soulmanipulator_ghastlysoul.name">Ghastly Soul Manipulator</entry>
<entry key="item.bop.soulManipulator.soulmanipulator_villager.name">Villager Soul Manipulator</entry>
<entry key="item.bop.enderporter.name">Enderporter</entry>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB