Nom d'item en plusieurs morceau.
-
Si tu utilises getLocalizedName tu n’as plus besoin de getUnlocalizedName.
Envoies ton code.
-
:::
package com.mod.infiniNature.RandomCreate; import java.util.Random; public class Flower { public static String RanFlowName1() { Random rand = new Random(); int RandNumb = rand.nextInt(3); if(RandNumb==0){return "Reni";} else if(RandNumb==1){return "Peni";} else if(RandNumb==2){return "Cali";} else if(RandNumb==3){return "Roni";} else{return "Erro";} } public static String RanFlowName2() { Random rand = new Random(); int RandNumb = rand.nextInt(3); if(RandNumb==0){return "pelu";} else if(RandNumb==1){return "calo";} else if(RandNumb==2){return "tina";} else if(RandNumb==3){return "galu";} else{return "Erro";} } public static String RanFlowName3() { Random rand = new Random(); int RandNumb = rand.nextInt(3); if(RandNumb==0){return "cilius";} else if(RandNumb==1){return "anilis";} else if(RandNumb==2){return "parni";} else if(RandNumb==3){return "dophelius";} else{return "Erro";} } }:::
:::package com.mod.infiniNature.init; import com.mod.infiniNature.Block.BlockFlowerMod; import com.mod.infiniNature.RandomCreate.Flower; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; public class BlockInit { public static Block flower1; public static Block flower2; public static void init() { flower1 = new BlockFlowerMod(1, Flower.RanFlowName1() , Flower.RanFlowName2(), Flower.RanFlowName3()); GameRegistry.registerBlock(flower1, "flower1"); flower2 = new BlockFlowerMod(1, Flower.RanFlowName1() , Flower.RanFlowName2(), Flower.RanFlowName3()); GameRegistry.registerBlock(flower2, "flower2"); } }:::
:::package com.mod.infiniNature.Block; import com.mod.infiniNature.RandomCreate.Flower; import com.mod.infiniNature.init.BlockInit; import net.minecraft.block.BlockFlower; import net.minecraft.init.Items; import net.minecraft.util.StatCollector; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class BlockFlowerMod extends BlockFlower { public BlockFlowerMod(int p_i2173_1_,String nam1,String nam2,String nam3) { super(p_i2173_1_); } }:::
Ducoup je sais pas comment faire pour mettre get-Localized/Unlocalized-Name dans la méthode du block.
-
package com.mod.infiniNature.Block; import com.mod.infiniNature.RandomCreate.Flower; import com.mod.infiniNature.init.BlockInit; import net.minecraft.block.BlockFlower; import net.minecraft.init.Items; import net.minecraft.util.StatCollector; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class BlockFlowerMod extends BlockFlower { private final String name1, name2, name3 public BlockFlowerMod(int p_i2173_1_, String name1,String name2,String name3) { super(p_i2173_1_); this.name1 = name1; this.name2 = name2; this.name3 = name3; } public String getLocalizedName() { return this.name1 + this.name2 + this.name3; } } -
@‘robin4002’:
package com.mod.infiniNature.Block; import com.mod.infiniNature.RandomCreate.Flower; import com.mod.infiniNature.init.BlockInit; import net.minecraft.block.BlockFlower; import net.minecraft.init.Items; import net.minecraft.util.StatCollector; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class BlockFlowerMod extends BlockFlower { private final String name1, name2, name3 public BlockFlowerMod(int p_i2173_1_, String name1,String name2,String name3) { super(p_i2173_1_); this.name1 = name1; this.name2 = name2; this.name3 = name3; } public String getLocalizedName() { return this.name1 + this.name2 + this.name3; } }Merci pour le code !;)
Tu as réglé un problème mais le getLocalizedName ne marche toujours pas.
-
Tu code en quelle version ?
-
@‘robin4002’:
Tu code en quelle version ?
En 1.7.10
-
Personne?

-
C’est 24h qu’il faut attendre avant d’up, on est pas présent 24h/24h sur le forum … Donc n’est normal de ne pas forcement avoir une réponse au bout de 2h.
Le nom de la fonction est identique en 1.7.10, donc ça coince à un autre endroit.
Et visiblement le soucis vient du fait que cette fonction n’est pas utilisé pour le nom du bloc en main.Dans la classe ItemBlock il y a ça :
public String getUnlocalizedName(ItemStack p_77667_1_) { return this.field_150939_a.getUnlocalizedName(); } public String getUnlocalizedName() { return this.field_150939_a.getUnlocalizedName(); }field_150939_a est l’instance du bloc associé à l’item.
Et dans la classe item il y a ça :
public String getItemStackDisplayName(ItemStack p_77653_1_) { return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(p_77653_1_) + ".name")).trim(); }Donc il faudrait ajouter un ItemBlock custom à ton bloc et mettre cette fonction dans l’item bloc :
public String getItemStackDisplayName(ItemStack stack) { return this.name1 + this.name2 + this.name3; } -
@‘robin4002’:
C’est 24h qu’il faut attendre avant d’up, on est pas présent 24h/24h sur le forum … Donc n’est normal de ne pas forcement avoir une réponse au bout de 2h.
Le nom de la fonction est identique en 1.7.10, donc ça coince à un autre endroit.
Et visiblement le soucis vient du fait que cette fonction n’est pas utilisé pour le nom du bloc en main.Dans la classe ItemBlock il y a ça :
public String getUnlocalizedName(ItemStack p_77667_1_) { return this.field_150939_a.getUnlocalizedName(); } public String getUnlocalizedName() { return this.field_150939_a.getUnlocalizedName(); }field_150939_a est l’instance du bloc associé à l’item.
Et dans la classe item il y a ça :
public String getItemStackDisplayName(ItemStack p_77653_1_) { return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(p_77653_1_) + ".name")).trim(); }Donc il faudrait ajouter un ItemBlock custom à ton bloc et mettre cette fonction dans l’item bloc :
public String getItemStackDisplayName(ItemStack stack) { return this.name1 + this.name2 + this.name3; }MAis ducoup,comment est-ce qu’on crée un ItemBlock?
-
C’est expliqué dans ce tutoriel : https://www.minecraftforgefrance.fr/showthread.php?tid=743