Texture bébé et random
-
Merci, mais je n’ai pas trop compris :s
-
Je la met où à true? J’ai essayé dans le field (private boolean isChild = true) et aussi dans la fonction ResourceLocation (if (this.isChild) = true), mais pour les deux cas les adultes ont aussi cette texture

-
Je dois les utiliser comment ces deux fonctions? J’ai essayé comme cela (je me suis inspirée dans la class EntityHorse):
public void writeEntityToNBT (NBTTagCompound tag) { super.writeEntityToNBT(tag); } public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); }mais ils changent toujours de texture
-
-
- Non ce n’est pas comme ça ^^ Copie le constructeur actuel et colle-le dans ta classe, ajoutes “boolean isChild” en argument, puis à la fin de celui-ci, mets “this.isChild = isChild;” puis dans l’autre constructeur, remplace son contenu par “this(world, false);”, ensuite, dans ta fonction createChild, rajoute true après l’argument this.worldObj que tu passes à la nouvelle entitée.
- Ton int ne va pas se sauvegarder par magie ^^ Dans writeEntityToNBT, il faut que tu fasses “tag.setInteger(je te laisse compléter eclipse est ton ami);” et dans readEntityFromNBT, “texture = tag.readInteger(je te laisse compléter eclipse est ton ami);”.
-
- Attention ! Il faudra que tu synchronises ta valeur avec les datawatchers. Sers toi de la classe EntityOcelot, les skins des chats apprivoisés représentent ta demande

- Attention ! Il faudra que tu synchronises ta valeur avec les datawatchers. Sers toi de la classe EntityOcelot, les skins des chats apprivoisés représentent ta demande
-
-
Je n’ai pas compris ce qu’il faut exactement rajouter dans la fonction createChild
-
Effectivement, quand j’ai rajouter ce qu’il fallait dans “writeEntityToNBT” et “readEntityToNBT”, le jeu ne voulais plus se sauvegarder, donc j’ai essayé de solutionner ça avec les datawatchers.
J’ai été regarder dans les class EntityOcelot et RenderOcelot. Voila ce que j’obtient:
:::
La class Entity
public class EntityDeer extends EntityAnimal { public int texture; private World isChild; public EntityDeer(World world) { super(world); texture = this.worldObj.rand.nextInt(2); this.setSize(0.7F, 0.7F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); this.tasks.addTask(3, new EntityAITempt(this, 1.2D, Items.wheat, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } public EntityDeer createChild(EntityAgeable entity) { return new EntityDeer(this.worldObj); } public boolean isBreedingItem(ItemStack breed) { return breed != null && breed.getItem() == Items.wheat; } public void writeEntityToNBT (NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setInteger("DeerType", this.getSkin()); } public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); this.setSkin(tag.getInteger("DeerType")); } public int getSkin() { return this.dataWatcher.getWatchableObjectByte(18); } public void setSkin(int skin) { this.dataWatcher.updateObject(18, Byte.valueOf((byte)skin)); } }La class render
public class RenderDeer extends RenderLiving { public boolean isChild; private static final ResourceLocation deerMaleTexture = new ResourceLocation("animalia:textures/entity/deermale.png"); private static final ResourceLocation deerFemaleTexture = new ResourceLocation("animalia:textures/entity/deerfemale.png"); public RenderDeer(ModelBase model, boolean isChild) { super(model, 0.5F); this.isChild = isChild; } public RenderDeer(ModelBase world) { this(world, false); } public ResourceLocation getEntityDeerTextures(EntityDeer entity) { if (this.isChild) { return new ResourceLocation("animalia:textures/entity/deerchild.png"); } else { switch (entity.getSkin()) { case 0: default: return deerMaleTexture; case 1: return deerFemaleTexture; } } } protected ResourceLocation getEntityTexture(Entity entity) { return getEntityDeerTextures((EntityDeer)entity); } }:::
Sauf que petit problème, les mobs apparaissent transparents.
J’ai modifié le getTameSkin en getSkin et j’ai retiré des “case” dans le render (je ne sais pas si c’est ça qui pose soucis).
Autre question: les textures random sont inutiles quand on utilise les datawatchers alors?
Dans les class, il y a ce que j’ai fait pour les deux questions
-
-
Nan ce n’est pas inutile sinon je n’aurai pas envoyé de messages. Tu as juste oublié d’override la méthode entityInit afin d’enregistrer le datawatcher. Regarde de nouveau la classe de l’entity ocelog car apparemment tu l’as survolée.
-
Merci ça a réglé le problème de transparence
et effectivement le random est toujours utile, sans lui, j’avais toujours la même texture pour mon mob.
Pour ceux qui veulent la solution, j’ai utiliser çaswitch (entity.getSkin()) { case 0: default: return new ResourceLocation("animalia:textures/entity/deer" + entity.texture + ".png"); }Dans le resourceLocation
Il me manque plus que la réponse pour la texture du bébé.
-
Pour la texture du bébé, il faut que tu ajoute “boolean isChild” en argument au constructeur. Tu dois ensuite ajouter “this.isChild = isChild;” dans ton constructeur. Ce constructeur permettra de faire spawner l’entité en choisissant si c’est un bébé ou non. Ensuite, tu ajoute un deuxième constructeur :
public EntityDeer(World world) { this(world, false) }Celui-ci permet de spawner l’entité directement adulte.
Enfin, dans la fonction createChild, tu spécifie que l’entité est un bébé en faisant “return new EntityDeer(this.worldObj, true);”(sources : message de AymericRed, partie 1)
-
public ResourceLocation getEntityDeerTextures(EntityDeer entity) { if (entity.isChild()) { return new ResourceLocation("animalia:textures/entity/deerchild.png"); } else { return new ResourceLocation("animalia:textures/entity/deer" + entity.texture + ".png"); } }Pourquoi faire compliquer quand on peut faire simple ?
La fonction isChild() renvoie déjà la valeur qu’on veut et se trouve dans EntityAgeable.Pas besoin de créer une nouvelle variable booléenne.
-
J’ai réussi pour la texture des bébés
J’ai été regardé dans la class des loups comme eux aussi peuvent avoir des textures différents et j’ai trouvé un truc beaucoup plus simple.public ResourceLocation getEntityDeerTextures(EntityDeer entity) { return entity.isChild() ? new ResourceLocation("animalia:textures/entity/deerchild.png") : (new ResourceLocation("animalia:textures/entity/deer" + entity.texture + ".png")); }Par contre, les textures random change toujours dès que je quitte mon monde

