Jump to content

Dig Mob Function (Like in Mo'Creatures)


OrcaWorld

Recommended Posts

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)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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