Posted June 12, 20187 yr Im trying to disable an entities ai under certain circumstances. As of now i tried to do it with potions. i do not want to do entity#setNoAI as that also disables general movement of it (means it floats in midair and stuff). EntityLiving#tasks has a control flag but due to call order even if i set it in my potion it gets cancelled (or maybe i did it wrong). Is there any way to disable the execution of the ai from an entity? This is my current potion class: Spoiler package com.flemmli97.runecraftory.common.potion; import com.flemmli97.runecraftory.common.lib.LibReference; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AbstractAttributeMap; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; public class PotionSleep extends Potion{ public PotionSleep() { super(true, 0); this.setPotionName("sleep"); this.setRegistryName(new ResourceLocation(LibReference.MODID, "sleep")); } public void removeAttributesModifiersFromEntity(EntityLivingBase entity, AbstractAttributeMap attributeMapIn, int amplifier) { if(entity instanceof EntityLiving) { //((EntityLiving)entity).tasks.setControlFlag(1, false); //((EntityLiving)entity).tasks.setControlFlag(4, false); //((EntityLiving)entity).tasks.setControlFlag(8, false); } //((EntityLiving)entityLivingBaseIn).setNoAI(false); super.removeAttributesModifiersFromEntity(entity, attributeMapIn, amplifier); } public boolean isReady(int duration, int amplifier) { return true; } @Override public void performEffect(EntityLivingBase entity, int amplifier) { if(entity instanceof EntityLiving) { //For testing //((EntityLiving)entity).tasks.setControlFlag(1, true); //((EntityLiving)entity).tasks.setControlFlag(4, true); //((EntityLiving)entity).tasks.setControlFlag(2, true); //this should disable all entity ai ((EntityLiving)entity).tasks.setControlFlag(8, true); ((EntityLiving)entity).targetTasks.setControlFlag(8, true); } } public void applyAttributesModifiersToEntity(EntityLivingBase entity, AbstractAttributeMap attributeMapIn, int amplifier) { //((EntityLiving)entity).tasks //((EntityLiving)entity).setNoAI(true); super.applyAttributesModifiersToEntity(entity, attributeMapIn, amplifier); } } Edited September 7, 20187 yr by Flemmli97
June 12, 20187 yr I would create a new task, add it with priority 0, and have it use a mutex flag value of 0xFFFFFF. That would prevent other tasks from running. Edited June 12, 20187 yr by Draco18s Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.