1.7.10 Monstre marin



  • Bonjour j'ai pour idée de crée un monstre marin donc qui attaque les joueur a porter tout le temps au début jais pris la classe du pouple en lui ajoutant quelque bout de code du zombie sans frant réussite mon monstre vas sous l'eau spawn dans l'eau m'attaque mais par contre si il y est au fond de l'eau il arrive pas a remonter dans l'eau bref j'ai besoin d'aide je vous met le bout de code même si il doit vous sembler affreux 😕
    je suis en 1.7.10 forge

    package com.onepice.mod.entity;
    
    import net.minecraft.block.material.Material;
    import net.minecraft.enchantment.EnchantmentHelper;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.SharedMonsterAttributes;
    import net.minecraft.entity.ai.EntityAIAttackOnCollide;
    import net.minecraft.entity.ai.EntityAIHurtByTarget;
    import net.minecraft.entity.ai.EntityAILookIdle;
    import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
    import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
    import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
    import net.minecraft.entity.ai.EntityAISwimming;
    import net.minecraft.entity.ai.EntityAIWander;
    import net.minecraft.entity.ai.EntityAIWatchClosest;
    import net.minecraft.entity.monster.EntityMob;
    import net.minecraft.entity.passive.EntityVillager;
    import net.minecraft.entity.passive.EntityWaterMob;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.EntityDamageSource;
    import net.minecraft.util.MathHelper;
    import net.minecraft.world.World;
    import net.minecraftforge.common.ForgeModContainer;
    
    
    
    
    
    
    public class entitymonstremarrin1 extends EntityWaterMob
    {
        private static final String __OBFID = "CL_00001651";
        private float rotationVelocity;
    
    
    
    
    
    public entitymonstremarrin1(World p_i1693_1_)
    {
        super(p_i1693_1_);
        this.setSize(0.95F, 0.95F);
        this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F;
        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 5.0D, false));
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 20.0F));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
    }
    
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6000000238418579D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.0D);
    }
    
    
    
    
    /**
     * Returns the sound this mob makes while it's alive.
     */
    
    /**
     * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack.
     */
    
    public void onEntityUpdate()
    {
        int i = this.getAir();
        super.onEntityUpdate();
    
        if (this.isEntityAlive() && !this.isInWater())
        {
            --i;
            this.setAir(i);
    
            if (this.getAir() == -20)
            {
                this.setAir(0);
                this.attackEntityFrom(DamageSource.drown, 2.0F);
            }
        }
        else
        {
            this.setAir(300);
        }
    }
    
    public boolean isInWater()
    {
        return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this);
    }
    
    
    
    
    public boolean getCanSpawnHere()
    {
        return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere();
    }
    
    protected Entity findPlayerToAttack()
    {
        EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
        return entityplayer != null && this.canEntityBeSeen(entityplayer) ? entityplayer : null;
    }
    
    /**
     * Called when the entity is attacked.
     */
    public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
    {
        if (this.isEntityInvulnerable())
        {
            return false;
        }
        else if (super.attackEntityFrom(p_70097_1_, p_70097_2_))
        {
            Entity entity = p_70097_1_.getEntity();
    
            if (this.riddenByEntity != entity && this.ridingEntity != entity)
            {
                if (entity != this)
                {
                    this.entityToAttack = entity;
                }
    
                return true;
            }
            else
            {
                return true;
            }
        }
        else
        {
            return false;
        }
    }
    
    public boolean attackEntityAsMob(Entity p_70652_1_)
    {
        float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
        int i = 0;
    
        if (p_70652_1_ instanceof EntityLivingBase)
        {
            f += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase)p_70652_1_);
            i += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase)p_70652_1_);
        }
    
        boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), f);
    
        if (flag)
        {
            if (i > 0)
            {
                p_70652_1_.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F));
                this.motionX *= 0.6D;
                this.motionZ *= 0.6D;
            }
    
            int j = EnchantmentHelper.getFireAspectModifier(this);
    
            if (j > 0)
            {
                p_70652_1_.setFire(j * 4);
            }
    
            if (p_70652_1_ instanceof EntityLivingBase)
            {
                EnchantmentHelper.func_151384_a((EntityLivingBase)p_70652_1_, this);
            }
    
            EnchantmentHelper.func_151385_b(this, p_70652_1_);
        }
    
        return flag;
    }
    
    /**
     * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack.
     */
    protected void attackEntity(Entity p_70785_1_, float p_70785_2_)
    {
        if (this.attackTime <= 0 && p_70785_2_ < 2.0F && p_70785_1_.boundingBox.maxY > this.boundingBox.minY && p_70785_1_.boundingBox.minY < this.boundingBox.maxY)
        {
            this.attackTime = 20;
            this.attackEntityAsMob(p_70785_1_);
        }
    }
    
    
    
    }
    

    Mercis d'avance bonne soirée


Log in to reply