Jump to content

Spawning a custom entity?


SureenInk

Recommended Posts

Doesn't seem to be an error with Neola. I tried using the same coding for both TTSnim and Tomboy, and commenting out everyone but one mob doesn't help. Whether it's Neola, Tomboy, or TTSnim, it still errors. Still, here's all three of them.

 

Neola

 

[code]package craftygirls.main;

import net.minecraft.block.BlockColored;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.world.World;

public class EntityNeola extends EntityTameable
{
    public EntityNeola(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 2F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
        this.tasks.addTask(2, this.aiSit);
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.apple, false));
        this.tasks.addTask(4, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
        this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
        this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
        this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
        this.setTamed(false);
    }

    public boolean isAIEnabled() {
    	return true;
    }
    
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
        if (this.isTamed()) {
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
        }
        else {
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
        }
    }

    protected void fall(float par1) {}
    
    @Override
    protected String getLivingSound()
    {
        return null;//this refers to:yourmod/sound/YourSound
    }

    @Override
    protected String getHurtSound()
    {
        return null;//this refers to:yourmod/sound/optionalFile/YourSound
    }

    @Override
    protected String getDeathSound()
    {
        return null;//etc.
    }

    @Override
    protected float getSoundVolume()
    {
        return 0.4F;
    }

public EntityNeola createChild(EntityAgeable par1EntityAgeable)
    {
        EntityNeola entityneola = new EntityNeola(this.worldObj);
        String s = this.getOwnerName();

        if (s != null && s.trim().length() > 0)
        {
            entityneola.setOwner(s);
            entityneola.setTamed(true);
        }

        return entityneola;
    }
public boolean isBreedingItem(ItemStack par1ItemStack)
    {
        return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds;
    }

protected boolean canDespawn()
    {
        return false;
    }

public void setTamed(boolean par1)
    {
        super.setTamed(par1);

        if (par1)
        {
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
        }
        else
        {
            this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
        }
    }

protected Item getDropItem()
    {
        return Items.apple;
    }

    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

        for (int k = 0; k < j; ++k)
        {
            this.dropItem(Items.apple, 1);
        }

        if (this.isBurning())
        {
            this.dropItem(Items.cooked_chicken, 1);
        }
        else
        {
            this.dropItem(Items.chicken, 1);
        }
    }
    
    public boolean canMateWith(EntityAnimal par1EntityAnimal)
    {
        if (par1EntityAnimal == this)
        {
            return false;
        }
        else if (!this.isTamed())
        {
            return false;
        }
        else if (!(par1EntityAnimal instanceof EntityNeola))
        {
            return false;
        }
        else
        {
            EntityNeola entityneola = (EntityNeola)par1EntityAnimal;
            return !entityneola.isTamed() ? false : (entityneola.isSitting() ? false : this.isInLove() && entityneola.isInLove());
        }
    }
    
    public boolean interact(EntityPlayer par1EntityPlayer)
    {
        ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

        if (this.isTamed())
        {
            if (itemstack != null)
            {
                if (itemstack.getItem() instanceof ItemFood)
                {
                    ItemFood itemfood = (ItemFood)itemstack.getItem();

                    if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F)
                    {
                        if (!par1EntityPlayer.capabilities.isCreativeMode)
                        {
                            --itemstack.stackSize;
                        }

                        this.heal((float)itemfood.func_150905_g(itemstack));

                        if (itemstack.stackSize <= 0)
                        {
                            par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
                        }

                        return true;
                    }
                }
            }

            if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
            {
                this.aiSit.setSitting(!this.isSitting());
                this.isJumping = false;
                this.setPathToEntity((PathEntity)null);
                this.setTarget((Entity)null);
                this.setAttackTarget((EntityLivingBase)null);
            }
        }
        else if (itemstack != null && itemstack.getItem() == Items.apple)
        {
            if (!par1EntityPlayer.capabilities.isCreativeMode)
            {
                --itemstack.stackSize;
            }

            if (itemstack.stackSize <= 0)
            {
                par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
            }

            if (!this.worldObj.isRemote)
            {
                if (this.rand.nextInt(3) == 0)
                {
                    this.setTamed(true);
                    this.setPathToEntity((PathEntity)null);
                    this.setAttackTarget((EntityLivingBase)null);
                    this.aiSit.setSitting(true);
                    this.setHealth(100.0F);
                    this.setOwner(par1EntityPlayer.getCommandSenderName());
                    this.playTameEffect(true);
                    this.worldObj.setEntityState(this, (byte)7);
                }
                else
                {
                    this.playTameEffect(false);
                    this.worldObj.setEntityState(this, (byte)6);
                }
            }

            return true;
        }

        return super.interact(par1EntityPlayer);
    }
}

 

