Jump to content

[1.7.10] Entity Is Invulnerable Unless Hit With Damage Source


StarV

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Add crash-reports with sites like https://paste.ee/ Maybe an issue with blur, essentials or cumulus_menus
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have a problem, I am trying to put two different effects to two different armors but when I run it only the emerald armor effect works. This is the code public class ModArmorItem extends ArmorItem{ private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.OBSIDIAN, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); public ModArmorItem(ArmorMaterial pMaterial, Type pType, Properties pProperties) { super(pMaterial, pType, pProperties); } @Override public void onArmorTick(ItemStack stack, Level world, Player player){ if (!world.isClientSide()) { if (hasFullSuitOfArmorOn(player)) { evaluateArmorEffects(player); } } } private void evaluateArmorEffects(Player player) { for (Map.Entry<ArmorMaterial,MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()){ ArmorMaterial mapArmorMaterial = entry.getKey(); MobEffectInstance mapStatusEffect = entry.getValue(); if (hasCorrectArmorOn(mapArmorMaterial, player)) { addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect); } } } private void addStatusEffectForMaterial(Player player, ArmorMaterial mapArmorMaterial, MobEffectInstance mapStatusEffect) { boolean hasPlayerEffect = player.hasEffect(mapStatusEffect.getEffect()); if (hasCorrectArmorOn(mapArmorMaterial, player) && !hasPlayerEffect) { player.addEffect(new MobEffectInstance(mapStatusEffect)); } } private boolean hasCorrectArmorOn(ArmorMaterial material, Player player) { for (ItemStack armorStack : player.getInventory().armor){ if (!(armorStack.getItem() instanceof ArmorItem)) { return false; } } ArmorItem helmet = ((ArmorItem)player.getInventory().getArmor(3).getItem()); ArmorItem breastplace = ((ArmorItem)player.getInventory().getArmor(2).getItem()); ArmorItem leggins = ((ArmorItem)player.getInventory().getArmor(1).getItem()); ArmorItem boots = ((ArmorItem)player.getInventory().getArmor(0).getItem()); return helmet.getMaterial() == material && breastplace.getMaterial() == material && leggins.getMaterial() == material && boots.getMaterial() == material; } private boolean hasFullSuitOfArmorOn(Player player){ ItemStack helmet = player.getInventory().getArmor(3); ItemStack breastplace = player.getInventory().getArmor(2); ItemStack leggins = player.getInventory().getArmor(1); ItemStack boots = player.getInventory().getArmor(0); return !helmet.isEmpty() && !breastplace.isEmpty() && !leggins.isEmpty() && !boots.isEmpty(); } } Also when I place two effects on the same armor, the game crashes. Here is the crash file. The code is the same, only this part is different   private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.HERO_OF_THE_VILLAGE,200, 1,false,false, true)) .put(ModArmorMaterials.EMERALD, new MobEffectInstance(MobEffects.FIRE_RESISTANCE,200, 1,false,false, true)).build(); I hope you guys can help me. Thanks.
  • Topics

×
×
  • Create New...

Important Information

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