Jump to content

Adding Attacks To mobs !!!NOT WORKING!!


junzuke

Recommended Posts

Hello all  sorry if this has already been solved  . but i have been trying  to add  attack to my mob  "Guard"

however no luck so far  maybe i haven't done enough  but this is really getting to me. 

i think Im making the mob passive  but don't  Know  how to change that please help  in new to modding and iv come back to after a while of frustration and failed attempts thanks  in advance  code  from baseMod and the GuardMod files  is below

 

 

 

BaseMod

 

 

 

ackage mcmkingdoms.mod.guard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class Guard extends EntityMob
{
public Guard(World par1World)
{
     super(par1World);
     this.setSize(0.9F, 1.3F);
     this.getNavigator().setAvoidsWater(true);
     this.tasks.addTask(0, new EntityAISwimming(this));
     this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
     this.tasks.addTask(3, new EntityAILookIdle(this));
     this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
     this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    

}
/**
     * Returns true if the newer Entity AI code should be run
     */
public boolean isAIEnabled()
{
     return true;
}
protected void applyEntityAttributes()
{
     super.applyEntityAttributes();
     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(50.0D);
     this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);
     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(5.0D);
}

public int getTotalArmorValue()
{
     int i = super.getTotalArmorValue() + 2;
     if (i > 20)
     {
         i = 20;
     }
     return i;
}
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
     if (this.isEntityInvulnerable())
     {
         return false;
     }
     else
     {
         Entity entity = par1DamageSource.getEntity();
        
         if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
         {
             par2 = (par2 + 1.0F) / 2.0F;
         }
         return super.attackEntityFrom(par1DamageSource, par2);
     }
}
    

/**
     * Returns the sound this mob makes while it's alive.
     */
protected String getLivingSound()
{
     return "mob.cow.say";
}
/**
     * Returns the sound this mob makes when it is hurt.
     */
protected String getHurtSound()
{
     return "mob.cow.hurt";
}
/**
     * Returns the sound this mob makes on death.
     */
protected String getDeathSound()
{
     return "mob.cow.hurt";
}
/**
     * Plays step sound at given x, y, z for the entity
     */
protected void playStepSound(int par1, int par2, int par3, int par4)
{
     this.playSound("mob.cow.step", 0.15F, 1.0F);
}
/**
     * Returns the volume for the sounds this mob makes.
     */
protected float getSoundVolume()
{
     return 0.4F;
}
/**
     * Returns the item ID for the item the mob drops on death.
     */
protected int getDropItemId()
{
     return Item.legsIron.itemID;
}
// sets Armour/Weapons the mob is using
public void setCurrentItemOrArmor(int par1, ItemStack ItemStack)
{
     super.setCurrentItemOrArmor(par1,ItemStack);
}

{
     this.setCurrentItemOrArmor(0, new ItemStack(Item.swordIron));
     this.setCurrentItemOrArmor(1, new ItemStack(Item.helmetIron));
     this.setCurrentItemOrArmor(2, new ItemStack(Item.bootsIron));
     this.setCurrentItemOrArmor(3, new ItemStack(Item.plateIron));
     this.setCurrentItemOrArmor(4, new ItemStack(Item.legsIron));
    
}
}

 

 

 

 

GuardMod

 

 

 

 

package mcmkingdoms.mod;
import mcmkingdoms.mod.guard.Guard;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
//import cpw.mods.fml.common.Mod.PreInit; // used in 1.5.2
//import cpw.mods.fml.common.Mod.Init;     // used in 1.5.2
//import cpw.mods.fml.common.Mod.PostInit; // used in 1.5.2
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid= McmkingdomsInfo.ID , name= McmkingdomsInfo.NAME , version= McmkingdomsInfo.VERS)
@NetworkMod(clientSideRequired=true)
public class basemod {

public EnumToolMaterial hardenedIron = EnumHelper.addToolMaterial("Hardened Iron", 3, 20000,9.0f , 9.0f, 20);
//tools

//public final Item longSword = new LongSword(502,hardenedIron).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("LongSword").setTextureName("mod:strongstone");
public final static Block StrongStone = new StrongStone(500,Material.rock).setHardness(100000.f).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("StrongStone").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongstone");
public final static Item FirstItem = new FirstItem(5000);
public final static Item flagItem = new FlagItem(5005).setTextureName("mod:flag");
public final static Block StrongGlass = new FirstBlock(4095,Material.glass).setHardness(100000.f).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("StrongGlass").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongglass4");
//public final static Item HardenedIron = new FirstItem (5001).setMaxStackSize(64).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("HardenedIron").setTextureName("mod:test");


// The instance of your mod that Forge uses.
     @Instance(value = McmkingdomsInfo.NAME)
     public static basemod instance;
    
