Jump to content

[1.7.10] Monster Spawner with spawns a custom mob


Hextor

Recommended Posts

I created a Boar mob and tried to make a Monster Spawner via command that spawns my mob.

First I tried with /give @p mob_spawner 1 0 {BlockEntityTag:{EntityId:Skeleton}}. It gave me the basic spawner block which spawns

pigs.

After that I used /setblock ~ ~ ~ mob_spawner 0 destroy {EntityId:Boar}. It spawned the block with the little spinning boar with it,

but spawned nothing.

 

Is the problem in the code or I search somewhere else?

Just to be sure here is my Boar.class

 

package net.Aethoscraft.mod.entity.hostile;

import java.util.Random;

import net.Aethoscraft.mod.Aethoscraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityBoar extends EntityMob implements IBossDisplayData {

 Random r = new Random();

public EntityBoar(World world) {
	super(world);
	this.experienceValue = 2;

	this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityPlayer.class, 5.0F));
	this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));

	this.setCustomNameTag("Boar");

}

 protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(5.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.5D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D);
    }

 public boolean attackEntityAsMob(Entity p_70652_1_)
    {
	 	return true;
    }

 protected boolean isAIEnabled()
    {
        return true;
    }

 protected Item getDropItem()
    {
        if(r.nextInt(100)>20)
        	return Items.leather;
        else
        	return Aethoscraft.itemBoarTusk;


    } 
}

 

Link to comment
Share on other sites

package net.Aethoscraft.mod.handlers;

import java.util.Random;

import net.Aethoscraft.mod.Aethoscraft;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityList.EntityEggInfo;
import net.minecraft.entity.EnumCreatureType;
import cpw.mods.fml.common.registry.EntityRegistry;

public class EntityHandler {

public static void registerMonsters(Class entityClass, String name){

	int entityID = EntityRegistry.findGlobalUniqueEntityId();
	long x = name.hashCode();
	Random random = new Random(x);
	int mainColor = random.nextInt() * 16777215;
	int subColor = random.nextInt() * 16777215;

	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
	EntityRegistry.addSpawn(entityClass, 50, 2, 4,EnumCreatureType.monster);
	EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true);
	EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor));

}

public static void registerCreatures(Class entityClass, String name){

	int entityID = EntityRegistry.findGlobalUniqueEntityId();
	long x = name.hashCode();
	Random random = new Random(x);
	int mainColor = random.nextInt() * 16777215;
	int subColor = random.nextInt() * 16777215;

	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
	EntityRegistry.addSpawn(entityClass, 50, 2, 4,EnumCreatureType.creature);
	EntityRegistry.registerModEntity(entityClass, name, entityID, Aethoscraft.instance, 16, 1, true);
	EntityList.entityEggs.put(Integer.valueOf(entityID),new EntityList.EntityEggInfo(entityID, mainColor,subColor));

}

}

 

In the main mod class I simply call the handler class above:

EntityHandler.registerMonsters(EntityBoar.class, "Boar");

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



×
×
  • Create New...

Important Information

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