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    161

ChampionAsh5357

ChampionAsh5357    161

  • World Shaper
  • ChampionAsh5357
  • Members
  • 161
  • 1021 posts
Posted January 13

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 January 13 (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 January 13 by Joshua66252
  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    161

ChampionAsh5357

ChampionAsh5357    161

  • World Shaper
  • ChampionAsh5357
  • Members
  • 161
  • 1021 posts
Posted January 14
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

    • diesieben07
      minecraft crashes as soon as I use shaders

      By diesieben07 · Posted 4 minutes ago

      Your graphics driver crashed. Make sure its up to date.
    • diesieben07
      My modpack takes years to load

      By diesieben07 · Posted 8 minutes ago

      Post the debug.log.
    • diesieben07
      [1.16.4] Custom item enchantability

      By diesieben07 · Posted 9 minutes ago

      A better way would be to use a Set (probably ImmutableSet in this case).
    • AzizD
      [1.16.4] Custom item enchantability

      By AzizD · Posted 27 minutes ago

      @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { Enchantment[] enchantments = { Enchantments.SHARPNESS, Enchantments.LOOTING, Enchantments.FIRE_ASPECT, Enchantments.UNBREAKING, Enchantments.KNOCKBACK, Enchantments.MENDING, }; for(int i=0;i<enchantments.length;i++){ if(enchantments[i] == enchantment){ return true; } } return false; }   I wrote this and it worked. Thx.
    • BBoi69
      My modpack takes years to load

      By BBoi69 · Posted 51 minutes ago

      So i wanted to play ATM6, but cuz my laptop cant handle all that, i made my Lite version with like half the mods. it ran a couple times already but then i decided to add just one more mod and now, it takes 7 years to load up. The nether background and MOJANG STUDIOS text is there and the white bar is about 8/10 full and it goes fast until that. the numbers in the left corner are moving digit by digit and it has been like this for the last hour. yes i restarted it already.
  • Topics

    • JoehnMama
      2
      minecraft crashes as soon as I use shaders

      By JoehnMama
      Started 3 hours ago

    • BBoi69
      1
      My modpack takes years to load

      By BBoi69
      Started 51 minutes ago

    • AzizD
      6
      [1.16.4] Custom item enchantability

      By AzizD
      Started 11 hours ago

    • SixSix
      1
      (1.16.4) Avalon, The Ragnarok is Here mod help.

      By SixSix
      Started December 24, 2020

    • Luis_ST
      6
      [1.16.5] Help with custom Glass Block

      By Luis_ST
      Started Friday at 07:35 AM

  • Who's Online (See full list)

    • diesieben07
    • XDKara
    • MrDuck20
    • kiou.23
    • AzizD
    • Choonster
    • Nitrix
    • BBoi69
  • 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