Créer un mob basique
-
Ah oui merci, sinon pour les balises je savais pas m’en servir x).
Maintenant ça marche, mais les textures sont buguées (le skin est noir et les bras violets).
C’est peut-être du au fait que j’ai voulu qu’il y ai 2 skins possibles :protected static final ResourceLocation minerTexture = new ResourceLocation(“ModMoHumans2:mob/mineur.png”);
L’erreur pour les textures est (encore désolé pour les balises, si on pouvait m’expliquer x)

2013-10-03 18:45:38 [WARNING] [Minecraft-Client] Failed to load texture: modmohumans2:mob/assassin.png
java.io.FileNotFoundException: modmohumans2:mob/assassin.png
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67)
at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:31)
at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:84)
at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:41)
at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:53)
at net.minecraft.client.renderer.entity.Render.bindEntityTexture(Render.java:48)
at net.minecraft.client.renderer.entity.RendererLivingEntity.renderModel(RendererLivingEntity.java:295)
at net.minecraft.client.renderer.entity.RendererLivingEntity.doRenderLiving(RendererLivingEntity.java:155)
at net.minecraft.client.renderer.entity.RenderLiving.doRenderLiving(RenderLiving.java:28)
at net.minecraft.client.renderer.entity.RenderBiped.doRenderLiving(RenderBiped.java:194)
at net.minecraft.client.renderer.entity.RenderBiped.doRender(RenderBiped.java:376)
at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:312)
at net.minecraft.client.renderer.entity.RenderManager.renderEntity(RenderManager.java:281)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:524)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1160)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1006)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:944)
at net.minecraft.client.Minecraft.run(Minecraft.java:836)
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)–-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDIT :
Je pense qu’il y a quelques bug avec l’attribut “attackDamage” car je veux m’en servir pour un mob agressif et j’ai le même bug que pour le mineur.Est-ce que si je ne met pas l’attribut à “attackDamage” le mob aura la valeur d’attaque par défaut ?
-
this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D)?;La plus part des crash en sont la cause, donc vire-le.

-
@‘MrBlockTNT’:
Ah oui merci, sinon pour les balises je savais pas m’en servir x).
Maintenant ça marche, mais les textures sont buguées (le skin est noir et les bras violets).
C’est peut-être du au fait que j’ai voulu qu’il y ai 2 skins possibles :protected static final ResourceLocation minerTexture = new ResourceLocation(“ModMoHumans2:mob/mineur.png”);
Et j’arrive toujours pas à mettre les balises.
–---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDIT :
Je pense qu’il y a quelques bug avec l’attribut “attackDamage” car je veux m’en servir pour un mob agressif et j’ai le même bug que pour le mineur.[size=xx-large
PAS DE MAJUSCULES DANS LES MODID]
-> modmohumans2Et pour le code java, tu écris :
[java]le code ici [java] avec un / avant java sur le deuxième. -
Ok merci tout le monde je teste tout de suite

EDIT :
Le followRange ne change rien par rapport au attackDamage, donc ça bugue toujours et les textures buguent encore
-
Ou as-tu placé les textures ?
En passant, utilise plutôt :protected static final ResourceLocation minerTexture = new ResourceLocation("modmohumans2", "mob/mineur.png"); -
@‘MrBlockTNT’:
Le followRange ne change rien par rapport au attackDamage, donc ça bugue toujours et les textures buguent encore

