Jump to content

[Solved] My New Mob Does Not Work


nickpops98

Recommended Posts

I tried adding a new mob 'Goblin' to the game but now it crashes.

 

Here is everything to do with the Goblin Entity and the Crash Report.

 

QuestCraft.java - Main Class

 

 

package nickpops98.questcraft;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityEggInfo;

import net.minecraft.entity.EntityList;

import net.minecraft.entity.EnumCreatureType;

import nickpops98.questcraft.entity.monster.EntityGoblin;

import nickpops98.questcraft.entity.monster.ModelGoblin;

import nickpops98.questcraft.entity.monster.RenderGoblin;

 

@Mod( modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)

public class QuestCraft {

 

    // Mob Generation Functions

 

    static int startEntityID = 300;

 

    public static int getUniqueEntityID() {

        do {

        startEntityID++;

        }

        while (EntityList.getStringFromID(startEntityID) != null);

        return startEntityID++;

    }

 

    @SuppressWarnings("unchecked")

    public static void registerEntityEgg(Class<? extends Entity> entity, int primaryColour, int secondaryColour){

          int id = getUniqueEntityID();

          EntityList.IDtoClassMapping.put(id, entity);

          EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColour, secondaryColour));

    }

 

    @EventHandler

    public void preInit(FMLInitializationEvent event) {

 

          // Entity Settings

 

          EntityRegistry.registerGlobalEntityID(EntityGoblin.class, "Goblin", 1);

 

          EntityRegistry.addSpawn(EntityGoblin.class, 10, 4, 8, EnumCreatureType.monster);

 

          EntityRegistry.findGlobalUniqueEntityId();

 

          registerEntityEgg(EntityGoblin.class, 0x007200, 0x8A5800);

 

          RenderingRegistry.registerEntityRenderingHandler(EntityGoblin.class, new RenderGoblin(new ModelGoblin(), 0.3F));

 

    }

 

}

 

 

Note: This is not the whole class only the things relating to the entity.

 

ModelGoblin.java - The Class Exported from Techne for the Model of the Goblin With Some Edits by Me

 

 

package nickpops98.questcraft.entity.monster;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

import net.minecraft.util.MathHelper;

 

public class ModelGoblin extends ModelBase

{

    ModelRenderer head;

    ModelRenderer body;

    ModelRenderer armRight;

    ModelRenderer armLeft;

    ModelRenderer legRight;

    ModelRenderer legLeft;

    ModelRenderer earRight;

    ModelRenderer earLeft;

 

  public ModelGoblin()

  {

    textureWidth = 32;

    textureHeight = 32;

 

      head = new ModelRenderer(this, 0, 0);

      head.addBox(-4F, -6F, -3F, 8, 6, 6);

      head.setRotationPoint(0F, 0F, 0F);

      head.setTextureSize(64, 32);

      head.mirror = true;

      setRotation(head, 0F, 0F, 0F);

      body = new ModelRenderer(this, 0, 12);

      body.addBox(-3F, 0F, -1F, 6, 6, 2);

      body.setRotationPoint(0F, 0F, 0F);

      body.setTextureSize(64, 32);

      body.mirror = true;

      setRotation(body, 0F, 0F, 0F);

      armRight = new ModelRenderer(this, 16, 13);

      armRight.addBox(0F, 0F, -1F, 2, 5, 2);

      armRight.setRotationPoint(3F, 1F, 0F);

      armRight.setTextureSize(64, 32);

      armRight.mirror = true;

      setRotation(armRight, 0F, 0F, 0F);

      armLeft.mirror = true;

      armLeft = new ModelRenderer(this, 16, 13);

      armLeft.addBox(-2F, 0F, -1F, 2, 5, 2);

      armLeft.setRotationPoint(-3F, 1F, 0F);

      armLeft.setTextureSize(64, 32);

      armLeft.mirror = true;

      setRotation(armLeft, 0F, 0F, 0F);

      armLeft.mirror = false;

      legRight = new ModelRenderer(this, 0, 20);

      legRight.addBox(-1F, 0F, -1F, 2, 4, 2);

      legRight.setRotationPoint(2F, 6F, 0F);

      legRight.setTextureSize(64, 32);

      legRight.mirror = true;

      setRotation(legRight, 0F, 0F, 0F);

      legLeft.mirror = true;

      legLeft = new ModelRenderer(this, 0, 20);

      legLeft.addBox(-1F, 0F, -1F, 2, 4, 2);

      legLeft.setRotationPoint(-2F, 6F, 0F);

      legLeft.setTextureSize(64, 32);

      legLeft.mirror = true;

      setRotation(legLeft, 0F, 0F, 0F);

      legLeft.mirror = false;

      earRight.mirror = true;

      earRight = new ModelRenderer(this, 8, 20);

      earRight.addBox(4F, -4F, -1F, 1, 2, 1);

      earRight.setRotationPoint(0F, 0F, 0F);

      earRight.setTextureSize(64, 32);

      earRight.mirror = true;

      setRotation(earRight, 0F, 0F, 0F);

      earRight.mirror = false;

      earLeft = new ModelRenderer(this, 8, 20);

      earLeft.addBox(-5F, -4F, -1F, 1, 2, 1);

      earLeft.setRotationPoint(0F, 0F, 0F);

      earLeft.setTextureSize(64, 32);

      earLeft.mirror = true;

      setRotation(earLeft, 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);

    head.render(f5);

    body.render(f5);

    armRight.render(f5);

    armLeft.render(f5);

    legRight.render(f5);

    legLeft.render(f5);

    earRight.render(f5);

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

  {

this.head.rotateAngleY = f3 / (180F /(float)Math.PI);

this.head.rotateAngleX = f4 / (170F /(float)Math.PI);

 

this.earLeft.rotateAngleY = f3 / (180F /(float)Math.PI);

this.earLeft.rotateAngleX = f4 / (170F /(float)Math.PI);

 

this.earRight.rotateAngleY = f3 / (180F /(float)Math.PI);

this.earRight.rotateAngleX = f4 / (170F /(float)Math.PI);

 

this.legLeft.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;

this.legLeft.rotateAngleY = 0.0F;

 

this.legRight.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1;

this.legRight.rotateAngleY = 0.0F;

 

this.armLeft.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F;

this.armLeft.rotateAngleZ = 0.0F;

 

this.armRight.rotateAngleX = MathHelper.cos(f * 0.6663F + (float)Math.PI) * 2.0F * f1 * 0.5F;

this.armRight.rotateAngleY = 0.0F;

  }

 

}

 

 

 

 

EntityGoblin.java - The AI for the Goblin

 

 

package nickpops98.questcraft.entity.monster;

 

import net.minecraft.entity.EnumCreatureAttribute;

import net.minecraft.entity.ai.EntityAIAttackOnCollide;

import net.minecraft.entity.ai.EntityAIHurtByTarget;

import net.minecraft.entity.ai.EntityAILookIdle;

import net.minecraft.entity.ai.EntityAINearestAttackableTarget;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.world.World;

 

public class EntityGoblin extends EntityMob {

 

public EntityGoblin(World par1World) {

super(par1World);

this.experienceValue = 5;

        this.tasks.addTask(0, new EntityAISwimming(this));

  this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.6D, false));

