Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.16.5 How to register entity ai?

Recommended Posts

Hi again, I'm trying to create a custom living entity but I keep running into this issue that causes a crash due to a ticking entity.


[12:31:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.crash.ReportedException: Ticking entity
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:855) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] {}
Caused by: java.lang.NullPointerException
	at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:1905) ~[forge:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.aiStep(LivingEntity.java:2449) ~[forge:?] {re:classloading}
	at net.minecraft.entity.MobEntity.aiStep(MobEntity.java:488) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.AgeableEntity.aiStep(AgeableEntity.java:115) ~[forge:?] {re:classloading}
	at net.minecraft.entity.passive.AnimalEntity.aiStep(AnimalEntity.java:51) ~[forge:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2158) ~[forge:?] {re:classloading}
	at net.minecraft.entity.MobEntity.tick(MobEntity.java:300) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tickNonPassenger(ServerWorld.java:611) ~[forge:?] {re:classloading}
	at net.minecraft.world.World.guardEntityTick(World.java:554) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) ~[forge:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:851) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	... 5 more
AL lib: (EE) alc_cleanup: 1 device not closed

 It seems to be that I have not defined an ai/brain but I have no idea how to do this. I cant seem to see any event to do this in the library. 

Any help would be greatly appreciated.

Link to post
Share on other sites

Ok, so I seem to have registered goals for the entity but I still have the problem that whenever I spawn it the game crashes. Here is my entity class so far.

public class TestEntity extends CowEntity {

	public static final String REG = "simple_entity";
	public static final EntityType<TestEntity> TYPE = //Entity type builder
	public static final AttributeModifierMap MAP = //Entity Attribute builder
	public TestEntity(EntityType<? extends CowEntity> p_i48567_1_, World p_i48567_2_) {
		super(p_i48567_1_, p_i48567_2_);
		Main.LOGGER.debug("STAR - Entity Constructed");
	protected void registerGoals() {
		Main.LOGGER.debug("STAR - Entity Goals");
		this.goalSelector.addGoal(0, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT), false));

Any ideas why this error is still occurring.

Link to post
Share on other sites

You need to use EntityAttributeCreationEvent to register the attributes for your entity (CowEntity.createAttributes or make your own if you have additional attributes).


1 hour ago, henzo800 said:

public static final EntityType<TestEntity> TYPE = //Entity type builder

Do not create registry entries in static initializers. Use DeferredRegister or @ObjectHolder when using manual registry events.

  • Like 1
Link to post
Share on other sites

I used diesieben07 suggestion and got it all working.

I have included my completed entity for anyone who needs it.

Entity Class:

public class TestEntity extends CowEntity {

	public static final String REG = "simple_entity";

	public TestEntity(EntityType<? extends CowEntity> p_i48567_1_, World p_i48567_2_) {
		super(p_i48567_1_, p_i48567_2_);
		STAR.LOGGER.debug("STAR - Entity Constructed");
	public static AttributeModifierMap.MutableAttribute createAttributes() {
	      return MobEntity.createMobAttributes().add(Attributes.MAX_HEALTH, 0.5D)
	    		  .add(Attributes.MOVEMENT_SPEED, (double)0.2F)
	    		  .add(Attributes.FOLLOW_RANGE, 20.0)
	    		  .add(Attributes.ATTACK_DAMAGE, 20.0);
	protected void registerGoals() {
		STAR.LOGGER.debug("STAR - Entity Goals");
		this.goalSelector.addGoal(0, new TemptGoal(this, 1.25D, Ingredient.of(Items.WHEAT), false));

Entity register:

public class EntityRegister {
	public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, STAR.MODID);

	public static final RegistryObject<EntityType<TestEntity>> TESTENTITY = ENTITIES.register(TestEntity.REG, () -> EntityType.Builder.<TestEntity>of(TestEntity::new, EntityClassification.MISC)
			.sized(0.98F, 0.7F)

Thanks for all your help.

Link to post
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.

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.

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • The durability of my custom Item goes down only for a second then goes back to where it was before I clicked. I'd really appreciate if someone can point me in the right direction to get this working. @Override public ActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) { ItemStack stack = playerEntity.getItemInHand(hand); if (!world.isClientSide) { ItemStack newStack = new ItemStack(stack.getItem()); newStack.setDamageValue(stack.getDamageValue() + 1); return ActionResult.success(newStack); } else return super.use(world, playerEntity, hand); }
    • biome.getRegistryName().equals(Biomes.SWAMP.location())  
    • Java 16 is not yet supported.
    • It is about the Java version. You cannot use Java 16. 
    • C:\Users\rauno\OneDrive\Töölaud\Uus kaust>java -Xmx2048M -Xms2048M -jar forgeserver.jar nogui 2021-06-21 10:09:17,374 main WARN Advanced terminal features are not available in this environment [10:09:17] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.0, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [10:09:17] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 16.0.1 by Oracle Corporation Exception in thread "main" java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x29f69090) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x29f69090         at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:41)         at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)         at cpw.mods.modlauncher.SecureJarHandler.<clinit>(SecureJarHandler.java:41)         at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)         at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)         at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)         at cpw.mods.modlauncher.Launcher.<init>(Launcher.java:55)         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\rauno\OneDrive\Töölaud\Uus kaust>PAUSE is it saying for me when i am first opening it 
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.