Jump to content

Spawning a custom entity?


SureenInk

Recommended Posts

So, I'm not sure if there's something wrong with my entity code, or if it's something else, but I can't get my creature to spawn anywhere, and it says "Unable to summon object" when I run the /summon command. Here's the code.

package radial.Main;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelNeola extends ModelBase
{
//fields
    ModelRenderer Hat;
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;
  
  public ModelNeola()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Hat = new ModelRenderer(this, 35, -4);
      Hat.addBox(-5F, -9F, -5F, 10, 9, 10);
      Hat.setRotationPoint(0F, 0F, 0F);
      Hat.setTextureSize(64, 32);
      Hat.mirror = true;
      setRotation(Hat, 0F, -1.570796F, 0F);
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-4F, -8F, -4F, 8, 8, ;
      head.setRotationPoint(0F, 0F, 0F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 16, 16);
      body.addBox(-4F, 0F, -2F, 8, 12, 4);
      body.setRotationPoint(0F, 0F, 0F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      rightarm = new ModelRenderer(this, 40, 16);
      rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);
      rightarm.setRotationPoint(-5F, 2F, 0F);
      rightarm.setTextureSize(64, 32);
      rightarm.mirror = true;
      setRotation(rightarm, 0F, 0F, 0F);
      leftarm = new ModelRenderer(this, 40, 16);
      leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);
      leftarm.setRotationPoint(5F, 2F, 0F);
      leftarm.setTextureSize(64, 32);
      leftarm.mirror = true;
      setRotation(leftarm, 0F, 0F, 0F);
      rightleg = new ModelRenderer(this, 0, 16);
      rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      rightleg.setRotationPoint(-2F, 12F, 0F);
      rightleg.setTextureSize(64, 32);
      rightleg.mirror = true;
      setRotation(rightleg, 0F, 0F, 0F);
      leftleg = new ModelRenderer(this, 0, 16);
      leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      leftleg.setRotationPoint(2F, 12F, 0F);
      leftleg.setTextureSize(64, 32);
      leftleg.mirror = true;
      setRotation(leftleg, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    Hat.render(f5);
    head.render(f5);
    body.render(f5);
    rightarm.render(f5);
    leftarm.render(f5);
    rightleg.render(f5);
    leftleg.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

package radial.Main;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.world.World;

public class Neola extends EntityAgeable
{
    public Neola(World par1World)
    {
        super(par1World);
        this.setSize(0.9F, 1.3F);
    }

    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    }

    @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 null;
}
}

And this is the proxy classes.

package radial.Main;

import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import radial.Main.CommonProxyClass;

public class ClientProxyClass extends CommonProxyClass {
@Override
    public void registerRenderThings()
    {
            RenderingRegistry.registerEntityRenderingHandler(Neola.class, new RenderNeola(new ModelNeola(), 0));
//the 0.5F is the shadowsize
    }
   
    /*@Override
    public void registerSound() {
            MinecraftForge.EVENT_BUS.register(new YourSoundEvent());//register the sound event handling class
    }*/
}

package radial.Main;

public class CommonProxyClass {
public void registerRenderThings() {
    }
   
    public void registerSound() {
    }
}

Finally, the main class code, which I have in FMLPreInitializationEvent.

@Mod(modid = "Radial", name = "Radial", version = "Alpha v0.3")
public class Radial {

@Instance("radial")
public static Radial instance;

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

@EventHandler
public void init(FMLInitializationEvent e){

int id = 0;
	EntityRegistry.registerModEntity(Neola.class, "Neola_Alice", 0, this, 80, 1, true);//id is an internal mob id, you can start at 0 and continue adding them up.
	id++;
	EntityRegistry.addSpawn(Neola.class, 10, 8, 10, EnumCreatureType.ambient, BiomeGenBase.taiga);//change the values to vary the spawn rarity, biome, etc.             
	proxy.registerRenderThings();//calls the methods in our proxy, which will do things on client side
	//proxy.registerSound();
}

}

Link to comment
Share on other sites

Actually, I moved it from PreInit to Init just before posting this because the tutorial said to. I'll move it back. That said, I figured out some problems, but the tutorial says to use

EntityRegistry.registerGlobalEntityID(Neola.class, "Neola", EntityRegistry.findGlobalUniqueEntityId(), 3515848, 12102);

 

