Skip to content

[Question] How can I get player stages from entity.attack event? #181

Discussion options

You must be logged in to vote

So first off, since you can't get the game stage of a damage source, you should use event.source.player instead and also check whether that is null, since damage sources can also be for example lightning bolts etc. (which obviously cannot have gamestages)

To access a player's stages, you can use player.stages and then for example check using stages.has or add a new stage using stages.add, so in total, you'd have something like

onEvent('entity.attack', event => {
  const player = event.source.player;
  if(player) {
    if(!player.stages.has('cacador') && player.mainHandItem == 'tconstruct:cleaver') {
      // do your thing
      event.cancel() // don't use return here, cancel is a void method

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@moniq-e
Comment options

Answer selected by moniq-e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #180 on August 12, 2021 16:06.