Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Entity Help[FORGE]


  • Please log in to reply
8 replies to this topic

#1

bartselen

Posted 02 December 2012 - 06:02 PM

I made a mob but the spawn egg won't appear and it doesn't spawn.
Maybe it's something with my rendering code?
Please help me.
Thanks!
Main Mod Class:
package bt_mods.mods;

import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.Block;
import net.minecraft.src.EnumCreatureType;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
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;

@Mod(modid = "BTMod.A", name = "Companion Love by bartselen", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)




public class BTMod {
public static net.minecraft.src.Item companionIngot;
public static net.minecraft.src.Item companionShard;
public static net.minecraft.src.Block companionOre;
public static net.minecraft.src.Block companionCube;
public static net.minecraft.src.Block companionBlock;
@SidedProxy(clientSide = "bt_mods.client.ClientProxyTutorial", serverSide = "bt_mods.mods.CommonProxy")
public static CommonProxyTut proxy;



@Init
public void load(FMLInitializationEvent event)
{

//*Blocks:
//Companionite Ore
companionOre = new companionOre(230, 0).setHardness(7F).setResistance(3.0F).setBlockName("companionOre");
GameRegistry.registerBlock(companionOre);
LanguageRegistry.addName(companionOre, "Companionite Ore");

//Companionite Block
companionBlock = new companionBlock(231, 1).setHardness(7F).setResistance(3.0F).setBlockName("companionBlock");
GameRegistry.registerBlock(companionBlock);
LanguageRegistry.addName(companionBlock, "Companionite Block");

//Companion Cube
companionCube = new companionCube(232, 4).setHardness(4F).setResistance(1000.0F).setBlockName("companionCube").setLightValue(1.0F);
GameRegistry.registerBlock(companionCube);
LanguageRegistry.addName(companionCube, "\u00a7aCompanion Cube\u00a7f");

//*Items:
//Companionite Gem
companionIngot = new ItemCompanionIngot(550).setIconIndex(2).setItemName("companionIngot");
LanguageRegistry.addName(companionIngot, "Companionite Gem");

//Companionite Shard
companionShard = new ItemCompanionShard(551).setIconIndex(3).setItemName("companionShard");
LanguageRegistry.addName(companionShard, "Companionite Shard");

//*Crafting Recipes:
//Companionite Gem
GameRegistry.addRecipe(new ItemStack(BTMod.companionIngot), new Object[]
{
"XXX", "XXX", "XXX", 'X', new ItemStack(BTMod.companionShard)
});
//Companion Cube
GameRegistry.addRecipe(new ItemStack(BTMod.companionCube), new Object[]
{
"ZSZ", "SXS", "ZSZ", 'X', BTMod.companionIngot, 'S', Block.stone, 'Z', Block.blockSteel
});
//Mobs

int greyColor = (180 << 16) + (180 << 8) + (180);
int orangeColor = (255 << 16)+ (200 << 8);

EntityRegistry.registerModEntity(EntityCompanionCube.class, "Companion Cube", 1, this, 40, 3, true);
EntityRegistry.addSpawn(EntityCompanionCube.class, 10, 2, 4, EnumCreatureType.creature, BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.swampland);


//Proxy Render
proxy.registerRenderThings();

//Generation Register
GameRegistry.registerWorldGenerator(new BT_WorldGen());

}
}

Entity Class:
package bt_mods.mods;

import net.minecraft.src.Entity;
import net.minecraft.src.EntityAIAttackOnCollide;
import net.minecraft.src.EntityAIBreakDoor;
import net.minecraft.src.EntityAIHurtByTarget;
import net.minecraft.src.EntityAINearestAttackableTarget;
import net.minecraft.src.EntityAISwimming;
import net.minecraft.src.EntityAIWander;
import net.minecraft.src.EntityAIWatchClosest;
import net.minecraft.src.EntityCreature;
import net.minecraft.src.EntityMob;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumCreatureAttribute;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.World;

public class EntityCompanionCube extends EntityCreature
{
public EntityCompanionCube(World par1World)
{
super(par1World);
this.texture = "/Tutorial/TutorialEntity.png";
this.moveSpeed = 0.25F;
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIBreakDoor(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false));
this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(4, new EntityAIWander(this, this.moveSpeed));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));
}

public int getAttackStrength(Entity par1Entity)
{
return 4;
}

protected boolean isAIEnabled()
{
return true;
}

public int getMaxHealth()
{
return 20;
}

public EnumCreatureAttribute getCreatureAttribute()
{
return EnumCreatureAttribute.UNDEFINED;
}

public String getTexture()
{
return "/Tutorial/Tutorialmob.png";
}

public int getTotalArmorValue()
{
return 2;
}

public void onLivingUpdate()
{

}

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.worldObj.playSoundAtEntity(this, "mob.zombie.step", 0.15F, 1.0F);
}

protected int getDropItemId()
{
return Item.ingotGold.shiftedIndex;
}

protected void dropRareDrop(int par1)
{
switch (this.rand.nextInt(2))
{
case 0:
this.dropItem(Item.ingotIron.shiftedIndex, 1);
break;
case 1:
this.dropItem(Item.helmetSteel.shiftedIndex, 1);
break;
}
}