  this.tasks.addTask(6, new EntityAIWander(this, 0.6D));

  this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

  this.tasks.addTask(7, new EntityAILookIdle(this));

  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));

  this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));

}

 

protected boolean isAIEnabled() {

return true;

}

 

public int getMaxHealth() {

return 10;

}

 

protected String getLivingSound() {

        return "mob.zombie.say";

    }

 

    protected String getHurtSound() {

        return "mob.zombie.hurt";

    }

 

    protected String getDeathSound() {

        return "mob.zombie.death";

    }

 

    protected void playStepSound(int par1, int par2, int par3, int par4) {

        this.playSound(null, 0.15F, 1.0F);

    }

 

    protected int getDropItemID() {

    return Item.leather.itemID;

 

    }

 

    protected void dropFewItems(boolean par1, int par2) {

        int j = this.rand.nextInt(2 + par2);

        int k;

 

        for (k = 0; k < j; ++k)

        {

            this.dropItem(Item.leather.itemID, 1);

        }

 

        j = this.rand.nextInt(1 + par2);

 

        for (k = 0; k < j; ++k)

        {

            this.dropItem(Item.ingotGold.itemID, 1);

        }

    }

 

    public EnumCreatureAttribute getCreatureAttribute() {

    return EnumCreatureAttribute.UNDEFINED;

    }

 

    public void onLivingUpdate() {

    super.onLivingUpdate();

    }

 

}

 

 

 

 

RenderGoblin.java - The Rendering Class for the Goblin

 

 

package nickpops98.questcraft.entity.monster;

 

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;

 

public class RenderGoblin extends RenderLiving {

 

protected ModelGoblin model;

 

public RenderGoblin(ModelBase par1ModelBase, float par2) {

super(par1ModelBase, par2);

model = ((ModelGoblin)mainModel);

}

 

public void renderGoblin(EntityGoblin 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) {

renderGoblin((EntityGoblin)par1EntityLiving, par2, par4, par6, par8, par9);

}

 

@Override

public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) {

renderGoblin((EntityGoblin)entity, d0, d1, d2, f, f1);

}

 

@Override

protected ResourceLocation func_110775_a(Entity entity) {

return new ResourceLocation("questcraft:textures/mobs/goblin.png");

}

 

}

 

 

 

 

Crash Report

 

 

---- Minecraft Crash Report ----

// Quite honestly, I wouldn't worry myself about that.

 

Time: 17/12/13 5:56 PM

Description: Initializing game

 

java.lang.NullPointerException

at nickpops98.questcraft.entity.monster.ModelGoblin.<init>(ModelGoblin.java:41)

at nickpops98.questcraft.QuestCraft.preInit(QuestCraft.java:432)

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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:540)

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:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

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:194)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:174)

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:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

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:105)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:697)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:231)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:506)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)

at net.minecraft.client.main.Main.main(Main.java:93)

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:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

 

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

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at nickpops98.questcraft.entity.monster.ModelGoblin.<init>(ModelGoblin.java:41)

at nickpops98.questcraft.QuestCraft.preInit(QuestCraft.java:432)

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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:540)

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:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

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:194)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:174)

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:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

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:105)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:697)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:231)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:506)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)

at net.minecraft.client.main.Main.main(Main.java:93)

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:57)

at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

 

-- System Details --

Details:

Minecraft Version: 1.6.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot™ Client VM (mixed mode), Oracle Corporation

Memory: 983210480 bytes (937 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v8.04 FML v6.2.43.821 Minecraft Forge 9.10.0.821 4 mods loaded, 4 mods active

mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized

FML{6.2.43.821} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized

Forge{9.10.0.821} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized

QC{0.0.1} [Quest Craft] (bin) Unloaded->Constructed->Pre-initialized->Errored

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Intel® HD Graphics GL version 2.1.0 - Build 8.15.10.2202, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Pack: Default

Current Language: English (UK)

Profiler Position: N/A (disabled)

Vec3 Pool Size: ~~ERROR~~ NullPointerException: null

 

 

 

Can you please help me by finding where the problem is and how i can solve it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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