followRange laisse le par défaut (donc supprimes la ligne) car beaucoup de personnes ont eu des crashs à cause du followRange modifié.
-
Mon followRange est par défaut donc il sert à rien c’est vrai x). Merci robin4002 pour cette astuce, je vais m’en servir.
-
@‘robin4002’:
Ou as-tu placé les textures ?
En passant, utilise plutôt :protected static final ResourceLocation minerTexture = new ResourceLocation("modmohumans2", "mob/mineur.png");Merci, ça marche :D. Par contre je n’arrive pas à mettre plusieurs textures pour le même mob :(.
Si quelqu’un pouvait m’aider
D’ailleurs j’ai fait quelques tests mais mes mobs ne m’attaquent pas, même en survival. Une solution :D?
EDIT :
La texture de mon chevalier est invisible, pouvez-vous m’aider ?Mon code :
RenderKnight :package fr.MrBlockTNT.MoHumans; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; public class RenderKnight extends RenderBiped { protected static final ResourceLocation texture = new ResourceLocation("modmohumans2", "mob/knight1.png"); public RenderKnight(ModelBiped base, float tailleOmbre) { super(base, tailleOmbre); } protected ResourceLocation getTextures(EntityAssassin miner) { return texture; } protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getTextures((EntityAssassin)par1Entity); } }ClientProxy :
package MrBlockTNT.Proxy; import cpw.mods.fml.client.registry.RenderingRegistry; import fr.MrBlockTNT.MoHumans.*; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityMiner.class, new RenderMiner(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityAssassin.class, new RenderAssassin(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityKnight.class, new RenderKnight(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityWoodCuter.class, new RenderWoodCuter(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityHunter.class, new RenderHunter(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityBarbarian.class, new RenderBarbarian(new ModelBiped(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityPirate.class, new RenderPirate(new ModelBiped(), 0.5F)); } }ModMoHumans2 :
package fr.MrBlockTNT.MoHumans; import net.minecraft.entity.EnumCreatureType; import MrBlockTNT.Proxy.CommonProxy; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; 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.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = "ModMoHumans2", name = "Mo'Humans 2", version = "1.0.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class ModMoHumans { @SidedProxy(clientSide = "MrBlockTNT.Proxy.ClientProxy", serverSide = "MrBlockTNT.Proxy.CommonProxy") public static CommonProxy proxy; @Instance("ModMoHumans2") public static ModMoHumans instance; @EventHandler public void PreInit(FMLPreInitializationEvent event) { } @EventHandler public void Init(FMLInitializationEvent event) { proxy.registerRender(); EntityRegistry.registerGlobalEntityID(EntityMiner.class, "Miner", EntityRegistry.findGlobalUniqueEntityId(), 0x6A7372, 0x78807F); EntityRegistry.registerModEntity(EntityMiner.class, "Miner", 500, this, 40, 1, true); EntityRegistry.addSpawn(EntityMiner.class, 1, 1, 2, EnumCreatureType.ambient); LanguageRegistry.instance().addStringLocalization("entity.Miner.name", "Miner"); EntityRegistry.registerGlobalEntityID(EntityAssassin.class, "Assassin", EntityRegistry.findGlobalUniqueEntityId(), 0xF00000, 0x9E9292); EntityRegistry.registerModEntity(EntityAssassin.class, "Assassin", 501, this, 40, 1, true); EntityRegistry.addSpawn(EntityAssassin.class, 1, 1, 1, EnumCreatureType.monster); LanguageRegistry.instance().addStringLocalization("entity.Assassin.name", "Assassin"); EntityRegistry.registerGlobalEntityID(EntityKnight.class, "Knight", EntityRegistry.findGlobalUniqueEntityId(), 0x131514, 0xC6DCD9); EntityRegistry.registerModEntity(EntityKnight.class, "Knight", 502, this, 40, 1, true); EntityRegistry.addSpawn(EntityKnight.class, 1, 3, 1, EnumCreatureType.ambient); LanguageRegistry.instance().addStringLocalization("entity.Knight.name", "Knight"); EntityRegistry.registerGlobalEntityID(EntityWoodCuter.class, "WoodCuter", EntityRegistry.findGlobalUniqueEntityId(), 0x261801, 0x674306); EntityRegistry.registerModEntity(EntityWoodCuter.class, "WoodCuter", 503, this, 40, 1, true); EntityRegistry.addSpawn(EntityWoodCuter.class, 1, 1, 1, EnumCreatureType.ambient); LanguageRegistry.instance().addStringLocalization("entity.WoodCuter.name", "Woodcuter"); EntityRegistry.registerGlobalEntityID(EntityHunter.class, "Hunter", EntityRegistry.findGlobalUniqueEntityId(), 0x261811, 0xC7C3BC); EntityRegistry.registerModEntity(EntityHunter.class, "Hunter", 504, this, 40, 1, true); EntityRegistry.addSpawn(EntityHunter.class, 1, 1, 1, EnumCreatureType.ambient); LanguageRegistry.instance().addStringLocalization("entity.Hunter.name", "Hunter"); EntityRegistry.registerGlobalEntityID(EntityBarbarian.class, "Barbarian", EntityRegistry.findGlobalUniqueEntityId(), 0x231300, 0x000000); EntityRegistry.registerModEntity(EntityBarbarian.class, "Barbarian", 505, this, 40, 1, true); EntityRegistry.addSpawn(EntityBarbarian.class, 1, 1, 1, EnumCreatureType.monster); LanguageRegistry.instance().addStringLocalization("entity.Barbarian.name", "Barbarian"); EntityRegistry.registerGlobalEntityID(EntityPirate.class, "Pirate", EntityRegistry.findGlobalUniqueEntityId(), 0x0F19AF, 0xDB0000); EntityRegistry.registerModEntity(EntityPirate.class, "Pirate", 506, this, 40, 1, true); EntityRegistry.addSpawn(EntityPirate.class, 1, 1, 1, EnumCreatureType.monster); LanguageRegistry.instance().addStringLocalization("entity.Pirate.name", "Pirate"); } @EventHandler public void PostInit(FMLPostInitializationEvent event) { } }EDIT 2 :
En fait j’ai trouvé mon erreur, qui était due à un oubli de modification après copié/collé x) . -
Tu veux faire quoi pour provoquer le changement de texture?
-
Une texture aléatoire parmi les disponibles pour le mob à son spawn (ex: mineur1/mineur2) comme pour les anciennes versions de forge.
-
Essaye de mettre du Random dans une condition. Sinon, regarde le code des Chevaux ou des villageois.
-
Ok merci, mais je me sert pas trop des Random donc… disons que ça va être légèrement compliqué

EDIT :
Il n’existerai pas un event de Forge fait exprès ? :huh: -
Comment fait-on pour faire tenir un objet à un mob ? J’ai cherché dans les classes des mobs de base comme le squelette mais tout ce que j’ai testé ne marche pas.
PS :
Existe-t-il une page web concernant les degrés de fréquence de spawn Minecraft ? (Je sais pas si c’est la rareté qui est trop élevée ou si c’est mes mobs qui buguent :() -
@‘MrBlockTNT’:
Ok merci, mais je me sert pas trop des Random donc… disons que ça va être légèrement compliqué

EDIT :
Il n’existerai pas un event de Forge fait exprès ? :huh:Pourquoi il y aurait un event pour un truc aussi simple o_O
Tu déclare deux resourceLocation, et ensuite :protected ResourceLocation getAniZobTextures(EntityAnizob anizob) { if(anizob.worldObj.rand.nextInt(1) == 0) { return texture; } else { return texture2; } }Rien de compliqué.
Pour faire tenir un objet en main, il y a une fonction dans le mob, mais aussi dans le rendu. -
Ok merci, par contre je crois que tu as répondu après mon edit x) donc si quelqu’un pouvait m’aider à ce niveau là (fréquence de spawn)
-
Hum, pour ta question dans le ton édit, je sais pas.
-
C’est ```java
EntityRegistry.addSpawn(Anyzoo.class, 5, 2, 4, EnumCreatureType.monster, BiomeGenBase.plains); -
Salut !
Merci pour ce tutoriel
Petit problème : mon mob ne fait pas planter le client (c’est déjà ça) mais il génère des erreurs quand j’essaye de le faire pop ::::
Client> 2013-10-26 19:04:31 [INFO] [STDERR] java.lang.reflect.InvocationTargetException
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at java.lang.reflect.Constructor.newInstance(Unknown Source)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.entity.EntityList.func_75616_a(EntityList.java:205)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.item.ItemMonsterPlacer.func_77840_a(SourceFile:139)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.item.ItemMonsterPlacer.func_77648_a(SourceFile:86)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.item.ItemStack.func_77943_a(ItemStack.java:152)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.item.ItemInWorldManager.func_73078_a(ItemInWorldManager.java:429)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.network.NetServerHandler.func_72472_a(NetServerHandler.java:554)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.network.packet.Packet15Place.func_73279_a(SourceFile:58)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.network.MemoryConnection.func_74428_b(MemoryConnection.java:89)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:141)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:54)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.integrated.IntegratedServerListenThread.func_71747_b(IntegratedServerListenThread.java:109)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:689)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:585)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:129)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:582)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] Caused by: java.lang.NullPointerException
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at Yseriu.Test.EntityAntiZob.func_110147_ax(EntityAntiZob.java:19)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:193)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:85)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at net.minecraft.entity.EntityCreature.<init>(SourceFile:22)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] at Yseriu.Test.EntityAntiZob.<init>(EntityAntiZob.java:10)
Client> 2013-10-26 19:04:31 [INFO] [STDERR] … 20 more
Client> 2013-10-26 19:04:31 [WARNING] [Minecraft-Server] Skipping Entity with id 25:::
Et voilà, juste ça dans les logs, rien de visible IG
Mon code :
Entity
:::package Yseriu.Test; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.world.World; public class EntityAntiZob extends EntityCreature { public EntityAntiZob(World par1World) { super(par1World); this.tasks.addTask(1, new EntityAISwimming(this)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(40D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.7D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(8D); } }:::
Render
:::package Yseriu.Test; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderAntiZob extends RenderBiped { protected static final ResourceLocation texture = new ResourceLocation("ytestmod:alex.png"); public RenderAntiZob(ModelBiped biped, float tailleOmbre) { super(biped, tailleOmbre); } protected ResourceLocation getAntiZobTextures(EntityAntiZob anizob) { return texture; } protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getAntiZobTextures((EntityAntiZob)par1Entity); } }:::
Merci !</init></init></init></init>
-
Supprime la ligne
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(8D);
Les mobs extends EntityCreature ne sont pas agressif, et donc ne fond pas de dégât. Il faut faire un extends EntityMob si tu veux qu’il soit agressif. -
ça marche, merci

enfin, mon mob a pas de texture … j’ai mis le fichier de texture un peu partout, j’ai regardé le fichier du squelette, du coup j’ai changé le : en / toujours rien (le mob est là, je vois sa barre de vie de TukMC) sur les logs, j’ai des NPE, et des ReportedException: Registering texture.
Je sais pas quoi faire.