Problem is, when I use that code, I get an error: Syntax error on token "registerGlobalEntityID", Identifier expected after this token

 

But, yes, I am using 1.7.2

Link to comment
Share on other sites

What Forge version are you using?

I'm using 10.12.0.1024 - and this works:

 

Note: You may have to change some fields to match your needs.

Pseudo Code

    
EntityRegistry.registerGlobalEntityID(MB_FireSkeleton.class, "FireSkeleton", EntityRegistry.findGlobalUniqueEntityId());

 

If you want a custom renderer use this:

Pseudo Code

RenderingRegistry.registerEntityRenderingHandler(MB_FireSkeleton.class, new RenderFireSkeleton());

Link to comment
Share on other sites

Wow...I feel stupid >> I was putting that code in the wrong spot -headdesk- It works now, thanks so much for the help! But...isn't that code supposed to also give me a spawn egg for her based on the numbers afterwards? I put in a couple random numbers and got nothing, but again, they were random. Gonna check the wiki again before I really ask for help on that.

 

EDIT: Yeah, I still can't spawn her using the /summon command, and I'm not getting a spawn egg. Do I have to make the spawn egg myself? (Also, I'm using Forge 10.12.0.1024)

Link to comment
Share on other sites

You need to use registerModEntity instead of registerGlobalEntity

If you want a spawn egg, use registerGlobalEntity with those additional parameters before the registerModEntity. Here I made wrapper methods for the entity registration:

https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/registry/CommonProxy.java

 

Those additional parameters are the foreground / background colors. You can (and should) use hexadecimal values, e.g.:

0xFF0000 - red

0x00FF00 - green

0x0000FF - blue

 

each digit after 0x can range from 0 to F (0 to 15)

 

An example for my wrapper methods:

https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/registry/ESPModRegistry.java#L450-L464

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

Those are good wrapper methods, but I don't think it's advisable to use update frequencies of 1 for your entities. Mobs, for example, typically use 3, while arrows use 20 and throwables use 10 (in vanilla). Using different values than those may cause strange problems or lag - I've noticed it most with arrows - your mileage may vary, and I'm sure you have good reasons for using 1 since you seem to know quite well what you're doing.

 

This spreadsheet put together by lockNload147 sums up the vanilla entity tracking values.

Link to comment
Share on other sites

Those are good wrapper methods, but I don't think it's advisable to use update frequencies of 1 for your entities. Mobs, for example, typically use 3, while arrows use 20 and throwables use 10 (in vanilla). Using different values than those may cause strange problems or lag - I've noticed it most with arrows - your mileage may vary, and I'm sure you have good reasons for using 1 since you seem to know quite well what you're doing.

 

This spreadsheet put together by lockNload147 sums up the vanilla entity tracking values.

 

I never worried about this too much, it worked and I was happy. It's older code anyway and will be refractored once I get to it (I'm currently in the process of completely refractoring the mod), and will use those recommented values.

Thanks for the sheet :)

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

I never worried about this too much, it worked and I was happy. It's older code anyway and will be refractored once I get to it (I'm currently in the process of completely refractoring the mod), and will use those recommented values.

Thanks for the sheet :)

Gotta love older code xD I've got plenty that makes me shudder in horror when I look at it now, so I'd say yours is looking pretty good by comparison! Glad I (or rather, lockNload) could help.

Link to comment
Share on other sites

Okay! I have the /spawn command working and the spawn eggs working now! But...I'm still not seeing them naturally spawning in my world...Maybe they're just rare? I guess I could increase their spawn rate in the .addspawn section?

 

You use EnumCreatureType.ambient in your addSpawn method.

Thus your entity must extend the EntityAmbientCreature class in order for it to spawn.

 

Look at the EnumCreatureType enum to see what values it has and which classes you need to implement / extend in your entity class.

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

You use EnumCreatureType.ambient in your addSpawn method.

Thus your entity must extend the EntityAmbientCreature class in order for it to spawn.

 

Look at the EnumCreatureType enum to see what values it has and which classes you need to implement / extend in your entity class.

Hmm...well, I modified some code earlier (I didn't update cause I didn't realize it was that important). They're all extending EntityAnimal, and set to EnumCreatureType.creature right now...

 

EDIT: Also, I'd like them to be tameable...so I changed them to extend EntityTameable...

Link to comment
Share on other sites