     // Says where the client and server 'proxy' code is loaded.
     @SidedProxy(clientSide="mcmkingdoms.mod.client.clientProxy", serverSide="mcmkingdoms.mod.CommonProxy")
     public static CommonProxy proxy;
    
     @EventHandler // used in 1.6.2
     //@PreInit // used in 1.5.2
     public void preInit(FMLPreInitializationEvent event) {
             // Stub Method
     }
    
     @EventHandler // used in 1.6.2
     //@Init     // used in 1.5.2
     public void load(FMLInitializationEvent event) {
             proxy.registerRenderers();
            
         // GameRegistry.registerItem(longSword,"LongSword");
         // LanguageRegistry.addName(longSword ,"Long Sword");
            
            
            
             GameRegistry.registerBlock(StrongStone,"StrongStone");
             LanguageRegistry.addName(StrongStone ,"Strong Stone");
            
             GameRegistry.registerItem(flagItem,"Flag");
             LanguageRegistry.addName(flagItem ,"Flag");
            
             GameRegistry.registerBlock(StrongGlass, "StrongGlass");
             LanguageRegistry.addName(StrongGlass ,"Strong Glass");
            
             MinecraftForge.setBlockHarvestLevel(StrongStone,"Pickaxe",3);
             MinecraftForge.setBlockHarvestLevel(StrongGlass,"Pickaxe",2);
            
             //mob
            
             registerEntity(Guard.class,"Gaurd",0xeaeae9, 0xc99a03);
             LanguageRegistry.instance().addStringLocalization("entity.gaurd.name","Gaurd");
     }
             public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
                 int id = EntityRegistry.findGlobalUniqueEntityId();

                 EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
                 EntityList.entityEggs.put(Integer.valueOf(id), new EntityEggInfo(id, bkEggColor, fgEggColor));
         }

         public void addSpawn(Class<? extends EntityLiving> entityClass, int spawnProb, int min, int max, BiomeGenBase[] biomes) {
                 if (spawnProb > 0) {
                         EntityRegistry.addSpawn(entityClass, spawnProb, min, max, EnumCreatureType.monster, biomes);
                 }
         }
                            
     //     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
     //     GameRegistry.registerBlock(StrongStoneStair,"StrongStone");
     //     LanguageRegistry.addName(StrongStoneStair ,"Strong Stone Stair");
        
//     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
            
    
    
     @EventHandler // used in 1.6.2
     //@PostInit // used in 1.5.2
     public void postInit(FMLPostInitializationEvent event) {
             // Stub Method
     }
}

 

 

Link to comment
Share on other sites

  • 1 month later...

Hello all  sorry if this has already been solved  . but i have been trying  to add  attack to my mob  "Guard"

however no luck so far  maybe i haven't done enough  but this is really getting to me. 

i think Im making the mob passive  but don't  Know  how to change that please help  in new to modding and iv come back to after a while of frustration and failed attempts thanks  in advance  code  from baseMod and the GuardMod files  is below

 

 

 

BaseMod

 

 

 

ackage mcmkingdoms.mod.guard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class Guard extends EntityMob
{
public Guard(World par1World)
{
     super(par1World);
     this.setSize(0.9F, 1.3F);
     this.getNavigator().setAvoidsWater(true);
     this.tasks.addTask(0, new EntityAISwimming(this));
     this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
     this.tasks.addTask(3, new EntityAILookIdle(this));
     this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
     this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    

}
/**
     * Returns true if the newer Entity AI code should be run
     */
public boolean isAIEnabled()
{
     return true;
}
protected void applyEntityAttributes()
{
     super.applyEntityAttributes();
     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(50.0D);
     this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);
     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(5.0D);
}

public int getTotalArmorValue()
{
     int i = super.getTotalArmorValue() + 2;
     if (i > 20)
     {
         i = 20;
     }
     return i;
}
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
     if (this.isEntityInvulnerable())
     {
         return false;
     }
     else
     {
         Entity entity = par1DamageSource.getEntity();
        
         if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
         {
             par2 = (par2 + 1.0F) / 2.0F;
         }
         return super.attackEntityFrom(par1DamageSource, par2);
     }
}
    

