Jump to content

Giving a mob an NBT tag while it's active


ironkiller224

Recommended Posts

I'm trying to give a mob the tag "NoAI". Is there any way to give it a tag using just the entity instance?

I attempted it this way:

public class voidCharmEffect {
	@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
	public void onEvent(LivingUpdateEvent event){
		EntityLivingBase entitya = event.getEntityLiving();
		if(entitya instanceof EntityPlayer && entitya != null){
			EntityPlayer entity = (EntityPlayer) entitya;
			if(entity.getHeldItemOffhand().getItem() == ModItems.voidCharm  ){
				GameSettings gs = Minecraft.getMinecraft().gameSettings;
				RayTraceResult mop = Minecraft.getMinecraft().objectMouseOver;
				if(mop != null){
					if(mop.entityHit == null){
						
					}else{
						if(mop.entityHit instanceof EntityEnderman){
							EntityEnderman target = (EntityEnderman) mop.entityHit;
							//System.out.println("found enderman");
							target.getEntityData().setInteger("NoAI", 1);
							//System.out.println(target.getEntityData().toString());
						}
					}
				}
			}
		}
	}
}

It detects the mob but the mob keeps moving around.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.