Added the Villager Soul Manipulator and switched to a non-hacky way of adding sounds
This commit is contained in:
parent
13c7d207d3
commit
3b0ec1ec85
12 changed files with 95 additions and 63 deletions
|
@ -67,9 +67,6 @@ public class BiomesOPlenty
|
||||||
{
|
{
|
||||||
BOPConfiguration.init(event.getSuggestedConfigurationFile());
|
BOPConfiguration.init(event.getSuggestedConfigurationFile());
|
||||||
|
|
||||||
SoundHandler soundHandler = new SoundHandler();
|
|
||||||
soundHandler.installRecordTracks();
|
|
||||||
|
|
||||||
Version.check();
|
Version.check();
|
||||||
|
|
||||||
tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty");
|
tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty");
|
||||||
|
@ -92,6 +89,8 @@ public class BiomesOPlenty
|
||||||
}
|
}
|
||||||
|
|
||||||
GameRegistry.registerCraftingHandler(new BOPCraftHandler());
|
GameRegistry.registerCraftingHandler(new BOPCraftHandler());
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(new SoundHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Init
|
@Init
|
||||||
|
|
|
@ -3,6 +3,7 @@ package biomesoplenty.blocks;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -72,29 +73,52 @@ public class BlockBOPGlass extends Block
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
ItemStack equippedItem = player.getCurrentEquippedItem();
|
||||||
|
Random rand = new Random();
|
||||||
if (equippedItem.itemID == Items.soulManipulator.get().itemID && equippedItem.getItemDamage() == 1)
|
|
||||||
|
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 -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.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);
|
|
||||||
|
|
||||||
return true;
|
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,18 +95,15 @@ public class EntityEventHandler
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
public void lightningStrike(LivingHurtEvent event)
|
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) || isBlockInBB(event.entity.worldObj, axisalignedbb, Blocks.glass.get().blockID, 3))
|
||||||
{
|
{
|
||||||
if (isBlockInBB(event.entity.worldObj, axisalignedbb, Blocks.glass.get().blockID, 2))
|
event.setCanceled(true);
|
||||||
{
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,52 +7,64 @@ import java.io.OutputStream;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
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.BiomesOPlenty;
|
||||||
import biomesoplenty.ClientProxy;
|
import biomesoplenty.ClientProxy;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class SoundHandler
|
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;
|
for (String soundFile : soundFiles)
|
||||||
|
|
||||||
if (isClient)
|
|
||||||
{
|
{
|
||||||
for (String soundFile : soundFiles)
|
try
|
||||||
{
|
{
|
||||||
try
|
event.manager.soundPoolSounds.addSound(soundFile, this.getClass().getResource("/" + soundFile));
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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);
|
int id = world.getBlockId(x, y, z);
|
||||||
System.out.println(itemstack);
|
|
||||||
|
|
||||||
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1)
|
if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class ItemSoulManipulator extends Item
|
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)
|
@SideOnly(Side.CLIENT)
|
||||||
private Icon[] textures;
|
private Icon[] textures;
|
||||||
|
|
||||||
|
|
BIN
src/minecraft/mods/BiomesOPlenty/audio/villager/no.ogg
Normal file
BIN
src/minecraft/mods/BiomesOPlenty/audio/villager/no.ogg
Normal file
Binary file not shown.
|
@ -319,6 +319,7 @@
|
||||||
|
|
||||||
<entry key="item.bop.soulManipulator.soulmanipulator_empty.name">Soul Manipulator</entry>
|
<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_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>
|
<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 |
Loading…
Reference in a new issue