Jump to content

[1.7.10] Entity Is Invulnerable Unless Hit With Damage Source


Recommended Posts

Posted

Hello. I am currently trying to make a mob that will only take damage if it is hit with a specific damage source. I have a sword that correctly deals "DamageSource.outOfWorld" damage, as I have tested it on a villager, which has 20 hit points, and the sword does 11 attack damage, and still kills it in one hit. I then have the mob, which should only take damage if the damage source is equal to outOfWorld, however I cannot hit it, as it is invulnerable to any attack, even the sword, which does work with the damage source. I believe the problem is that the entity is not registering it is being hit with the outOfWorld damage.

 

ItemOblivionSword.class

 

package com.starv.arcticarrival.item;

 

import com.starv.arcticarrival.Main;

 

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.item.ItemStack;

import net.minecraft.item.ItemSword;

import net.minecraft.util.DamageSource;

 

public class ItemOblivionSword extends ItemSword {

 

public ItemOblivionSword(String oblivionSword, ToolMaterial oblivion) {

        super(oblivion);

        this.setUnlocalizedName(oblivionSword);

        this.setTextureName(Main.MODID + ":" + "oblivionSword");

}

 

@Override

public boolean hitEntity(ItemStack itemstack, EntityLivingBase attackedEntity, EntityLivingBase attacker)

{

attackedEntity.attackEntityFrom(DamageSource.outOfWorld, 24.0F);

return super.hitEntity(itemstack, attackedEntity, attacker);

}

 

}

 

 

 

EntityOblivionCore.class

 

package com.starv.arcticarrival.entity;

 

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.boss.BossStatus;

import net.minecraft.entity.boss.IBossDisplayData;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.DamageSource;

import net.minecraft.world.World;

 

public class EntityOblivionCore extends EntityMob implements IBossDisplayData {

 

    public EntityOblivionCore(World par1World) {

        super(par1World);

        this.preventEntitySpawning = true;

        this.setSize(2.0F, 2.0F);

//        this.ignoreFrustumCheck = true;

        this.isImmuneToFire = true;

        this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

    }

   

    @Override

    public boolean attackEntityFrom(DamageSource damageSource, float damage)

    {

    if (damageSource == DamageSource.outOfWorld)

    {

    if (isEntityInvulnerable())

    {

    return false;

    }

    else

    {

    return true;

    }

    }

return false;

    }

   

    public boolean isAIEnabled()

    {

    return true;

    }

   

    public void setAggressive(boolean aggressive)

    {

        this.getDataWatcher().updateObject(21, Byte.valueOf((byte)(aggressive ? 1 : 0)));

    }

   

    public boolean canBePushed()

    {

        return false;

    }

   

    public void onLivingUpdate() {

super.onLivingUpdate();

BossStatus.setBossStatus(this, true);

    }

   

    protected String getLivingSound()

    {

    return null;

    }

   

    protected String getHurtSound()

    {

        return "mob.enderdragon.hit";

    }

   

    protected String getDeathSound()

    {

        return "mob.enderdragon.end";

    }

   

    protected void applyEntityAttributes()

    {

    super.applyEntityAttributes();

    getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(50.0F);

    getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.00D);

    getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D);

   

//    getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);

    getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);

    getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D);

}

           

    public boolean canBreath()

    {

        return true;

    }

   

    @Override

    protected boolean canDespawn()

    {

    return false;

    }   

}

 

 

I realize 1.7.10 is not supported, but this mod is for a modpack on the FTB launcher, and is for 1.7.10, and I cannot update it to further versions. I apologize if this causes any trouble.

Posted

Since this forum no longer supports 1.7.10 it will get locked when a mod gets on. Though I will give you a hint look at attackEntityFromDamageSource in other EntityLiving...class and you will find your issue. Any more 1.7.10- problems figurre them out yourself from previous tutorials/forum posts and of course from VANILLA SOURCE. Just thought I would stress that as it is the best source if you are making something similar.

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.

Posted

I realize 1.7.10 is not supported, but this mod is for a modpack on the FTB launcher, and is for 1.7.10, and I cannot update it to further versions. I apologize if this causes any trouble.

 

All this does is perpetuate the laziness of sticking to old versions. Just update and move on.

Posted

I realize 1.7.10 is not supported, but this mod is for a modpack on the FTB launcher, and is for 1.7.10, and I cannot update it to further versions. I apologize if this causes any trouble.

 

All this does is perpetuate the laziness of sticking to old versions. Just update and move on.

 

The problem is, this modpack relies on mods that are not being updated to versions further than 1.7.10, notably Enviromine. It isn't laziness, it's the inability to update at all.

Posted

I realize 1.7.10 is not supported, but this mod is for a modpack on the FTB launcher, and is for 1.7.10, and I cannot update it to further versions. I apologize if this causes any trouble.

 

All this does is perpetuate the laziness of sticking to old versions. Just update and move on.

 

The problem is, this modpack relies on mods that are not being updated to versions further than 1.7.10, notably Enviromine. It isn't laziness, it's the inability to update at all.

Yes, but it doesn't really matter as forge only supports modding final versions of Minecraft above 1.7.10. At current, but you should do what I said in my last post after me saying update.

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.

Posted
It isn't laziness, it's the inability to update at all.

Yes, it is laziness. You shouldn't rely on other mods, unless you are making an addon for that mod.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

It isn't laziness, it's the inability to update at all.

Yes, it is laziness. You shouldn't rely on other mods, unless you are making an addon for that mod.

 

This mod is for a modpack on the Feed the Beast launcher, and said modpack has a multitude of mods that are not yet updated past 1.7.10, so unless I'm allowed to update all of those mods, which I'm pretty sure I'm not, then I have to stick with 1.7.10.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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