You use EnumCreatureType.ambient in your addSpawn method.

Thus your entity must extend the EntityAmbientCreature class in order for it to spawn.

 

Look at the EnumCreatureType enum to see what values it has and which classes you need to implement / extend in your entity class.

Hmm...well, I modified some code earlier (I didn't update cause I didn't realize it was that important). They're all extending EntityAnimal, and set to EnumCreatureType.creature right now...

 

Those really spawn rarely. Either increase your spawn rates (idk, but I've seen that someone had to increase it to insane numbers like 1000 or so) or register a new EnumCreatureType.

The latter is shown here:

private static final Class<?>[][] paramTypes = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType ambientWater = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "ambientWaterFish", EntityWaterMob.class, 40, Material.water, false, true);

"ambientWaterFish" is the name of the new enum within the EnumCreatureType class

EntityWaterMob.class is the class which should be used as a reference (your mobs shall then use the same class or a childclass of it)

40 determines how much entites should be spawning at maximum

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

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

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

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

Sorry I'm such a noob x.x but... I'm getting an error saying EnumHelper is undefined? I can't seem to import it, and it tells me I need to create the variable...

 

The EnumHelper is located at net.minecraftforge.common

 

Can you show me your full class file where you put the variables?

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

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 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;

@Mod(modid = "craftygirls", name = "The Crafty Girls 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 ambientWater = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "ambientWaterFish", EntityWaterMob.class, 40, Material.water, false, 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.registerEntityWithEgg(EntityMrFree.class, "MrFree", entityID++, this, 128, 1, true, 0x378d46, 0xdadada);
	proxy.registerRenderThings();	

}

public void postInit(FMLPostInitializationEvent e) {
	EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, EnumCreatureType.creature, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityTomboy.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
	EntityRegistry.addSpawn(EntityTTSnim.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
	EntityRegistry.addSpawn(EntityMrFree.class, 100, 8, 10, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
}
}

Link to comment
Share on other sites

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 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;

@Mod(modid = "craftygirls", name = "The Crafty Girls 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 ambientWater = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "ambientWaterFish", EntityWaterMob.class, 40, Material.water, false, 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.registerEntityWithEgg(EntityMrFree.class, "MrFree", entityID++, this, 128, 1, true, 0x378d46, 0xdadada);
	proxy.registerRenderThings();	

}

public void postInit(FMLPostInitializationEvent e) {
	EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, EnumCreatureType.creature, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityTomboy.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
	EntityRegistry.addSpawn(EntityTTSnim.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
	EntityRegistry.addSpawn(EntityMrFree.class, 100, 8, 10, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
}
}

 

Please just don't blindly copy-paste code...

You really want to name your Creature Type "ambientWaterFish"?

I highly doubt you have a class named EntityWaterMob

Also you can rename the EnumCreatureType variable to something more fitting than "ambientWater"

 

Again, I've explained the parameters previously, here's a short version:

*variableName* = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, *nameOfEnumValue*, *baseClassOfCreatures*, *maxNumberOfCreaturesSpawning*, *MaterialInWhichCreaturesShouldSpawnIn*, *isPeaceful*, *isAnimal*);

 

Also you must import net.minecraftforge.common.EnumHelper

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

Yeah, it wouldn't let me import it before, and I didn't know where it was located. Let me actually code it (I didn't because I didn't really understand the code at all, like the Material.class and such.) I don't usually just copy and paste in code, but here I couldn't understand some of it, so I figured I'd ask about it before I tried adding my own code in (didn't want to put the wrong stuff in and make it worse, you know?)

 

EDIT 1:

 

 

Okay, so I obviously have something wrong, and I apologize for being stupid and noobish...I'm not very good at comprehending things sometimes, and this seems to be the case here. I know I have this coding wrong, but despite reading over your code (and your breakdown of the code) about 10 times, I still am lost.

public static final EntityNeola EntityTameable = EnumHelper.addEnum(paramTypes, EntityNeola.class, "Neola", EntityTameable.class, 40, Material.air, true, true);

As you said, each of those lines is (to my knowledge):

*variableName* = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, *nameOfEnumValue*, *baseClassOfCreatures*, *maxNumberOfCreaturesSpawning*, *MaterialInWhichCreaturesShouldSpawnIn*, *isPeaceful*, *isAnimal*);

