I have created custom sound in 1.7.10 mod using sounds.json file and w.playsound function. It works great for the player who activates the sound but the sound is not heard by other players on the server. I was not able to figure out from searching how to get w.playsound to play for all players. Can you take a look at this class and let me know what needs to be added for the sound to play for all players (within hearing distance, obviously). Thanks very much.
package blinkylightsmod;
import java.util.Random;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.IIcon;
public class BlockStar extends Block {
private boolean playing;
private boolean playing1;
public BlockStar() {
super(BlinkyLightsMod.star);
setStepSound(Block.soundTypeGlass);
setCreativeTab(CreativeTabs.tabDecorations);
setBlockTextureName("blinkylightsmod:blockStar");
setBlockName("blockStar");
setLightLevel(1.0F);
this.playing = false;
this.playing1 = false;
}
public boolean renderAsNormalBlock() {
return false;
}
public boolean isOpaqueCube() {
return false;
}
public int getRenderType() {
return 1;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World w, int x, int y, int z) {
return null;
}
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int i, float hx, float hy, float hz) {
if (p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() == BlinkyLightsMod.itemCandyCane) {
w.playSound(x, y, z, "blinkylightsmod:deckthehalls", 1.0F, 1.0F, true);
return true;
} else {
w.playSound(x, y, z, "blinkylightsmod:merrychristmas", 1.0F, 1.0F, true);
return true;
}
}
}