Jump to content

Recommended Posts

Posted

So i'm making an entity which uses a similar model to that of a horse (so I copied everything from ModelHorse into a class which will be used by my entity and renamed everything so it would work), and I made a render class along with an entity class. In the main class I registered it and made the spawn egg, but whenever I try to spawn it into the world I just get an error message in the console.

 

Error message:

 

2013-09-08 18:19:48 [iNFO] [sTDERR] java.lang.InstantiationException
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityList.createEntityByID(EntityList.java:205)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.item.ItemMonsterPlacer.spawnCreature(ItemMonsterPlacer.java:175)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.item.ItemMonsterPlacer.onItemUse(ItemMonsterPlacer.java:81)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:152)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:429)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:554)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:79)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
2013-09-08 18:19:48 [iNFO] [sTDERR] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
2013-09-08 18:19:48 [WARNING] [Minecraft-Server] Skipping Entity with id 301

 

Could it be that i'm calling it wrong, or do you think it's something else?

Posted

(so I copied everything from ModelHorse

*facepalm*

Why not use ModelHorse directly ?  :'(

 

Your error comes from your entity constructors. It is expected to have a constructor with (World) as only argument.

Posted

I didn't use ModelHorse as I was going to make a new, similar model at a later date. I did this to get it setup for when I decided to do that.

 

As for the constructors, do you think you could perhaps give a little hint as to what I need to do, as I thought that it was correct  :-[

Posted

Ok, this is what I have in the EntityPegasus class.

 

package RosarioMokaChan.RandomCraft;

import RosarioMokaChan.RandomCraft.lib.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.StepSound;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

public abstract class EntityPegasus extends EntityAnimal
{
    public EntityPegasus(World par1World)
    {
        super(par1World);
        this.setSize(1.4F, 1.6F);
        this.isImmuneToFire = true;
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 0.8D));
        this.tasks.addTask(6, new EntityAIWander(this, 0.7D));
        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(8, new EntityAILookIdle(this));
    }
    
    protected boolean isAIEnabled(){
    	return true;
    }
    
    public int getMaxHealth() {
    	return 15;
    	}
    

    @Override
    protected String getLivingSound()
    {
        return "mob.horse.idle";
    }

    @Override
    protected String getHurtSound()
    {
        return "mob.horse.hit";
    }

    @Override
    protected String getDeathSound()
    {
        return "mob.horse.death";
    }

    @Override
    protected float getSoundVolume()
    {
        return 0.4F;
    }
    
    protected int getDropItemId()
    {
        return Item.leather.itemID;
    }
    
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.playSound("mob.horse.gallop", 0.15F, 1.0F);
        
    }
    
    protected void dropRareDrop(int par1){
    	switch (this.rand.nextInt(3)){
    	case 0:
    		this.dropItem(ModBlocks.dragonWings.itemID, 1);
    	break;
    	}
    }
    
    public EnumCreatureAttribute getCreatureAttribute(){
    	return EnumCreatureAttribute.UNDEFINED;
    }
    
    

    
}

Posted

Before I started anything to do with modding, I made sure to read a few java documents and do some exercises to learn some of the stuff needed, it's just abstract classes and a few other things weren't covered. Also making the class abstract was an alternative to importing net.minecraft.entity.EntityAgeable, which I was trying to avoid doing as I was trying to cut down on the amount of unnecessary imports.

Posted

Well, abstract classes can't be instanciated.

It is their main property.

 

making the class abstract was an alternative to importing net.minecraft.entity.EntityAgeable

This doesn't make any sense. You can also do both or neither.

 

I was trying to cut down on the amount of unnecessary imports.

One of my personal rules is: "Optimize a working code, not the other way around"

Posted

Right, so now my entity spawns in the world and has a shadow, hitbox and sounds. However it's invisible. The console is saying that my entity can't be cast to EntityHorse, and i'm sure that I must be missing something in my RenderPegasus class.

 

2013-09-09 10:08:30 [iNFO] [sTDERR] java.lang.ClassCastException: RosarioMokaChan.RandomCraft.EntityPegasus cannot be cast to net.minecraft.entity.passive.EntityHorse
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at RosarioMokaChan.RandomCraft.Pegasus.setLivingAnimations(Pegasus.java:362)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RendererLivingEntity.func_130000_a(RendererLivingEntity.java:153)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderLiving.doRenderLiving(RenderLiving.java:28)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at RosarioMokaChan.RandomCraft.RenderPegasus.renderPegasus(RenderPegasus.java:21)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at RosarioMokaChan.RandomCraft.RenderPegasus.doRender(RenderPegasus.java:31)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:312)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:281)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:524)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1160)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1006)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:934)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:826)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.client.main.Main.main(Main.java:93)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
2013-09-09 10:08:30 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

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.