Tomboy

 

package craftygirls.main;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class EntityTomboy extends EntityAnimal
{
    public EntityTomboy(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 2F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.cookie, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    public boolean isAIEnabled() {
    	return true;
    }
    
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
    }

    protected void fall(float par1) {}
    
    @Override
    protected String getLivingSound()
    {
        return null;//this refers to:yourmod/sound/YourSound
    }

    @Override
    protected String getHurtSound()
    {
        return null;//this refers to:yourmod/sound/optionalFile/YourSound
    }

    @Override
    protected String getDeathSound()
    {
        return null;//etc.
    }

    @Override
    protected float getSoundVolume()
    {
        return 0.4F;
    }

@Override
public EntityAgeable createChild(EntityAgeable var1) {
	return new EntityTomboy(this.worldObj);
}

public boolean isBreedingItem(ItemStack par1ItemStack)
    {
        return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds;
    }

protected boolean canDespawn()
    {
        return false;
    }
}

 

TTSnim

 

package craftygirls.main;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class EntityTTSnim extends EntityAnimal
{
    public EntityTTSnim(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 2F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
        this.tasks.addTask(1, new EntityAIPanic(this, 1.4D));
        this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
        this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.diamond, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
        this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    public boolean isAIEnabled() {
    	return true;
    }
    
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
    }

    protected void fall(float par1) {}
    
    @Override
    protected String getLivingSound()
    {
        return null;//this refers to:yourmod/sound/YourSound
    }

    @Override
    protected String getHurtSound()
    {
        return null;//this refers to:yourmod/sound/optionalFile/YourSound
    }

    @Override
    protected String getDeathSound()
    {
        return null;//etc.
    }

    @Override
    protected float getSoundVolume()
    {
        return 0.4F;
    }

@Override
public EntityAgeable createChild(EntityAgeable var1) {
	return new EntityTTSnim(this.worldObj);
}

public boolean isBreedingItem(ItemStack par1ItemStack)
    {
        return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds;
    }

protected boolean canDespawn()
    {
        return false;
    }
}

 

Link to comment
Share on other sites

oops! The error is in EnumHelper and it's incorrect signature for EnumCreatureType (both the addCreatureType method, and the commonTypes grid.)

Link to comment
Share on other sites

The args probably changed from 1.6.4 to 1.7 and it was forgotten to change in EnumHelper.

 

The args changed even before there... There was a reason I didn't give him the addCreatureType method, though I probably should have said why. So again, use

private static final Class<?>[][] PARAM_TYPES = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType MY_CREATURE_TYPE = EnumHelper.addEnum(PARAM_TYPES, EnumCreatureType.class, "creatureTypeName", BaseEntityClass.class, 40, Material.air, false, true);

instead of

public static final EnumCreatureType MY_CREATURE_TYPE = EnumHelper.addCreatureType(...)

since Forge doesn't provide the additional boolean parameter (even in 1.6) and thus will crash.

 

The parameters for the addEnum are as following:

par3 - "creatureTypeName" The name of the new enum within the EnumCreatureType class (you CANNOT use this to reference to the new enum directly! That's why the return value of the addEnum method is saved!)

par4 - BaseEntityClass.class The class which should be used as a reference (your mobs shall then use the same class or a childclass of it)

par5 - 40 Determines how much entites should be spawning at maximum

par6 - Material.air The Material the entities should be spawning in, Material.water and Material.air are used in vanilla

par7 - false Determines if it's a peaceful creature (e.g. any animal like cows, chickens etc.)

par8 - true Determines if it's an ambient creature (e.g. bats) an animal (e.g. see above)

 

In your case, it would be:

private static final Class<?>[][] PARAM_TYPES = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType E_NEOLA = EnumHelper.addEnum(PARAM_TYPES, EnumCreatureType.class, "neola", WhateverYourCreatureClassIs.class, 40, Material.air, true, true);

Change those parameters to fit your purpose!

 

To reference it in the addSpawn method use the E_NEOLA variable

EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, E_NEOLA, BiomeGenBase.forest);

 

Some notes from me:

  • I encourage that any static final variable is spelled uppercase with underscores separating the words, like MY_FINAL_VAR to distinguish them from normal variables
  • I encourage that any other variable is spelled camelCase, like myNormalVar

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Well, the good news is that I don't have errors with the code anymore ^^ You've all been a big help there, and I thank you. The bad news is...I spent 20 minutes flying through 3 different worlds and still can't find a single one of them naturally spawning (I even created new worlds to see if that did anything). The spawn rates are 100, 8, 10...is that really low or something? I'd think a weighted probability of 100 would be really high and thus cause a lot of spawns...

