Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.6.4] How to create a mob?


Pandassaurus
 Share

Recommended Posts

Hi,

So I found code online to create a new mob, and in the video as well as my other mod it worked, but for some reason, it's not in this one.

 

main class:

 

 package com.Pandassaurus.WTHMod;

import com.Pandassaurus.WTHMod.mob.entity.EntityPedophileMob;
import com.Pandassaurus.WTHMod.mob.model.PedophileMob;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraftforge.common.MinecraftForge;

/**
* User: Pandassaurus
* Date: 2/17/14
*/
@Mod(modid = WTHMod.MODID, version = WTHMod.VERSION)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class WTHMod {
    public static final String MODID = "WTHMod";
    public static final String VERSION = "1.0";

    @SidedProxy(clientSide = "com.Pandassaurus.WTHMod.ClientProxy", serverSide = "com.Pandassaurus.WTHMod.CommonProxy")
    public static CommonProxy proxy;

    @Mod.EventHandler
    public void load(FMLInitializationEvent event) {
        proxy.registerRenderers();
    }

   /* @Mod.EventHandler
    public void preInt(FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(new SoundHandler());
    }
                        */

    public static int startEntityId = 300;

    public static int getUniqueEntityId() {
        do {
            startEntityId++;
        }
        while (EntityList.getStringFromID(startEntityId) != null);
        return startEntityId++;
    }

    public static void registerEntityEgg(Class<? extends Entity> entity, int primaryColor, int secondaryColor) {
        int id = getUniqueEntityId();
        EntityList.IDtoClassMapping.put(id, entity);
        EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
    }


    public WTHMod() {
        EntityRegistry.registerGlobalEntityID(EntityPedophileMob.class, "Pedophile", 1);
        EntityRegistry.addSpawn(EntityPedophileMob.class, 3, 1, 4, EnumCreatureType.creature);
        EntityRegistry.findGlobalUniqueEntityId();
        registerEntityEgg(EntityPedophileMob.class, 0xffffffff, 0x00033ff);
    }
}

 

 

Entity Class:

 

package com.Pandassaurus.WTHMod.mob.entity;

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

/**
* User: Pandassaurus
* Date: 2/18/14
*/
public abstract class EntityPedophileMob extends EntityCreature {
    public EntityPedophileMob(World par1World) {
        super(par1World);
    }

    public void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0D);
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(20D);
    }

    public boolean getCanSpawnHere() {
        return super.getCanSpawnHere();
    }

    public String getLivingSound() {
        return "modid:textures/sound/sounds/pedophilegrunt.ogg";
    }

    public void onLivingUpdate() {
        if (isInWater())
            this.worldObj.playSoundAtEntity(this, "modid:textures/sound/sounds/pedophilegrunt.ogg", 1.0F, 1.0F);
    }
}

 

 

Render Class:

 

package com.Pandassaurus.WTHMod.mob.render;

import com.Pandassaurus.WTHMod.mob.entity.EntityPedophileMob;
import com.Pandassaurus.WTHMod.mob.model.PedophileMob;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;

/**
* User: Pandassaurus
* Date: 2/18/14
*/
public class RenderPedophileMob extends RenderLiving {
    private static final ResourceLocation field_110837_a = new ResourceLocation("modid:textures/mobs/PedophileMob.png");
    protected PedophileMob model;

    public RenderPedophileMob(ModelBase par1ModelBase, float par2) {
        super(par1ModelBase, par2);
        model = ((PedophileMob) mainModel);
    }

    public void RenderPedophile(EntityPedophileMob entity, double par2, double par4, double par6, float par8, float par9) {
        super.doRenderLiving(entity, par2, par4, par6, par8, par9);
    }

    public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) {
        RenderPedophile((EntityPedophileMob) par1EntityLiving, par2, par4, par6, par8, par9);
    }

    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
        RenderPedophile((EntityPedophileMob) par1Entity, par2, par4, par6, par8, par9);
    }

    @Override
    protected ResourceLocation getEntityTexture(Entity entity) {
        return field_110837_a;
    }
}

 

 

Client Proxy:

 

package com.Pandassaurus.WTHMod;

import com.Pandassaurus.WTHMod.mob.entity.EntityPedophileMob;
import com.Pandassaurus.WTHMod.mob.model.PedophileMob;
import com.Pandassaurus.WTHMod.mob.render.RenderPedophileMob;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.Render;

/**
* User: Pandassaurus
* Date: 2/19/14
*/
public class ClientProxy extends CommonProxy {
    @Override
    public void registerRenderers() {
        RenderingRegistry.registerEntityRenderingHandler(EntityPedophileMob.class, new RenderPedophileMob(new PedophileMob(), 0.3F));
    }
}

 

 

Common Proxy

 

package com.Pandassaurus.WTHMod;

/**
* User: Pandassaurus
* Date: 2/19/14
*/
public class CommonProxy {
    public void registerRenderers() {
    }
}

 

 

Error:

 

java.lang.InstantiationException
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.entity.EntityList.createEntityByID(EntityList.java:205)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.item.ItemMonsterPlacer.spawnCreature(ItemMonsterPlacer.java:139)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.item.ItemMonsterPlacer.onItemUse(ItemMonsterPlacer.java:86)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:153)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.item.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:434)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.handlePlace(NetServerHandler.java:556)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.network.packet.Packet15Place.processPacket(Packet15Place.java:58)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
2014-02-19 17:33:42 [iNFO] [sTDERR] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:583)
2014-02-19 17:33:42 [WARNING] [Minecraft-Server] Skipping Entity with id 301

 

 

 

