In Minecraft, the damage source when a player is attacked can be found using datapacks. Here's an example of how you can achieve this:

  1. Create a new datapack by creating a new folder in the "datapacks" directory of your Minecraft world. Let's call it "DamageSourceDatapack".

  2. Inside the "DamageSourceDatapack" folder, create the following directories: "DamageSourceDatapack/data/damage_source/functions".

  3. In the "functions" directory, create a new text file called "attack.mcfunction".

  4. Open the "attack.mcfunction" file and enter the following command to detect the damage source:

execute as @a at @s run say You were attacked by: 
execute as @e[type=minecraft:player] at @s unless entity @a[distance=0..1] run say @s

This command will display the message "You were attacked by:" and then the name of the attacking player.

  1. Save the file and exit.

  2. Compress the "DamageSourceDatapack" folder into a .zip file.

  3. Place the .zip file into the "datapacks" directory of your Minecraft world.

  4. Load the world in Minecraft.

Now, whenever a player is attacked by another player, the message "You were attacked by: [Player Name]" will be displayed

find the damage source when player is attack in minecraftusing datapck

原文地址: https://www.cveoy.top/t/topic/h6ka 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录