Posted January 18, 20169 yr Alright... I'm fairly new to the modding community but I need some help with something... I was able to make a custom ender pearl, which is supposed to play a sound to all entities near the impact upon colliding with either a block or a player. Now, it does play the sound; that isn't my issue. The problem is if I teleport too far with my custom pearl, the sound doesn't play at all. I tested with a LAN world, but it didn't even play for the second player. I tested the distance at which the sound would cut out, and it turned out to be 17 blocks. My Ender Pearl's code is quite similar to that of the in-game ender pearl, but I will copy paste some of the code anyways. The class is extending entityEnderPearl, so feel free to check that class out if you need any more. This is the section that triggers on the projectiles impact. I am aware that the line where the sound gets trigger is below where the section where the particles are triggered, but I have moved this line of code around and it doesn't make a difference. [embed=425,349]@Override protected void onImpact(MovingObjectPosition p_70184_1_) { if (p_70184_1_.entityHit != null) { p_70184_1_.entityHit.setFire(10);; } for (int i = 0; i < 32; ++i) { this.worldObj.spawnParticle("lava", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); } if (!this.worldObj.isRemote) { if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj) { EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F); this.worldObj.playSoundEffect(posX, posY, posX, "MyMod:teleportfwoop", 0.75F, 0.95F); if (!MinecraftForge.EVENT_BUS.post(event)) { // Don't indent to lower patch size if (this.getThrower().isRiding()) { this.getThrower().mountEntity((Entity)null); } this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ); this.getThrower().fallDistance = 0.0F; } } } this.setDead(); } }[/embed] If anyone could help with this, or tell me a better way to call the sound, please let me know. -Wekio
January 20, 20169 yr The volume you play the sound at using World#playSoundEffect determines how far around the position the sound can be heard. If you look at WorldManager#playSound (the server-side IWorldAccess implementation called by World#playSoundEffect ), you'll see that the S29PacketSoundEffect (the packet that plays the sound on the client) is sent to all players in a radius of 16 * volume blocks around the target position (minimum radius is 16). Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.