Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have the following class (Scala).

 

class ItemMyItem extends Item {
  setRegistryName("my_item")
  setUnlocalizedName("my_item")
  maxStackSize = 1
  setCreativeTab(CreativeTabs.TOOLS)

  def spawnParticles(world: World, pos: BlockPos): Unit = {
    for (_ <- 1 to 50000) {
      val randX = Random.nextDouble()
      val randZ = Random.nextDouble()
      val randPlusX = Random.nextBoolean()
      val randPlusY = Random.nextBoolean()
      val randPlusZ = Random.nextBoolean()
      val d0 = pos.getX + 20.0 * (if (randPlusX) randX else -randX)
      val d1 = pos.getY + (if (randPlusY) randX else -randX) * 6.0 / 16.0
      val d2 = pos.getZ + 20.0 * (if (randPlusZ) randZ else -randZ)
      world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, 20.0 * (if (randPlusX) randX else -randX), 1.0, 20.0 * (if (randPlusZ) randZ else -randZ))
    }
  }

  override
  def itemInteractionForEntity(stack: ItemStack, playerIn: EntityPlayer, target: EntityLivingBase, hand: EnumHand): Boolean = {
    super.itemInteractionForEntity(stack, playerIn, target, hand)
    playerIn.playSound(MyMod.mySound, 1.0F, 1.0F)
    spawnParticles(playerIn.getEntityWorld, playerIn.getPosition)
    true
  }
}

 

The problem is that when I test in multiplayer, only the person using the item can see the particles and hear the sound.  They can see the arm swing animation on use.  I was wondering why that was, and how I could get other players to see/hear them.

 

Only on the client proxy do I register the sound.  I am using vanilla particles, so I don't ever register those.

 

I checked the docs and they seem to suggest it should be run on both sides automatically.  Any help would be appreciated.

  • Author

Thank you very much.  I will check how to use packets.

 

For the sound, I still can't get it to work right now.  I'll post back if I figure it out.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.