/**
     * Returns the sound this mob makes while it's alive.
     */
protected String getLivingSound()
{
     return "mob.cow.say";
}
/**
     * Returns the sound this mob makes when it is hurt.
     */
protected String getHurtSound()
{
     return "mob.cow.hurt";
}
/**
     * Returns the sound this mob makes on death.
     */
protected String getDeathSound()
{
     return "mob.cow.hurt";
}
/**
     * Plays step sound at given x, y, z for the entity
     */
protected void playStepSound(int par1, int par2, int par3, int par4)
{
     this.playSound("mob.cow.step", 0.15F, 1.0F);
}
/**
     * Returns the volume for the sounds this mob makes.
     */
protected float getSoundVolume()
{
     return 0.4F;
}
/**
     * Returns the item ID for the item the mob drops on death.
     */
protected int getDropItemId()
{
     return Item.legsIron.itemID;
}
// sets Armour/Weapons the mob is using
public void setCurrentItemOrArmor(int par1, ItemStack ItemStack)
{
     super.setCurrentItemOrArmor(par1,ItemStack);
}

{
     this.setCurrentItemOrArmor(0, new ItemStack(Item.swordIron));
     this.setCurrentItemOrArmor(1, new ItemStack(Item.helmetIron));
     this.setCurrentItemOrArmor(2, new ItemStack(Item.bootsIron));
     this.setCurrentItemOrArmor(3, new ItemStack(Item.plateIron));
     this.setCurrentItemOrArmor(4, new ItemStack(Item.legsIron));
    
}
}

 

 

 

 

GuardMod

 

 

 

 

package mcmkingdoms.mod;
import mcmkingdoms.mod.guard.Guard;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
//import cpw.mods.fml.common.Mod.PreInit; // used in 1.5.2
//import cpw.mods.fml.common.Mod.Init;     // used in 1.5.2
//import cpw.mods.fml.common.Mod.PostInit; // used in 1.5.2
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid= McmkingdomsInfo.ID , name= McmkingdomsInfo.NAME , version= McmkingdomsInfo.VERS)
@NetworkMod(clientSideRequired=true)
public class basemod {

public EnumToolMaterial hardenedIron = EnumHelper.addToolMaterial("Hardened Iron", 3, 20000,9.0f , 9.0f, 20);
//tools

//public final Item longSword = new LongSword(502,hardenedIron).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("LongSword").setTextureName("mod:strongstone");
public final static Block StrongStone = new StrongStone(500,Material.rock).setHardness(100000.f).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("StrongStone").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongstone");
public final static Item FirstItem = new FirstItem(5000);
public final static Item flagItem = new FlagItem(5005).setTextureName("mod:flag");
public final static Block StrongGlass = new FirstBlock(4095,Material.glass).setHardness(100000.f).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("StrongGlass").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongglass4");
//public final static Item HardenedIron = new FirstItem (5001).setMaxStackSize(64).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("HardenedIron").setTextureName("mod:test");


// The instance of your mod that Forge uses.
     @Instance(value = McmkingdomsInfo.NAME)
     public static basemod instance;
    
     // Says where the client and server 'proxy' code is loaded.
     @SidedProxy(clientSide="mcmkingdoms.mod.client.clientProxy", serverSide="mcmkingdoms.mod.CommonProxy")
     public static CommonProxy proxy;
    
     @EventHandler // used in 1.6.2
     //@PreInit // used in 1.5.2
     public void preInit(FMLPreInitializationEvent event) {
             // Stub Method
     }
    
     @EventHandler // used in 1.6.2
     //@Init     // used in 1.5.2
     public void load(FMLInitializationEvent event) {
             proxy.registerRenderers();
            
         // GameRegistry.registerItem(longSword,"LongSword");
         // LanguageRegistry.addName(longSword ,"Long Sword");
            
            
            
             GameRegistry.registerBlock(StrongStone,"StrongStone");
             LanguageRegistry.addName(StrongStone ,"Strong Stone");
            
             GameRegistry.registerItem(flagItem,"Flag");
             LanguageRegistry.addName(flagItem ,"Flag");
            
             GameRegistry.registerBlock(StrongGlass, "StrongGlass");
             LanguageRegistry.addName(StrongGlass ,"Strong Glass");
            
             MinecraftForge.setBlockHarvestLevel(StrongStone,"Pickaxe",3);
             MinecraftForge.setBlockHarvestLevel(StrongGlass,"Pickaxe",2);
            
             //mob
            
             registerEntity(Guard.class,"Gaurd",0xeaeae9, 0xc99a03);
             LanguageRegistry.instance().addStringLocalization("entity.gaurd.name","Gaurd");
     }
             public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
                 int id = EntityRegistry.findGlobalUniqueEntityId();