protected void dropFewItems(boolean par1, int par2)
{
if(this.rand.nextInt(3) == 0)
{
this.dropItem(Item.appleRed.shiftedIndex, 1);
}
}
}

Client Proxy:
package bt_mods.client;

import net.minecraft.src.ModelBiped;
import net.minecraft.src.RenderBiped;
import net.minecraft.src.RenderLiving;
import net.minecraftforge.client.MinecraftForgeClient;
import bt_mods.mods.CommonProxyTut;
import bt_mods.mods.EntityCompanionCube;
import cpw.mods.fml.client.registry.RenderingRegistry;



public class ClientProxyTutorial extends CommonProxyTut {

@Override
public void registerRenderThings(){

MinecraftForgeClient.preloadTexture("/SpriteSheet_CL.png");

RenderingRegistry.registerEntityRenderingHandler(EntityCompanionCube.class, new RenderEntity(new ModelBiped(), 0.05f));
}
}

Please Please Please Please Help Me!

Register or log in to remove.

#2

Fr3nchT0ast

Posted 02 December 2012 - 06:30 PM

This might help:

http://wuppy29.blogs...odding-142.html

#3

lockNload147
  • Location: VVNBLCBNYXNz
  • Minecraft: Don't play

Posted 02 December 2012 - 07:18 PM

http://www.minecraft...__140#howto_egg

Wuppy made an Android app for his tutorials... lol

Posted Image


#4

bartselen

Posted 03 December 2012 - 11:14 AM

It doesn't work... Please Help Me

#5

Teotoo
    Teotoo

    Void Walker

  • Members
  • 1883 posts

Posted 06 December 2012 - 02:10 PM

Nowhere in here are you doing registerGlobalEntityID. I believe you should be, for living entities.

Also you've made variables for the spawn egg colors, but you've not used them anywhere. You use them in the registerGlobalEntityID method.

A side note:

public static net.minecraft.src.Item companionIngot;
public static net.minecraft.src.Item companionShard;
public static net.minecraft.src.Block companionOre;
public static net.minecraft.src.Block companionCube;
public static net.minecraft.src.Block companionBlock;

Don't do that. You've already imported Item and Block, you shouldn't be declaring the packages each time you use them. Just do:

public static Item companionIngot;
public static Item companionShard;
public static Block companionOre;
public static Block companionCube;
public static Block companionBlock;

Posted Image
If you're having trouble pronouncing my name, it's Tea-oh-2. If you have a crashlog, put it in spoiler tags!

#6

Mordil
    Mordil

    Out of the Water

  • Members
  • 5 posts
  • Location: Reno, NV
  • Minecraft: Mordil

Posted 07 December 2012 - 08:49 PM

At your class declaration:

type " public class YOURMOD extends BaseMod
{
    STUFF;
}"

and then remove "FMLInitializationEventevent" from your "public void load(){}".

and then underneath load(), add:

public void addRenderer(Map map)
{
      map.put(EntityYOURMOB.class, new RenderYOURMOB(new ModelYOURMOB(), 0.5F));
}
Spellbook Entertainment - CEO
www.spellbookentertainment.com

#7

Crunchy_Nut
  • Minecraft: Crunchie_Nut

Posted 07 December 2012 - 09:29 PM

View PostMordil, on 07 December 2012 - 08:49 PM, said:

At your class declaration:

type " public class YOURMOD extends BaseMod
{
STUFF;
}"

and then remove "FMLInitializationEventevent" from your "public void load(){}".

and then underneath load(), add:

public void addRenderer(Map map)
{
  map.put(EntityYOURMOB.class, new RenderYOURMOB(new ModelYOURMOB(), 0.5F));
}
He is using forge, what you put is outdated ModLoader junk.

Ontopic:
Replace EntityRegistry.registerModEntity with this:
EntityRegistry.registerGlobalEntityID(Entity.class, "name",  ModLoader.getUniqueEntityId(), eggColor1, eggColor2);


#8

Mordil
    Mordil

    Out of the Water

  • Members
  • 5 posts
  • Location: Reno, NV
  • Minecraft: Mordil

Posted 07 December 2012 - 09:31 PM

No, what I am using is Forge, mixed with ModLoader, as I've seen from Minecraftforge.net's own tutorials.

You were correct with EntityRegistry.registerGlobalEntityID, EntityRegistry.registerEntity doesn't work with more than 1 mob, nor does ModLoader.registerEntityID.
Spellbook Entertainment - CEO
www.spellbookentertainment.com

#9

Crunchy_Nut
  • Minecraft: Crunchie_Nut

Posted 07 December 2012 - 09:35 PM

View PostMordil, on 07 December 2012 - 09:31 PM, said:

No, what I am using is Forge, mixed with ModLoader, as I've seen from Minecraftforge.net's own tutorials.

You were correct with EntityRegistry.registerGlobalEntityID, EntityRegistry.registerEntity doesn't work with more than 1 mob, nor does ModLoader.registerEntityID.

You were referencing the old forge. The latest forge (post 1.3) is completely different as in it doesn't use extends BaseMod or any of that rubbish. Even though FML still allows it to be used, its still outdated.