Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.4] Removing Mob AI
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Joshua66252

[1.16.4] Removing Mob AI

By Joshua66252, January 12 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Joshua66252    0

Joshua66252

Joshua66252    0

  • Tree Puncher
  • Joshua66252
  • Members
  • 0
  • 2 posts
Posted January 12

I'm Trying To Remove All AI From A Mob Currently I Have Removed All Goal Selector Goals But I'm Not Sure How To Go About Removing Target Selector Goals
This Is My Current Code

    public void handleZombie(Entity ent,EntityJoinWorldEvent event)
    {
        ZombieEntity castEnt=((ZombieEntity)ent);
        Set<PrioritizedGoal> goals = ObfuscationReflectionHelper.getPrivateValue(GoalSelector.class, castEnt.goalSelector, "goals");
        goals.clear();
    }


The Reason I Need To Remove Target Selector Goals Is Because If I Add

  castEnt.goalSelector.addGoal(2, new ZombieAttackGoal(castEnt, 1.0D, false));


It Will Start Attacking The Player

  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    160

ChampionAsh5357

ChampionAsh5357    160

  • World Shaper
  • ChampionAsh5357
  • Members
  • 160
  • 1017 posts
Posted Wednesday at 05:51 PM

Target selectors are a separate instance of GoalSelector. Also, read the documentation on ObfuscationReflectionHelper as you cannot provide a mapped name for a field. What you have currently will fail in production, not on userdev. I will assume your cast is hopefully checked as well, although why you do not supply a ZombieEntity for the parameter instead is questionable on if it is checked.

  • Quote

Share this post


Link to post
Share on other sites

Joshua66252    0

Joshua66252

Joshua66252    0

  • Tree Puncher
  • Joshua66252
  • Members
  • 0
  • 2 posts
Posted Wednesday at 09:40 PM (edited)
4 hours ago, ChampionAsh5357 said:

Target selectors are a separate instance of GoalSelector. Also, read the documentation on ObfuscationReflectionHelper as you cannot provide a mapped name for a field. What you have currently will fail in production, not on userdev. I will assume your cast is hopefully checked as well, although why you do not supply a ZombieEntity for the parameter instead is questionable on if it is checked.

    @SubscribeEvent
	public void entSpawn(EntityJoinWorldEvent event)
	{
		if (event.getEntity() instanceof ZombieEntity) handleZombie((ZombieEntity) event.getEntity(), event);
	}

It does Check If Its A Zombie This Is The Code For That

Edit: Btw Can You Please Send Me The Docs For ObfuscationReflectionHelper I Can't Find Them

Edited Wednesday at 10:13 PM by Joshua66252
  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    160

ChampionAsh5357

ChampionAsh5357    160

  • World Shaper
  • ChampionAsh5357
  • Members
  • 160
  • 1017 posts
Posted Thursday at 12:33 AM
2 hours ago, Joshua66252 said:

Edit: Btw Can You Please Send Me The Docs For ObfuscationReflectionHelper I Can't Find Them

They're on the class in the source itself. All javadocs are located there.

2 hours ago, Joshua66252 said:

It does Check If Its A Zombie This Is The Code For That

Then the cast inside the method is even more unnecessary as you're passing in a ZombieEntity and can make the parameter a ZombieEntity.

  • Quote

Share this post


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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Klarks
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks · Posted 3 minutes ago

      I don't understand. Where i should have container factory
    • Johnkakminecraft
      Mod Code Not Detecting Correct Version

      By Johnkakminecraft · Posted 1 hour ago

      Thank you so much. Don't know how I missed this.
    • DaemonUmbra
      Mod Code Not Detecting Correct Version

      By DaemonUmbra · Posted 2 hours ago

      https://paste.gg/p/anonymous/47eb336f970d400bb9f707d7aed7c776#pastefile1-l30 That's not a valid mod ID
    • DaemonUmbra
      tinkers crashing server

      By DaemonUmbra · Posted 2 hours ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • DaemonUmbra
      Forge Server Error

      By DaemonUmbra · Posted 2 hours ago

      Please provide the installer log. It will be named the same as the installer but with .log on the end: Installer: forge-<mc_version>-<forge_version>-installer.jar Log: forge-<mc_version>-<forge_version>-installer.jar.log   Note: Windows hides file extensions by default, so unless you have set it to show file extensions it may show as below: Installer: forge-<mc_version>-<forge_version>-installer Log: forge-<mc_version>-<forge_version>-installer.jar
  • Topics

    • Klarks
      30
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks
      Started Saturday at 09:56 PM

    • Johnkakminecraft
      6
      Mod Code Not Detecting Correct Version

      By Johnkakminecraft
      Started 4 hours ago

    • cammoschetti
      1
      tinkers crashing server

      By cammoschetti
      Started 2 hours ago

    • Darkbarracuda541
      1
      Forge Server Error

      By Darkbarracuda541
      Started 3 hours ago

    • Xenfo
      3
      Mod Blocker

      By Xenfo
      Started 9 hours ago

  • Who's Online (See full list)

    • FreshMod
    • BGames
    • Insanity_Alice
    • Klarks
    • Will11690
    • Cheezy Amuzus
    • TeuFox
    • Moon2288
    • ChampionAsh5357
    • DaemonUmbra
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.4] Removing Mob AI
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community