Link to comment
Share on other sites

Which biomes did you set them to spawn in? You might need to find such a biome and spend some time there looking around. I had a similar issue when horses were added, for I did not know they only spawned in plains and such.

Link to comment
Share on other sites

I have them set for plains, forest, and Jungle. Whereas I've yet to see a jungle biome in any of my worlds, I spent about 20 minutes flying over plains and forest biomes and not seeing any spawns. I saw tons of horses, cows, pigs, sheep, etc. Like...lots more then I've ever seen...but none of my mobs showed. I will admit to having trouble finding spawns before with horses, and with a few other mods I used that had custom mobs in it...so I want to just trust that they are spawning...but I want to be sure...I don't want to release the mod if nothing is spawning, you know? Is there some kind of debug function I could use to test that it's working even if I don't see them spawning?

Link to comment
Share on other sites

I went looking for the spawn code for different creatureTypes and I discovered the possible problem you are encountering getting your creatureType to spawn.

Check this code in BiomeGenBase:

    public List getSpawnableList(EnumCreatureType par1EnumCreatureType)
    {
        return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : (par1EnumCreatureType == EnumCreatureType.ambient ? this.spawnableCaveCreatureList : null)));
    }

Apparently it is not smart enough to support spawning custom CreatureTypes. This makes is hard to accomplish what you want short of using ASM and changing the method. On the other hand, if you used a standard creature type from the list then it should spawn nicely.

Link to comment
Share on other sites

@sequituri: Certainly didn't expect the code to be so inflexible... I wonder how Mo' Creatures does it?

 

@OP: You can use the vanilla creature types just fine for custom entities provided your entity matches the type (i.e. Mob, Animal / Creature, Ambient, WaterCreature). Note that you will be competing with all mobs that use the same creature types, so for testing you should definitely set your spawn rate to 1000+ just so you can see them spawn.

 

I haven't done much with entity spawning, but Ambient creatures are almost nonexistant in vanilla minecraft, so if you can code your entity to be an ambient creature type and still get the tameable functionality, you won't have much to compete against - but it's more work >.<

Link to comment
Share on other sites

-sighs- nope, that didn't work either...I even tried setting them to spawn in the desert, where nothing else spawns, and still got nothing... I really don't understand what's wrong here v.v

 

EDIT: NO WAIT! I got one of the three to spawn! I think I may have figured out why they weren't spawning!

 

EDIT 2: Okay, still can't get the other version of the code to spawn them (the one SanAndreasP gave me) but I can get them to spawn with the regular code now. So, I'll leave that up to SAP if he wants to try to fix it further. Here's my code for the main:

package craftygirls.main;

import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import net.minecraft.entity.EntityList.EntityEggInfo;
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.registry.EntityRegistry;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.entity.passive.EntityTameable;

