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
  • Dig Mob Function (Like in Mo'Creatures)
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
OrcaWorld

Dig Mob Function (Like in Mo'Creatures)

By OrcaWorld, September 11, 2020 in Modder Support

  • Start new topic

Recommended Posts

OrcaWorld    1

OrcaWorld

OrcaWorld    1

  • Tree Puncher
  • OrcaWorld
  • Members
  • 1
  • 28 posts
Posted September 11, 2020

Heyo, everyone! I'm back but withnouth crash report. I made a mole for my mod and I wanted to make dig function for him (like in Mo'Creatures). But I don't know any of functions in his AI.

 

Mo'Creatures Mole AI:

 

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package drzhark.mocreatures.entity.passive;

import drzhark.mocreatures.MoCTools;
import drzhark.mocreatures.MoCreatures;
import drzhark.mocreatures.entity.MoCEntityTameableAnimal;
import drzhark.mocreatures.entity.ai.EntityAIWanderMoC2;
import drzhark.mocreatures.init.MoCItems;
import drzhark.mocreatures.init.MoCSoundEvents;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public class MoCEntityMole extends MoCEntityTameableAnimal {
    private static final DataParameter<Integer> MOLE_STATE;

    public MoCEntityMole(World world) {
        super(world);
        this.func_70105_a(1.0F, 0.5F);
    }

    protected void func_184651_r() {
        this.field_70714_bg.func_75776_a(1, new EntityAISwimming(this));
        this.field_70714_bg.func_75776_a(2, new EntityAIWanderMoC2(this, 1.0D));
        this.field_70714_bg.func_75776_a(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    }

    protected void func_110147_ax() {
        super.func_110147_ax();
        this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(10.0D);
        this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.2D);
    }

    public ResourceLocation getTexture() {
        return MoCreatures.proxy.getTexture("mole.png");
    }

    protected void func_70088_a() {
        super.func_70088_a();
        this.field_70180_af.func_187214_a(MOLE_STATE, 0);
    }

    public boolean isOnDirt() {
        Block block = this.field_70170_p.func_180495_p(new BlockPos(MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.func_174813_aQ().field_72338_b - 0.5D), MathHelper.func_76128_c(this.field_70161_v))).func_177230_c();
        return this.isDiggableBlock(Block.func_149682_b(block));
    }

    private boolean isDiggableBlock(int i) {
        return i == 2 | i == 3 | i == 12;
    }

    private void digForward() {
        double coordY = this.field_70163_u;
        double coordZ = this.field_70161_v;
        double coordX = this.field_70165_t;
        int x = 1;
        double newPosY = coordY - Math.cos((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x;
        double newPosX = coordX + Math.cos((double)(MoCTools.realAngle(this.field_70177_z - 90.0F) / 57.29578F)) * Math.sin((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x;
        double newPosZ = coordZ + Math.sin((double)(MoCTools.realAngle(this.field_70177_z - 90.0F) / 57.29578F)) * Math.sin((double)((this.field_70125_A - 90.0F) / 57.29578F)) * (double)x;
        Block block = this.field_70170_p.func_180495_p(new BlockPos(MathHelper.func_76128_c(newPosX), MathHelper.func_76128_c(newPosY), MathHelper.func_76128_c(newPosZ))).func_177230_c();
        if (this.isDiggableBlock(Block.func_149682_b(block))) {
            this.func_70107_b(newPosX, newPosY, newPosZ);
        }

    }

    public int getState() {
        return (Integer)this.field_70180_af.func_187225_a(MOLE_STATE);
    }

    public void setState(int i) {
        this.field_70180_af.func_187227_b(MOLE_STATE, i);
    }

    public float pitchRotationOffset() {
        int i = this.getState();
        switch(i) {
        case 0:
            return 0.0F;
        case 1:
            return -45.0F;
        case 2:
            return 0.0F;
        case 3:
            return 60.0F;
        default:
            return 0.0F;
        }
    }

    public float getAdjustedYOffset() {
        int i = this.getState();
        switch(i) {
        case 0:
            return 0.0F;
        case 1:
            return 0.3F;
        case 2:
            return 1.0F;
        case 3:
            return 0.1F;
        default:
            return 0.0F;
        }
    }

    public void func_70636_d() {
        super.func_70636_d();
        if (!this.field_70170_p.field_72995_K) {
            if (this.field_70146_Z.nextInt(10) == 0 && this.getState() == 1) {
                this.setState(2);
            }

            if (this.getState() != 2 && this.getState() != 1 && this.isOnDirt()) {
                EntityLivingBase entityliving = this.getBoogey(4.0D);
                if (entityliving != null && this.func_70685_l(entityliving)) {
                    this.setState(1);
                    this.func_70661_as().func_75499_g();
                }
            }

            if (this.field_70146_Z.nextInt(20) == 0 && this.getState() == 2 && this.getBoogey(4.0D) == null) {
                this.setState(3);
                this.func_70661_as().func_75499_g();
            }

            if (this.getState() != 0 && !this.isOnDirt()) {
                this.setState(0);
            }

            if (this.field_70146_Z.nextInt(30) == 0 && this.getState() == 3) {
                this.setState(2);
            }

            if (this.getState() != 1 && this.getState() != 2) {
                this.func_70031_b(false);
            } else {
                this.func_70031_b(true);
            }
        }

    }

    public boolean isMovementCeased() {
        return this.getState() == 1 || this.getState() == 3;
    }

    public boolean func_70097_a(DamageSource damagesource, float i) {
        return this.getState() != 2 ? super.func_70097_a(damagesource, i) : false;
    }

    public boolean func_70067_L() {
        return this.getState() != 2;
    }

    public boolean func_70104_M() {
        return this.getState() != 2;
    }

    protected void func_82167_n(Entity par1Entity) {
        if (this.getState() != 2) {
            super.func_82167_n(par1Entity);
        }

    }

    public boolean func_70094_T() {
        return this.getState() == 2 ? false : super.func_70094_T();
    }

    public void func_70645_a(DamageSource damagesource) {
        super.func_70645_a(damagesource);
    }

    public boolean func_180431_b(DamageSource source) {
        return this.getState() == 2 ? true : super.func_180431_b(source);
    }

    protected Item func_146068_u() {
        return MoCItems.fur;
    }

    protected SoundEvent func_184615_bR() {
        return MoCSoundEvents.ENTITY_RABBIT_DEATH;
    }

    protected SoundEvent func_184601_bQ(DamageSource source) {
        return MoCSoundEvents.ENTITY_RABBIT_HURT;
    }

    protected SoundEvent func_184639_G() {
        return null;
    }

    static {
        MOLE_STATE = EntityDataManager.func_187226_a(MoCEntityMole.class, DataSerializers.field_187192_b);
    }
}

 

PS. I know most of functions. I need help from you , while func_70088_a. Yeah I know , that some function can be not work in 1.16 versions, but I hope that some of you can help me with making this interesting function.

 

Sorry for my English (I'm from Russia)

Share this post


Link to post
Share on other sites

diesieben07    7583

diesieben07

diesieben07    7583

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7583
  • 54909 posts
Posted September 11, 2020

1.12 is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      whenever I join a server it shows me this error

      By diesieben07 · Posted 12 minutes ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      Cant Get a Config File Working 1.16.5

      By diesieben07 · Posted 13 minutes ago

      Git is not the right way to store worlds or other large files.   There is no such line in the repository you posted. I used the debugger and put a breakpoint in the FMLCommonSetupEvent handler. Then I used evaluate expression and ArmorConfig.COMMON.enableOakWood.get() was false, as expected.
    • gamer650xd
      whenever I join a server it shows me this error

      By gamer650xd · Posted 17 minutes ago

      crash-2021-01-16_21.37.09-client.txt
    • Bailym
      Cant Get a Config File Working 1.16.5

      By Bailym · Posted 18 minutes ago

      I initially removed the .gitignore because i wanted to preserve the world saves, ill add it back in with the necessary exceptions.   Just to clarify. If you set enableOakWood to false in extraarmor-common.toml the line    System.out.println(ArmorConfig.COMMON.enableOakWood.get()); //Always True   returns false as expected? As i'm not getting the same behavior
    • gamer650xd
      whenever I join a server it shows me this error

      By gamer650xd · Posted 21 minutes ago

      internal exception: com.google.common.util.concurrent.UncheckedExecutionException:net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Minecraft Forge (forge)   crash-2021-01-16_21.37.09-client.txt
  • Topics

    • gamer650xd
      2
      whenever I join a server it shows me this error

      By gamer650xd
      Started 21 minutes ago

    • Bailym
      11
      Cant Get a Config File Working 1.16.5

      By Bailym
      Started 1 hour ago

    • e2rifia
      4
      (1.16.2) How do I use onPlayerTick?

      By e2rifia
      Started 3 hours ago

    • kiou.23
      11
      [1.16] Custom Sign won't render

      By kiou.23
      Started 9 hours ago

    • Ipsissimus418
      1
      [1.16.4] WorldTickEvent Concurrent Access Exception

      By Ipsissimus418
      Started 46 minutes ago

  • Who's Online (See full list)

    • diesieben07
    • kreezxil
    • JackRaidenPH
    • qwepo
    • Caaruzo
    • Telmoun
    • st4s1k
    • e2rifia
    • Talp1
    • Bailym
    • LeoBeliik
    • Kikoz
    • Beethoven92
    • Pl00py_R
    • gamer650xd
    • vemerion
    • KickPotato
    • Boetam
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Dig Mob Function (Like in Mo'Creatures)
  • Theme

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