                 EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
                 EntityList.entityEggs.put(Integer.valueOf(id), new EntityEggInfo(id, bkEggColor, fgEggColor));
         }

         public void addSpawn(Class<? extends EntityLiving> entityClass, int spawnProb, int min, int max, BiomeGenBase[] biomes) {
                 if (spawnProb > 0) {
                         EntityRegistry.addSpawn(entityClass, spawnProb, min, max, EnumCreatureType.monster, biomes);
                 }
         }
                            
     //     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
     //     GameRegistry.registerBlock(StrongStoneStair,"StrongStone");
     //     LanguageRegistry.addName(StrongStoneStair ,"Strong Stone Stair");
        
//     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
            
    
    
     @EventHandler // used in 1.6.2
     //@PostInit // used in 1.5.2
     public void postInit(FMLPostInitializationEvent event) {
             // Stub Method
     }
}

 

 

 

Try to use that tags in your mob class:

this.tasks.addTask(1, new EntityAIFollowCalled(this, this.moveSpeed, 5.0F, 2.0F));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,EntityPlayer.class, 25.0F, 0, true));

Link to comment
Share on other sites

Hello all  sorry if this has already been solved  . but i have been trying  to add  attack to my mob  "Guard"

however no luck so far  maybe i haven't done enough  but this is really getting to me. 

i think Im making the mob passive  but don't  Know  how to change that please help  in new to modding and iv come back to after a while of frustration and failed attempts thanks  in advance  code  from baseMod and the GuardMod files  is below

 

 

 

BaseMod

 

 

 

ackage mcmkingdoms.mod.guard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
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.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class Guard extends EntityMob
{
public Guard(World par1World)
{
     super(par1World);
     this.setSize(0.9F, 1.3F);
     this.getNavigator().setAvoidsWater(true);
     this.tasks.addTask(0, new EntityAISwimming(this));
     this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
     this.tasks.addTask(3, new EntityAILookIdle(this));
     this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
     this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    

}
/**
     * Returns true if the newer Entity AI code should be run
     */
public boolean isAIEnabled()
{
     return true;
}
protected void applyEntityAttributes()
{
     super.applyEntityAttributes();
     this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(50.0D);
     this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);
     this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(5.0D);
}

public int getTotalArmorValue()
{
     int i = super.getTotalArmorValue() + 2;
     if (i > 20)
     {
         i = 20;
     }
     return i;
}
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
     if (this.isEntityInvulnerable())
     {
         return false;
     }
     else
     {
         Entity entity = par1DamageSource.getEntity();
        
         if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
         {
             par2 = (par2 + 1.0F) / 2.0F;
         }
         return super.attackEntityFrom(par1DamageSource, par2);
     }
}
    

/**
     * Returns the sound this mob makes while it's alive.
     */
protected String getLivingSound()
{
     return "mob.cow.say";
}
/**
     * Returns the sound this mob makes when it is hurt.
     */
protected String getHurtSound()
{
     return "mob.cow.hurt";
}
/**
     * Returns the sound this mob makes on death.
     */
protected String getDeathSound()
{
     return "mob.cow.hurt";
}
/**
     * Plays step sound at given x, y, z for the entity
     */
protected void playStepSound(int par1, int par2, int par3, int par4)
{
     this.playSound("mob.cow.step", 0.15F, 1.0F);
}
/**
     * Returns the volume for the sounds this mob makes.
     */
protected float getSoundVolume()
{
     return 0.4F;
}
/**
     * Returns the item ID for the item the mob drops on death.
     */
protected int getDropItemId()
{
     return Item.legsIron.itemID;
}
// sets Armour/Weapons the mob is using
public void setCurrentItemOrArmor(int par1, ItemStack ItemStack)
{
     super.setCurrentItemOrArmor(par1,ItemStack);
}

{
     this.setCurrentItemOrArmor(0, new ItemStack(Item.swordIron));
     this.setCurrentItemOrArmor(1, new ItemStack(Item.helmetIron));
     this.setCurrentItemOrArmor(2, new ItemStack(Item.bootsIron));
     this.setCurrentItemOrArmor(3, new ItemStack(Item.plateIron));
     this.setCurrentItemOrArmor(4, new ItemStack(Item.legsIron));
    
}
}

 

 

 

 

