Created
November 4, 2020 13:14
-
-
Save salwador/bab1a790a5b1ffc0e8067a8a5a74c1fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system.listenForEvent(ReceiveFromMinecraftServer.PlayerAttackedEntity, | |
function(en) { | |
setTimeout( | |
function() { | |
let entity = en.data.attacked_entity; | |
let entityActor = Actor.fromEntity(entity); | |
let entityHealth = entityActor.getAttribute(7); | |
let entityName = entity.__identifier__.substr(11, 64); | |
entityName = `${entity.__identifier__.substr(10, 1).toUpperCase()}${entityName}`; | |
let playerEntity = en.data.player; | |
let playerActor = Actor.fromEntity(playerEntity); | |
let playerHealth = playerActor.getAttribute(7); | |
let playerNetwork = playerActor.getNetworkIdentifier(); | |
console.log(`PlayerAttackedEntity => ${entityName}, ${entityHealth} ❤, ${playerNetwork.getAddress()}`); | |
}, 10 | |
); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment