Jump to content

[1.15.2] Remove goal from creeper


TheBigCraftGuy

Recommended Posts

I am trying to remove the AvoidEntity goals for a creeper to make it not run away from ocelots. This is my code:

 

@Mod.EventBusSubscriber(modid = CreeperMod.MODID)
public class EntityChangeEvent {

    @SubscribeEvent
    public static void onSpawn(EntityJoinWorldEvent event) {
        if (event.getEntity() instanceof CreeperEntity) changeAI((CreeperEntity) event.getEntity(), event);
    }
	
	private static void changeAI(CreeperEntity entity) {
        if (entity.world != null && !entity.world.isRemote) {
            CreeperMod.LOGGER.info(entity.goalSelector.getRunningGoals().count());
            entity.goalSelector.getRunningGoals().forEach((action) -> {
                CreeperMod.LOGGER.info(action.getGoal());
                if (action.getGoal() instanceof AvoidEntityGoal) {
                    entity.goalSelector.removeGoal(action.getGoal());
                    CreeperMod.LOGGER.info("removed");
                }
            });
        }
    }

But it looks like the AvoidEntity goals are not running when the creeper is spawned. How would I remove those goals. Thanks

Link to comment
Share on other sites

3 hours ago, TheBigCraftGuy said:

changeAI((CreeperEntity) event.getEntity(), event);

This doesn't even compile.

3 hours ago, TheBigCraftGuy said:

But it looks like the AvoidEntity goals are not running when the creeper is spawned. How would I remove those goals. Thanks

The goal is only running when there is an OcelotEntity or a CatEntity nearby. You have to use Reflection to get the Goal out of the GoalSelector.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

This is my code so far but it doesn't seem to work

private static void changeAI(CreeperEntity entity) {
        if (entity.world != null && !entity.world.isRemote) {
            Set<PrioritizedGoal> goals = ObfuscationReflectionHelper.getPrivateValue(GoalSelector.class, entity.goalSelector, "goals");
            ChangeMod.LOGGER.info(goals);
            for (PrioritizedGoal goal: goals) {
                if (goal.getGoal() instanceof AvoidEntityGoal) {
                    entity.goalSelector.removeGoal(goal);
                    ChangeMod.LOGGER.info(goal.getGoal().toString());
                }
            }
            goals = ObfuscationReflectionHelper.getPrivateValue(GoalSelector.class, entity.goalSelector, "goals");
            ChangeMod.LOGGER.info(goals);
        }
    }

But the creepers still avoid them and the goals are the same length

Link to comment
Share on other sites

3 hours ago, TheBigCraftGuy said:

entity.goalSelector.removeGoal(goal);

It should be goal.getGoal()

 

Also you cannot iterate and remove an entry. You will get a ConcurrentModificationException. Use an iterator.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 关东俱乐部最新地址◀BCGAME55·COM▲关东俱乐部总经销网络游戏关东俱乐部网站壁球俱乐部推特赛艇比赛俱乐部新地址[本社文之电讯@JBOX7]关东俱乐部连接掰手腕俱乐部广播掷标枪俱乐部亚东花样游泳俱乐部队[总经销文之Kakao Talk JBOX7]关东俱乐部的系统掷铅球 关东俱乐部的位置足球俱乐部队优兔F1大奖赛[各种官方制作链接 制作 关东俱乐部的 短视频 度假村] 俱乐部招聘广告F1大奖赛俱乐部招聘广告[体育总公司]关东俱乐部视频Flag关东俱乐部位置掷标枪俱乐部Telegram游泳俱乐部YouTube[咨询]关东俱乐部最新地址棒球关东俱乐部旅行软网球俱乐部的总经销藤球俱乐部的推特[买关东总经销]关东俱乐部的位置网球俱乐部的网球拍打铁饼俱乐部的举办地功夫俱乐部的地址[赌场总经销]关东俱乐部的总经销诱导的Instagram跳水俱乐部的总经销网] Sparketarketakragram 棒球运动会的总经销社推特[买办地]关东总经销] 棒球比赛场  视频[赛马总经销]关东俱乐部最新地址篮球关东俱乐部网站铅球俱乐部链接拳击俱乐部视频[BCGAME BC游戏总经销咨询]设置通知推荐订阅点赞
    • How would I give an item (from my mod) lore? I overrode the appendHoverText method but I haven't been able to figure out how to add something to it.
    • 東南アジアグラフ バカラパブ☎BCGAME33·COM ㏂ アルメニアグラフ ゲームセンター東南アジアケニアグラフ本社[本社お問い合わせテレJBOX7]東南アジアグラフ†▨サイトブラジルグラフ本社東南アジアオマーン東南アジアグラフ方法[総販お問い合わせカカオトークJBOX7]東南アジアグラフ♤ 단グループチャットイエメングラフ旅行東南アジアイラン東南アジアグラフィック戦略[各種オフィコミュニティ制作]南東アグラフ◈●京畿ジンバブエ ギジンバブエ グラフ競技南東ア ロシア 東南アチャート遊び場[マーケティングお問い合わせ]南東アグラフ ¶△♨トーナメントガーナグラフ本社南東ア東亜 南ア東亜 南ア本社東南ア東亜南亜気候] [スポーツ本社]東南アジアグラフ♤▷住所 南アフリカグラフ キャッシュゲーム [カジノ総販]東南アジアパプアニューギニア東南アジアグラフリーグ [ト本社お問い合わせ]東南アジアグラフ☎◇YouTubeベルギーグラフ グループトーク東南アジア西ヨーロッパ東南アジアグラフ旅行 [ト総販購入]東南アジアグラフ☏▒ポーカー大会イラングラフ旅行東南アジア東アフリカ東アフリカ東アフリカ東南アグラフィキャッシュゲーム[カジノ総販]南東アグラフィックス ▦放送アルメニアグラフ旅行南東ア 遊び場 [ヤマト本社]南東アグラフィ▽↑クープーン スダンパーカ ラッパブ 南東ア リゾートワールドカジノ南東アグリッグプレート ツアー 北アメリカ グラフメーカー [BCGAME BCゲーム 総販に関するお問い合わせ] お知らせ設定 おすすめ購読いいですね
    • 东北棒球场开放聊天 §BCGAME55·COM*东北棒球场聚会信息拳击东北棒球场度假村旗舰棒球场视频水球棒球场视频Instagram[本社咨询的Tele @JBOX7]东北棒球场旅行自由式东北棒球场推荐曲棍球棒球场视频摔跤棒球比赛登陆[总经销的Kakao Talk JBOX7]东北棒球比赛视频世界杯滑冰比赛[推特 球洞 制作 棒球联谊会 棒球赛] 棒球巡回赛网络游戏东北棒球场链接足球棒球场故事板球棒球场TikTok[体育总公司]东北棒球场新地址功夫棒球场最新地址排球棒球场总经销软式网球棒球场TikTok[TOKO棒球场地图]拳击TokU棒球场地位置世界杯棒球场地度假村摔跤棒球场地最新地址[TOKO总经销购买] TokU棒球场地推特 Ring TokUKO棒球场地线棒球场地板[TikTok[TokUKO] 东北棒球场同好会平均台东北棒球场地图网球棒球场推荐曲棍球棒球场最新地址[赛马总经销]东北棒球场地址 匹克球 东北棒球场故事 硬地滚球棒球场 广播水球棒球场新地址[BCGAME BC游戏总经销咨询] 设置通知 推荐 订阅 点赞
    • 全世界バドゥギ本社▒BCGAME33·COM▒ザンビアバドゥギ クープーン全世界セーシェルバドゥギ住所[本社お問い合わせテレJBOX7]全世界バドゥギ◁↗グループトークアトランティスカジノバドゥギYouTube全世界バドゥギユーチューブ[総販売お問い合わせカカオトークJBOX7]全世界バドゥギ ]♨遊び場リオオールスイートカジノバドゥギ総販全世界のスロバキア全世界バージュ本社[各種オフィコミュニティ制作]全世界のバージュクープーンバージュクープーン 世界のサハラミジブータム前のサハラミのお問い合わせ [マーケティングサイトバージュブーンバージュ戦略サイトバー アトランティスカジノ全世界バドゥギ募集[スポーツ本社]全世界バドゥギ◁■総販モナコバドゥギ放送全世界イタリア全世界バドゥギグループトーク[ト本社お問い合わせ]全世界バドゥギ#№旅行ハンガリーバドゥギYouTube全世界ボツワナ全世界バドゥギグループトーク[トト総販購入]全世界バドゥギ☜#クープンベナンドバーホールダンバー 全世界ウルグアイ 全世界バージュサイト [カジノ総販] 全世界バージュ↑ªトーナメント フィリピンバートゥブ 全世界ネヴィス 世界ネヴィス旅行バージュブベリーズ動画 [競馬総販]ジョージアバドゥギ カジノパブ アルバニアバドゥギ放送 [BCGAME BCゲーム総販お問い合わせ] お知らせ設定おすすめ購読いいですね
  • Topics

×
×
  • Create New...

Important Information

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