GuardMod

 

 

 

 

package mcmkingdoms.mod;
import mcmkingdoms.mod.guard.Guard;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
//import cpw.mods.fml.common.Mod.PreInit; // used in 1.5.2
//import cpw.mods.fml.common.Mod.Init;     // used in 1.5.2
//import cpw.mods.fml.common.Mod.PostInit; // used in 1.5.2
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid= McmkingdomsInfo.ID , name= McmkingdomsInfo.NAME , version= McmkingdomsInfo.VERS)
@NetworkMod(clientSideRequired=true)
public class basemod {

public EnumToolMaterial hardenedIron = EnumHelper.addToolMaterial("Hardened Iron", 3, 20000,9.0f , 9.0f, 20);
//tools

//public final Item longSword = new LongSword(502,hardenedIron).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("LongSword").setTextureName("mod:strongstone");
public final static Block StrongStone = new StrongStone(500,Material.rock).setHardness(100000.f).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("StrongStone").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongstone");
public final static Item FirstItem = new FirstItem(5000);
public final static Item flagItem = new FlagItem(5005).setTextureName("mod:flag");
public final static Block StrongGlass = new FirstBlock(4095,Material.glass).setHardness(100000.f).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("StrongGlass").setCreativeTab(CreativeTabs.tabBlock).setTextureName("mod:strongglass4");
//public final static Item HardenedIron = new FirstItem (5001).setMaxStackSize(64).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("HardenedIron").setTextureName("mod:test");


// The instance of your mod that Forge uses.
     @Instance(value = McmkingdomsInfo.NAME)
     public static basemod instance;
    
     // Says where the client and server 'proxy' code is loaded.
     @SidedProxy(clientSide="mcmkingdoms.mod.client.clientProxy", serverSide="mcmkingdoms.mod.CommonProxy")
     public static CommonProxy proxy;
    
     @EventHandler // used in 1.6.2
     //@PreInit // used in 1.5.2
     public void preInit(FMLPreInitializationEvent event) {
             // Stub Method
     }
    
     @EventHandler // used in 1.6.2
     //@Init     // used in 1.5.2
     public void load(FMLInitializationEvent event) {
             proxy.registerRenderers();
            
         // GameRegistry.registerItem(longSword,"LongSword");
         // LanguageRegistry.addName(longSword ,"Long Sword");
            
            
            
             GameRegistry.registerBlock(StrongStone,"StrongStone");
             LanguageRegistry.addName(StrongStone ,"Strong Stone");
            
             GameRegistry.registerItem(flagItem,"Flag");
             LanguageRegistry.addName(flagItem ,"Flag");
            
             GameRegistry.registerBlock(StrongGlass, "StrongGlass");
             LanguageRegistry.addName(StrongGlass ,"Strong Glass");
            
             MinecraftForge.setBlockHarvestLevel(StrongStone,"Pickaxe",3);
             MinecraftForge.setBlockHarvestLevel(StrongGlass,"Pickaxe",2);
            
             //mob
            
             registerEntity(Guard.class,"Gaurd",0xeaeae9, 0xc99a03);
             LanguageRegistry.instance().addStringLocalization("entity.gaurd.name","Gaurd");
     }
             public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
                 int id = EntityRegistry.findGlobalUniqueEntityId();

                 EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
                 EntityList.entityEggs.put(Integer.valueOf(id), new EntityEggInfo(id, bkEggColor, fgEggColor));
         }

         public void addSpawn(Class<? extends EntityLiving> entityClass, int spawnProb, int min, int max, BiomeGenBase[] biomes) {
                 if (spawnProb > 0) {
                         EntityRegistry.addSpawn(entityClass, spawnProb, min, max, EnumCreatureType.monster, biomes);
                 }
         }
                            
     //     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
     //     GameRegistry.registerBlock(StrongStoneStair,"StrongStone");
     //     LanguageRegistry.addName(StrongStoneStair ,"Strong Stone Stair");
        
//     MinecraftForge.setBlockHarvestLevel(StrongStoneStair,"Axe",3);
            
    
    
     @EventHandler // used in 1.6.2
     //@PostInit // used in 1.5.2
     public void postInit(FMLPostInitializationEvent event) {
             // Stub Method
     }
}

 

 

 

Try those tasks. Put them in your mob class

this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 0.25F, true));
        this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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