I guess the problem I'm having is...Am I supposed to put something in paramTypes? For the EnumCreatureType.class, is that where I put EntityNeola? Then I'd put "Neola" in the nameofEnumValue? The errors I am still getting are that "EntityTameable" isn't an existing class (though I seem to be able to fix that by importing it myself. It wouldn't give me the ability to import it on the command). Also, I'm getting an error under "addEnum" which is:

Bound mismatch: The generic method addEnum(Class<T>, String, Object...) of type EnumHelper is not applicable for the arguments (Class[][], Class<EntityNeola>, String, Class<EntityTameable>, Integer, Material, Boolean, Boolean). The inferred type EntityNeola&Enum<?> is not a valid substitute for the bounded parameter <T extends Enum<?>>

 

 

EDIT 2: Wait...okay...I think I figured it out...Now I have

public static final EnumCreatureType ENeola = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "Neola", EntityTameable.class, 40, Material.air, true, true);

That works fine it seems, but is that supposed to add ENeola as an EnumCreatureType? Cause when I do

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

It says that doesn't exists and recommends changing "ENeola" to "creature"...These are my lines of code for the ones you gave me:

private static final Class[][] paramTypes = new Class[][] {{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}};
public static final EnumCreatureType ENeola = EnumHelper.addEnum(paramTypes, EnumCreatureType.class, "Neola", EntityTameable.class, 40, Material.air, true, true);

Link to comment
Share on other sites

Are you trying to call this method?

public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful)

?

Link to comment
Share on other sites

Are you trying to call this method?

public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful)

?

I think so? According to SanAndreasP, I needed to create a new creature type, since I'm trying to spawn in "EntityTameable" instead of the others. I've still got a big error in the taming code, but I'm more concerned with getting them to spawn right now then making it so they can be tamed. He gave me a code that (I guess?) was supposed to add a creature type, but I don't know how to run it? How do I run that one?

Link to comment
Share on other sites

Normally I don't just post free code for people, I think they should learn the proper code themselves and become better modders. But, this one time I excuse myself and do it anyways.


public static final EnumCreatureType ENeola = EnumHelper.addCreatureType("Neola", WhateverYourCreatureClassIs.class, 40, Material.air, true);

The true at the end means peaceful. But, you have to provide the exact class to spawn where is says above. Whatever...is.class requires the name of your CLASS, NOT EntityCreature or EntityLiving, or EntityTameable..

Link to comment
Share on other sites

-nods- makes sense...hmm...I still get an error, though in the spawn code (or am I doing that wrong?)...I tried

		EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, new EnumCreatureType(ENeola), BiomeGenBase.forest);

but got the error

Cannot instantiate the type EnumCreatureType

Before that I tried

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

but still have the same error as before where it's not recognizing the code. Am I putting that first part in the wrong spot (It doesn't seem to work anywhere else). I have it right now just in the top section before any of the PreInits, Inits, etc. Here's my current code:

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 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;

//Cookies for Tomboy. Flowers for Alice, and Diamonds for Stef
public static final EnumCreatureType ENeola = EnumHelper.addCreatureType("Neola", EntityNeola.class, 40, Material.air, true);

@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, 100, 8, 10, EnumCreatureType.ENeola, BiomeGenBase.forest);
	EntityRegistry.addSpawn(EntityTomboy.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
	EntityRegistry.addSpawn(EntityTTSnim.class, 100, 100, 200, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.plains);
}
}

Again, it can't seem to read "ENeola" as a creature type. It tells me it's wrong and recommends changing to one of the four existing ones, just like the previous code I was given...

 

I guess I should note I'm working in 1.7.2, so if these have been 1.6 codes, that might be the problem. I...thought I had mentioned that earlier, but I don't see a mention of it previously, so I must not have.

Link to comment
Share on other sites

EntityRegistry.addSpawn(EntityNeola.class, 100, 8, 10, new EnumCreatureType(ENeola), BiomeGenBase.forest);

He gave you exactly the code you need, but you are using it incorrectly. You do not create a "new" EnumCreatureType, you just did that using the EnumHelper above; likewise, ENeola is not going to be found in EnumCreatureType.ENeola, because it doesn't exist in that class.

 

Replace "new EnumCreatureType(ENeola)" with "ENeola".

Link to comment
Share on other sites

