I found a new error post in the new version of Minecraft.
[media]And it was caused by these lines of code:
[media]The thrown error seemed show that any mobs(of cause player isn’t a mob) cannot be defined as “damagingEntity”
Attachments
Comments 6
I can’t edit my report so I have to claim it here. The code in the screenshot is enough for testing the issue, only needs to correctly add it to a script (.js file) in a behavior pack.
And I noticed there are custom fields in the code, so I’ll provide improved code here:
import { world } from "@minecraft/server";
//subscribe an entity hit entity event
world.afterEvents.entityHitEntity.subscribe(t => {
//define entities in the event
var entity = t.hitEntity
var attack = t.damagingEntity
//use different methods to get items held by different types of entities
if (attack.typeId == "minecraft:player") {
var weapon = attack.getComponent("inventory")
.container.getItem(attack.selectedSlotIndex)
}
else {
var weapon = attack.getComponent("equippable")
.getEquipment("mainhand")
}
//when the hitting entity holding wooden sword, affect hit entity poison
if (weapon.typeId == "minecraft:wooden_sword"){
entity.runCommand(`effect @s fatal_poison 5 1`);
}
//when the hitting entity holding iron sword, affect hit entity slowness. especially when hit entity is player, affect it blindness
if (weapon.typeId == "minecraft:iron_sword"){
if (entity.typeId == "minecraft:player") {entity.runCommand(`effect @s blindness 120 0`);}
else {entity.runCommand(`effect @s slowness 120 1`);}
}
});
when you copy the code and successfully set up a pack, apply it to a world, then we can test.
Steps to Reproduce:
Summon an entity, say a zombie, holding a wooden sword or a iron sword(actually whatever it’s holding or even nothing it’s holding, the error post will be shown)
Summon another entity, say a villager or yourself in survival mode, and let the entity hit this entity
Observed Results:
the error posts and no effect is applied to hit entity
Expected Results:
the effect is applied and no error posts
The thrown error seemed show that any mobs(of cause player isn’t a mob) cannot be defined as “damagingEntity”
The original description of the report was inaccurate. If you replace
The error post shows that a mob hitting other entity and its component "equippable" wass undefined(not readable). And actually its component "inventory" was not readable, too. So I suppose mobs' components that contains item stack were not readable.
with
The thrown error seemed show that any mobs(of cause player isn’t a mob) cannot be defined as “damagingEntity”
I would be more clear.
We do not have enough information to reproduce this issue.
Please include the following information to help us understand your problem:
Steps to Reproduce:
(Explain what needs to be done for the issue to happen)
Observed Results:
(Briefly describe what happens)
Expected Results:
(Briefly describe what should happen)
Please also attach any needed commands, add-ons/behavior packs, data packs, resource packs, screenshots, videos, or worlds needed to help reproduce this issue.
Refer to the Bug Tracker Guidelines for more information about how to write helpful bug reports. Bug reports with insufficient information may be closed as Incomplete.
This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.
Quick Links:
📓 Bug Tracker Guidelines -- 💬 Community Support -- 📧 Mojang Support (Technical Issues) -- 📧 Microsoft Support (Account Issues) -- ✍️ Feedback and Suggestions -- 📖 Game Wiki