-
Il faudrait que tu print ton entity.texture voir ce qu’il renvoit. Refile nous la classe de ton entity qu’on voit un peu tes erreurs.
-
Voici la classe:
public class EntityDeer extends EntityAnimal { public int texture; public EntityDeer(World world) { super(world); texture = this.worldObj.rand.nextInt(2); this.setSize(0.8F, 1.0F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); this.tasks.addTask(3, new EntityAITempt(this, 1.2D, Items.wheat, false)); this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, Byte.valueOf((byte)0)); } public boolean isAIEnabled() { return true; } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); } public EntityDeer createChild(EntityAgeable entity) { return new EntityDeer(this.worldObj); } public boolean isBreedingItem(ItemStack breed) { return breed != null && breed.getItem() == Items.wheat; } public void writeEntityToNBT (NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setInteger("DeerType", this.getSkin()); } public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); this.setSkin(tag.getInteger("DeerType")); } public int getSkin() { return this.dataWatcher.getWatchableObjectByte(18); } public void setSkin(int skin) { this.dataWatcher.updateObject(18, Byte.valueOf((byte)skin)); } }Les 4 dernières fonctions et la “protected void entityInit” viennent de l’EntityOcelot
-
this.dataWatcher.addObject(18, Byte.valueOf((byte)0));
->
this.dataWatcher.addObject(18, Byte.valueOf((byte)texture));et dans la fonction getEntityDeerTextures du rendu remplaces entity.texture par entity.getSkin()
-
Je viens d’essayer ça mais il n’y a plus de texture random (les animaux adultes sont tous les mêmes) quand je remplace entity.texture par entity.getSkin()
-
Tu as aussi changé la ligne avec le data watcher ?
-
Si c’est de celle-ci (this.dataWatcher.addObject(18, Byte.valueOf((byte)texture));) dont tu parle, alors oui je l’ai aussi changé
-
Ajoutes des System.out.println(texture) / System.out.println(entity.getSkin()) dans le constructeur de la classe de ton entité et dans le code du rendu et envoies les logs.
-
Je dois les coller où exactement dans la class Render? Et dans le constructeur il y a une erreur avec le ‘entity’, je laisse comme ça et je lance minecraft?
J’envoie les logs client et serveur? -
Dans la fonction getEntityDeerTextures
Envoies simplement ce qu’il y a dans la console d’eclipse.
-
Voici donc le log quand je lance minecraft
[16:33:31] [main/INFO] [GradleStart]: username: Valina02 [16:33:31] [main/INFO] [GradleStart]: Extra: [] [16:33:31] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/Valentine 02/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --username, Valina02, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [16:33:31] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [16:33:31] [main/INFO] [FML]: Forge Mod Loader version 7.99.40.1614 for Minecraft 1.7.10 loading [16:33:31] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_91, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jre1.8.0_91 [16:33:31] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [16:33:31] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [16:33:31] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin [16:33:31] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [16:33:31] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:33:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [16:33:32] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [16:33:34] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [16:33:34] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [16:33:34] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [16:33:34] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [16:33:34] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker [16:33:34] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker [16:33:34] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [16:33:35] [main/INFO]: Setting user: Valina02 [16:33:37] [Client thread/INFO]: LWJGL Version: 2.9.1 [16:33:38] [Client thread/INFO] [STDOUT]: [cpw.mods.fml.client.SplashProgress:start:188]: –-- Minecraft Crash Report ---- // You're mean. Time: 7/07/16 16:33 Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.8.0_91, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 748054104 bytes (713 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.3.0' Renderer: 'GeForce GT 620/PCIe/SSE2' [16:33:38] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [16:33:38] [Client thread/INFO] [FML]: MinecraftForge v10.13.4.1614 Initialized [16:33:38] [Client thread/INFO] [FML]: Replaced 183 ore recipies [16:33:39] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [16:33:39] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [16:33:39] [Client thread/INFO] [FML]: Searching C:\Users\Valentine 02\Documents\Minecraft\Modding\FORGE\forge-1.7.10\eclipse\mods for mods [16:33:44] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [16:33:45] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, animalia] at CLIENT [16:33:45] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, animalia] at SERVER [16:33:45] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Animalia [16:33:45] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [16:33:45] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations [16:33:45] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations [16:33:45] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations [16:33:45] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [16:33:45] [Client thread/INFO] [FML]: Applying holder lookups [16:33:45] [Client thread/INFO] [FML]: Holder lookups applied [16:33:45] [Client thread/INFO] [FML]: Injecting itemstacks [16:33:45] [Client thread/INFO] [FML]: Itemstack injection complete [16:33:45] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:45] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem… [16:33:45] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL [16:33:45] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [16:33:46] [Thread-8/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized. [16:33:46] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:46] [Sound Library Loader/INFO]: Sound engine started [16:33:48] [Client thread/INFO]: Created: 16x16 textures/blocks-atlas [16:33:48] [Client thread/INFO]: Created: 16x16 textures/items-atlas [16:33:48] [Client thread/INFO] [FML]: Injecting itemstacks [16:33:48] [Client thread/INFO] [FML]: Itemstack injection complete [16:33:48] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [16:33:48] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Animalia [16:33:48] [Client thread/INFO]: Created: 512x256 textures/blocks-atlas [16:33:48] [Client thread/INFO]: Created: 256x256 textures/items-atlas [16:33:48] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:48] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: SoundSystem shutting down… [16:33:48] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:importantMessage:90]: Author: Paul Lamb, www.paulscode.com [16:33:48] [Client thread/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:48] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:48] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem… [16:33:49] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL [16:33:49] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [16:33:49] [Thread-10/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized. [16:33:49] [Sound Library Loader/INFO] [STDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [16:33:49] [Sound Library Loader/INFO]: Sound engine started -
Charges un monde où se trouve l’entité, sinon ça ne sert à rien x)