-headdesk- Ugh...why am I so stupid? Am I really just missing something? Like...you guys are literally handing me the code I need to make it work, and I'm following your instructions and I'm STILL getting errors. Actually, this time, I'm not getting any errors till I try to load it. I don't understand this error log at all, but I followed your words exactly (I changed the EnumCreatureType.ENeola to just "ENeola". Well, actually, I changed it to "TypeNeola" but I made sure to modify the public static part to say that, too). Here's my error log...I'm still new to Java but...it seems like it's having an error on the addCreatureType? Do I need to be running both of you guys' code in order for it all to work? Cause I have the one set of code SanAndreasP gave me currently commented out...but uncommenting it doesn't seem to help.

---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 3/30/14 12:31 AM
Description: Initializing game

java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:42)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:515)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:487)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:194)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:561)
at net.minecraft.client.Minecraft.run(Minecraft.java:931)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.RuntimeException: net.minecraft.entity.EnumCreatureType.<init>(java.lang.String, int, java.lang.Class, int, net.minecraft.block.material.Material, boolean)
at net.minecraftforge.common.util.EnumHelper.addEnum(EnumHelper.java:272)
at net.minecraftforge.common.util.EnumHelper.addEnum(EnumHelper.java:199)
at net.minecraftforge.common.util.EnumHelper.addEnum(EnumHelper.java:184)
at net.minecraftforge.common.util.EnumHelper.addCreatureType(EnumHelper.java:70)
at craftygirls.main.Main.<clinit>(Main.java:31)
... 36 more
Caused by: java.lang.NoSuchMethodException: net.minecraft.entity.EnumCreatureType.<init>(java.lang.String, int, java.lang.Class, int, net.minecraft.block.material.Material, boolean)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at net.minecraftforge.common.util.EnumHelper.getConstructorAccessor(EnumHelper.java:140)
at net.minecraftforge.common.util.EnumHelper.makeEnum(EnumHelper.java:149)
at net.minecraftforge.common.util.EnumHelper.addEnum(EnumHelper.java:262)
... 40 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at cpw.mods.fml.common.ProxyInjector.inject(ProxyInjector.java:42)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:515)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:487)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:194)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:561)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:931)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 858263792 bytes (818 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.116.1024 Minecraft Forge 10.12.0.1024 7 mods loaded, 7 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed
FML{7.2.116.1024} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed
Forge{10.12.0.1024} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1024.jar) Unloaded->Constructed
craftygirls_comic{Alpha v0.1} [The Crafty Girls Comic Mod] (bin) Unloaded
craftygirls{Alpha v0.1} [The Crafty Girls Core Mod] (bin) Unloaded
Radial{Alpha v0.2} [Radial] (bin) Unloaded
sureencore{V1.0} [sureen Core] (bin) Unloaded
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: GeForce GT 635/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Anisotropic Filtering: Off (1)

Link to comment
Share on other sites