@Mod(modid = "craftygirls", name = "The Crafty Girls Core Mod", version = "Alpha v0.1")
public class Main {

@Instance("craftygirls")
public static Main instance;

//Proxies
@SidedProxy(clientSide="craftygirls.main.ClientProxyClass", serverSide="craftygirls.main.CommonProxyClass")
public static CommonProxyClass proxy;

private static final Class[][] paramTypes = new Class<?>[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType EnumNeola = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeNeola", EntityNeola.class, 40, Material.air, true, true);
public static final EnumCreatureType EnumTomBoy = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeTomBoy", EntityTomboy.class, 40, Material.air, true, true);
public static final EnumCreatureType EnumTTSnim = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeTTSnim", EntityTTSnim.class, 40, Material.air, true, true);
//Cookies for Tomboy. Flowers for Alice, and Diamonds for Stef

@EventHandler
public void preInit(FMLPreInitializationEvent e){

}

@EventHandler
public void Init(FMLInitializationEvent e) {

	short entityID = 0;
	proxy.registerEntityWithEgg(EntityNeola.class, "Neola", entityID++, this, 128, 1, true, 0x492d00, 0x029820);
	proxy.registerEntityWithEgg(EntityTomboy.class, "TomBoy", entityID++, this, 128, 1, true, 0x290877, 0x03f63b);
	proxy.registerEntityWithEgg(EntityTTSnim.class, "TTSnim", entityID++, this, 128, 1, true, 0x8e69cd, 0xfee02b);
	proxy.registerRenderThings();	

	}

public void postInit(FMLPostInitializationEvent e) {

	EntityRegistry.addSpawn(EntityNeola.class, 1000, 8, 10, EnumNeola, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityTomboy.class, 1000, 8, 10, EnumTomBoy, BiomeGenBase.jungle);
	EntityRegistry.addSpawn(EntityTTSnim.class, 1000, 8, 10, EnumTTSnim, BiomeGenBase.plains);

}
}

And, no, I'm not getting any errors with it, I'm just not getting any spawns from it.

Link to comment
Share on other sites

-sighs- nope, that didn't work either...I even tried setting them to spawn in the desert, where nothing else spawns, and still got nothing... I really don't understand what's wrong here v.v

 

EDIT: NO WAIT! I got one of the three to spawn! I think I may have figured out why they weren't spawning!

 

EDIT 2: Okay, still can't get the other version of the code to spawn them (the one SanAndreasP gave me) but I can get them to spawn with the regular code now. So, I'll leave that up to SAP if he wants to try to fix it further. Here's my code for the main:

package craftygirls.main;

import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import net.minecraft.entity.EntityList.EntityEggInfo;
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.registry.EntityRegistry;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.entity.passive.EntityTameable;

@Mod(modid = "craftygirls", name = "The Crafty Girls Core Mod", version = "Alpha v0.1")
public class Main {

@Instance("craftygirls")
public static Main instance;

//Proxies
@SidedProxy(clientSide="craftygirls.main.ClientProxyClass", serverSide="craftygirls.main.CommonProxyClass")
public static CommonProxyClass proxy;

private static final Class[][] paramTypes = new Class<?>[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType EnumNeola = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeNeola", EntityNeola.class, 40, Material.air, true, true);
public static final EnumCreatureType EnumTomBoy = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeTomBoy", EntityTomboy.class, 40, Material.air, true, true);
public static final EnumCreatureType EnumTTSnim = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "TypeTTSnim", EntityTTSnim.class, 40, Material.air, true, true);
//Cookies for Tomboy. Flowers for Alice, and Diamonds for Stef

@EventHandler
public void preInit(FMLPreInitializationEvent e){

}

@EventHandler
public void Init(FMLInitializationEvent e) {

	short entityID = 0;
	proxy.registerEntityWithEgg(EntityNeola.class, "Neola", entityID++, this, 128, 1, true, 0x492d00, 0x029820);
	proxy.registerEntityWithEgg(EntityTomboy.class, "TomBoy", entityID++, this, 128, 1, true, 0x290877, 0x03f63b);
	proxy.registerEntityWithEgg(EntityTTSnim.class, "TTSnim", entityID++, this, 128, 1, true, 0x8e69cd, 0xfee02b);
	proxy.registerRenderThings();	

	}

public void postInit(FMLPostInitializationEvent e) {

	EntityRegistry.addSpawn(EntityNeola.class, 1000, 8, 10, EnumNeola, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityTomboy.class, 1000, 8, 10, EnumTomBoy, BiomeGenBase.jungle);
	EntityRegistry.addSpawn(EntityTTSnim.class, 1000, 8, 10, EnumTTSnim, BiomeGenBase.plains);

}
}

And, no, I'm not getting any errors with it, I'm just not getting any spawns from it.

 

There's nothing I can do to fix this. It's an issue with the Minecraft code itself:

I went looking for the spawn code for different creatureTypes and I discovered the possible problem you are encountering getting your creatureType to spawn.

Check this code in BiomeGenBase:

    public List getSpawnableList(EnumCreatureType par1EnumCreatureType)
    {
        return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : (par1EnumCreatureType == EnumCreatureType.ambient ? this.spawnableCaveCreatureList : null)));
    }

Apparently it is not smart enough to support spawning custom CreatureTypes. This makes is hard to accomplish what you want short of using ASM and changing the method. On the other hand, if you used a standard creature type from the list then it should spawn nicely.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

Ahh, all right then, I wasn't sure. Well, then, I guess that's about all I can do with it...I mean, unless somsone wants to tell me how to go about overriding the minecraft code and all, and I don't know if I'm really experienced enough for that yet so. Thanks everyone for the help. ^^

Link to comment
Share on other sites

I just found this, so it may already have been tried and failed...

There is a MinecraftForge event called

WorldEvent.PotentialSpawns

that can be handled and will allow the spawnlist to be set to any spawnlist desired (added to, or removed from). That might make your creature spawn wherever you want. I have not tested this theory, so it's up to you.

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

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

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