Sound on portal activation

Started by Rowan101 on

Topic category: Help with modding (Java Edition)

Last seen on 20:06, 28. Aug 2022
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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?

Last seen on 20:06, 28. Aug 2022
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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();