Sound on portal activation

Started by Rowan101 on Fri, 05/22/2020 - 05:09

Topic category: Help with modding (Java Edition)

Last seen on 19:37, 30. Oct 2020
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Sound on portal activation
Fri, 05/22/2020 - 05:09

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 19:37, 30. Oct 2020
Joined Dec 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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();