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

    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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