Started by
Crawler
on
Topic category: Advanced modding
I have been trying to add potion effects to the entity that attacks not the one that receives damage can anyone give me an example of how to do it? even if it needs custom code I'm comfortable with it
I.E. giving strenght to the wielder of a sword every time he hits another entity.
Upvote this issue: https://mcreator.net/tracker/issue/45976
After messing a bit with it I found a way to do it you just need to add a procedure to "when mob is hit with tool" and add the potion effects that you want to apply to the wielder of the sword then lock the sword element and edit it manually look for this part of the code:
@Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
super.hitEntity(itemstack, entity, entity2);
int x = (int) entity.posX;
int y = (int) entity.posY;
int z = (int) entity.posZ;
World world = entity.world;
{
java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
$_dependencies.put("entity", entity);
MCreatorGuinsoMobIsHitWithTool.executeProcedure($_dependencies);
}
return true;
}
and edit the line "$_dependencies.put("entity", entity);" ading a 2 in the seccond entity it should look like this "$_dependencies.put("entity", entity2);" and thats it you will get the effects.