Dont mind the name of the mob :P

 

anyway, thanks, and any help is appreciated.

-Pandassaurus

Link to comment
Share on other sites

Oh sorry, I forgot to add the model class:

 

 

// Date: 2/17/2014 10:20:32 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX


package com.Pandassaurus.WTHMod.mob.model;

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

public class PedophileMob extends ModelBase {
    //fields
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightupperarm;
    ModelRenderer rightlowerarm;
    ModelRenderer leftupperarm;
    ModelRenderer leftlowerarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;

    public PedophileMob() {
        textureWidth = 64;
        textureHeight = 64;

        head = new ModelRenderer(this, 0, 0);
        head.addBox(-4F, -8F, -4F, 8, 8, ;
        head.setRotationPoint(0F, 0F, 0F);
        head.setTextureSize(64, 64);
        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, 64);
        body.mirror = true;
        setRotation(body, 0F, 0F, 0F);
        rightupperarm = new ModelRenderer(this, 40, 16);
        rightupperarm.addBox(-3F, -2F, -2F, 4, 7, 4);
        rightupperarm.setRotationPoint(-5F, 2F, 0F);
        rightupperarm.setTextureSize(64, 64);
        rightupperarm.mirror = true;
        setRotation(rightupperarm, 0F, 0F, 0F);
        rightlowerarm = new ModelRenderer(this, 32, 0);
        rightlowerarm.addBox(-2F, 0F, -2F, 4, 6, 4);
        rightlowerarm.setRotationPoint(-6F, 6F, 0F);
        rightlowerarm.setTextureSize(64, 64);
        rightlowerarm.mirror = true;
        setRotation(rightlowerarm, -0.7853982F, 0F, 0F);
        leftupperarm = new ModelRenderer(this, 40, 16);
        leftupperarm.addBox(-1F, -2F, -2F, 4, 7, 4);
        leftupperarm.setRotationPoint(5F, 2F, 0F);
        leftupperarm.setTextureSize(64, 64);
        leftupperarm.mirror = true;
        setRotation(leftupperarm, 0F, 0F, 0F);
        leftlowerarm = new ModelRenderer(this, 32, 0);
        leftlowerarm.addBox(-2F, 0F, -2F, 4, 6, 4);
        leftlowerarm.setRotationPoint(6F, 6F, 0F);
        leftlowerarm.setTextureSize(64, 64);
        leftlowerarm.mirror = true;
        setRotation(leftlowerarm, -0.7853982F, 0F, 0F);
        rightleg = new ModelRenderer(this, 0, 16);
        rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
        rightleg.setRotationPoint(-2F, 12F, 0F);
        rightleg.setTextureSize(64, 64);
        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, 64);
        leftleg.mirror = true;
        setRotation(leftleg, 0F, 0F, 0F);
    }

    public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
        setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
        head.render(par7);
        body.render(par7);
        rightupperarm.render(par7);
        rightlowerarm.render(par7);
        leftupperarm.render(par7);
        leftlowerarm.render(par7);
        rightleg.render(par7);
        leftleg.render(par7);
    }

    private void setRotation(ModelRenderer model, float x, float y, float z) {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
    }

    public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
    }

}

 

Link to comment
Share on other sites

Your mob should look black and purple because your pointing to a (mostly likely) non-existant texture at assets/modid/textures/mobs/PedophileMob.png instead of assets/wthmod/textures/mobs/PedophileMob.png

 

I do have the texture, but even if i didn't, but instead of there being a white or purple and black box, it's just invisible.

This is the class path of the picture:

 

http://24.media.tumblr.com/c2a434334eaa6e97a2efb17a2385c984/tumblr_n1bgybNCrF1sejvuqo1_250.png

 

 

Ctrl+F shows me that you're missing

Minecraft.theWorld.spawnEntityInWorld(yourEntityObject);

Would this be correct?

 

Also, be sure you're setting a location for your entity!

 

I am missing that, but is that necessary? In my other mod that I am trying i didn't need it. If so, where would i put it?

Also, what do you mean by setting a location for my entity?

 

I'm sorry, im new to modding, so thanks for the help!

-Pandassaurus

Link to comment
Share on other sites

I currently use spawnEntityinWorld, perhaps there is another method, I'm not sure, new to this as well ;)

BUT as for the location say you have your entity pandasauruss

 
EntityPandasauruss pandasauruss = new EntityPandasauruss(Minecraft.theWorld);
pandasauruss.setPositionAndUpdate(player.posX, player.posY, player.posZ);

The player.posX, etc. would change to be where your egg landed but same concept. Perhaps that will work for you.

Link to comment
Share on other sites

I currently use spawnEntityinWorld, perhaps there is another method, I'm not sure, new to this as well ;)

BUT as for the location say you have your entity pandasauruss

 
EntityPandasauruss pandasauruss = new EntityPandasauruss(Minecraft.theWorld);
pandasauruss.setPositionAndUpdate(player.posX, player.posY, player.posZ);

The player.posX, etc. would change to be where your egg landed but same concept. Perhaps that will work for you.

 

no, that didn't work for me.

 

thanks though,

-Pandassaurus

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.