Sound on portal activation

Started by Rowan101 on

Topic category: Help with Minecraft modding (Java Edition)

Active 4 months ago
Joined Dec 2015
Points:
715

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
Sound on portal activation

I would like to play a sound when a custom portal is activated, however there is currently only a trigger for when the igniter is used on anything even if it's not the portal. How can I detect when the portal is activated?

Active 4 months ago
Joined Dec 2015
Points:
715

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 2
After some trial and error I…
Fri, 05/22/2020 - 06:09

After some trial and error I found a way to do this. In the "When portal trigger used" procedure, I test for the custom portal block by running the custom code:

(world.getBlockState(new BlockPos((int) x, (int) y, (int) z))).getBlock() == VitiaDimension.portal.getDefaultState().getBlock();