Please post your EntityNeola class. The classloader seems to be having trouble loading it. Or there is another problem.

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

    • हथियार व्यापारियों की चमक आज के समय में भारत और दुनिया के विभिन्न हिस्सों में तेजी से बढ़ रही है। स्वीडन की स्थित संस्था सिपरी की नवीनतम रिपोर्ट के अनुसार, विश्व भर में विभिन्न देश अब पूर्व कभी नहीं देखे गए हथियारों और सैन्य सामग्रियों पर धन का व्यय कर रहे हैं। वैश्विक संघर्षों के बढ़ते संकेतों के कारण, विश्व के कई हिस्सों में युद्ध की संभावनाएं बढ़ रही हैं। पश्चिमी एशिया में युद्ध की आग फैल रही है, जबकि दक्षिण चीन सागर और ताइवान में भी तनाव बढ़ रहा है। भारत-चीन सीमा पर भी स्थिति चिंताजनक है। इन घटनाओं के परिणामस्वरूप, विभिन्न देशों की प्राथमिकताएं बदल रही हैं, और हथियार व्यापारियों का धंधा आजकल चमक उठा है। सिपरी की रिपोर्ट के अनुसार, 2023 में वैश्विक सैन्य खर्च एक नया रिकॉर्ड स्थापित किया गया है। 2022 की तुलना में, 2023 में सैन्य खर्च 6.8 फीसदी बढ़कर 24.4 ट्रिलियन डॉलर पर पहुंच गया। इसके पीछे कुछ विशेष कारण हैं, जिनमें दुनिया भर में तनाव बढ़ना और अद्यतित सैन्य तैयारियों की आवश्यकता शामिल है। इस वृद्धि में, भारत जैसे देशों का योगदान भी अधिक है। भारत ने भी अपने सैन्य खर्चों में वृद्धि की है, और यह दुनिया के सबसे बड़े और सबसे प्रभावशाली राष्ट्रों में एक बन गया है। इसके अलावा, अमेरिका, चीन, और रूस भी सैन्य खर्च में वृद्धि की हैं, जिससे विश्व सुरक्षा में नए दायरे खुले हैं। संभावनाओं के इस नए मंच पर, दुनिया के सक्षम देश अब अपने सैन्य तैयारियों में ज्यादा ध्यान दे रहे हैं। यह वृद्धि विकास और प्रगति के बजट पर भी प्रभाव डाल रही है, जिससे विभिन्न देशों के आर्थिक प्रगति में बदलाव आ सकता है।   https://www.nayaindia.com/editorial-column/editorial1/arms-sales-increased-in-the-world-454072.html
    • Hello, Hi and I am making a forge 1.12.2 mod and also trying to get a custom model helmet item (I made a joker mask) and exported it to .json format and put it in the ~/namespace/models/item folder. Though, I'm struggling to get the item to render what I want it to be rendered like as I've positioned it in the 'head' window view in blockbench. How did you render out your model? I checked your code and it looks like no references to the actual model are being made. I'm new to this forge modding stuff (was a fabric modder) and I desperately need some help. Is there a way to standardly render out armor models made using blockbench? any methods that one can use? My model in JSON: ```json { "credit": "Made with Blockbench", "texture_size": [160, 160], "textures": { "0": "ydyrn:items/joker_mask_texture", "particle": "ydyrn:items/joker_mask_texture" }, "elements": [ { "from": [0, 0, 0], "to": [16, 16, 1], "faces": { "north": {"uv": [0, 1.7, 16, 14.2], "texture": "#0"}, "east": {"uv": [0, 4, 0.9, 5.6], "texture": "#0"}, "south": {"uv": [0, 5.8, 1.6, 7.4], "texture": "#0"}, "west": {"uv": [0, 1.9, 1.3, 3.5], "texture": "#0"}, "up": {"uv": [0, 3.4, 1.6, 4.2], "texture": "#0"}, "down": {"uv": [0, 9, 1.6, 9.7], "texture": "#0"} } }, { "from": [15.8, 11, 0.5], "to": [16.2, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"} } }, { "from": [0.2, 11, 14.6], "to": [15.8, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 9.46, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 9.46, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 9.46, 7.94], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 9.46, 7.94], "texture": "#0"} } }, { "from": [-0.2, 11, 0.5], "to": [0.2, 13, 15], "faces": { "north": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "east": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "south": {"uv": [7.9, 7.9, 7.94, 8.1], "texture": "#0"}, "west": {"uv": [7.9, 7.9, 9.35, 8.1], "texture": "#0"}, "up": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"}, "down": {"uv": [7.9, 7.9, 7.94, 9.35], "texture": "#0"} } } ], "display": { "thirdperson_righthand": { "translation": [-0.25, -2.75, 0], "scale": [0.3, 0.3, 0.3] }, "thirdperson_lefthand": { "translation": [-0.25, -2.75, 0], "scale": [0.3, 0.3, 0.3] }, "firstperson_righthand": { "rotation": [-9, 115, 15], "translation": [0, 1.25, -1.75], "scale": [0.5, 0.5, 0.5] }, "firstperson_lefthand": { "rotation": [-9, 115, 15], "translation": [0, 1.25, -1.75], "scale": [0.5, 0.5, 0.5] }, "ground": { "rotation": [40, 0, 0], "translation": [0, -2.5, 0], "scale": [0.5, 0.5, 0.5] }, "gui": { "rotation": [0, 180, 0] }, "head": { "translation": [0, 0, 0.25], "scale": [0.82773, 0.73594, 0.9] }, "fixed": { "translation": [0, 0, 8.75] } }, "groups": [ 0, { "name": "straps", "origin": [0, 0, 0], "color": 0, "children": [1, 2, 3] } ] } ```
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • In your config folder, delete the sophisticatedcore-common.toml file and test it again
    • Add the crash-report or latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

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