Résolu Mon Gui ne s'ouvre pas
-
Bonsoir,
Je vient de créer un block avec un gui sauf que au clique droit dessus rien ne se passe
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (world.isRemote){ FMLNetworkHandler.openGui(player, Main.instance, Main.guiIDIngotMasher, world, x, y, z); } return true; }
Voilà la ligne que j’apelle pour ouvrir mon gui
-
Déjà ton code pour ouvrir le gui ne doit pas être uniquement exécuté côté client, donc vire la condition. Puis file nous la classe du GuiHandler, et as-tu pensé à l’enregistrer dans ta classe principale ?
-
@‘Plaigon’:
Déjà ton code pour ouvrir le gui ne doit pas être uniquement exécuté côté client, donc vire la condition. Puis file nous la classe du GuiHandler, et as-tu pensé à l’enregistrer dans ta classe principale ?
Oui je les mis
package fr.darkvince.proxy; import cpw.mods.fml.common.network.IGuiHandler; import fr.darkvince.four.ContainerIngotMasher; import fr.darkvince.four.GuiIngotMasher; import fr.darkvince.four.TileEntityIngotMasher; import fr.darkvince.ultrav2.Main; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); if (entity != null) { switch (ID) { case Main.guiIDIngotMasher: if (entity instanceof TileEntityIngotMasher){ return new ContainerIngotMasher(player.inventory, (TileEntityIngotMasher)entity); } return null; } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); if (entity != null) { switch (ID) { case Main.guiIDIngotMasher: if (entity instanceof TileEntityIngotMasher){ return new GuiIngotMasher(player.inventory, (TileEntityIngotMasher)entity); } return null; } } return null; } }
-
@‘Plaigon’:
As-tu pensé à l’enregistrer dans ta classe principale ?
Il suffit que tu l’enregistres au mauvais moment et ça peut ne plus marcher, vérifies si c’est fait correctement.
-
Merci du conseil
darkvince37, est-ce bien enregistré dans ta méthode preInit ??
Sinon essaie de debug avec des println, pour voir si tout ton code est bien lu -
Slt, dans ta fonction onBlockActivated dans la class de ton block
remplace par çaif (world.isRemote) { return true; } else { player.openGui(Main.instance, id de ton gui, world, x, y, z); return true; }
et dans le gui handler:
@Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityDeTonBlock) { return new ClassDuContainer((TileEntityDeTonBlock)tile, player.inventory); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityDeTonBlock) { return new ClassDuGui((TileEntityDeTonBlock, player.inventory); } return null; }
-
Rassure moi tu as enregistré ton gui handler ?
-
Maintenant quand je fait clique droit dessus j’ai un crash qui donne cette ligne
player.openGui(Main.instance, 2, world, x, y, z);
et quand je le pose en multi sa me deco
-
Ça serait bien de nous envoyer un copier/coller du rapport de crash.
Mais si c’est sur cette ligne que ça crash je suppose que le crash est un npe et du-coup que ton instance est null
-
@‘robin4002’:
Ça serait bien de nous envoyer un copier/coller du rapport de crash.
Mais si c’est sur cette ligne que ça crash je suppose que le crash est un npe et du-coup que ton instance est null
–-- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 06/11/16 19:45 Description: Unexpected error java.lang.NullPointerException: Unexpected error at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at fr.darkvince.ultrav2.four.IngotMasher.onBlockActivated(IngotMasher.java:105) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) at net.minecraft.client.Minecraft.run(Minecraft.java:962) at net.minecraft.client.main.Main.main(Main.java:164) 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:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
Voilà mais c’est la ligne que j’ai signalé
-
Comme le souligne robin, ta variable instance est sûrement null. Pourrais-tu nous donner ta classe principale ?
-
package fr.darkvince.ultrav2; 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.NetworkRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import fr.darkvince.proxy.CommonProxy; import fr.darkvince.proxy.GuiHandler; import fr.darkvince.ultrav2.MineraiIridium.ArcIridium; import fr.darkvince.ultrav2.MineraiIridium.BlockMineraiIridium; import fr.darkvince.ultrav2.MineraiIridium.GemMineraiIridium; import fr.darkvince.ultrav2.MineraiIridium.IridiumArmor; import fr.darkvince.ultrav2.MineraiIridium.ItemIridiumAxe; import fr.darkvince.ultrav2.MineraiIridium.ItemIridiumHoe; import fr.darkvince.ultrav2.MineraiIridium.ItemIridiumPickaxe; import fr.darkvince.ultrav2.MineraiIridium.ItemIridiumShovel; import fr.darkvince.ultrav2.MineraiIridium.ItemIridiumSword; import fr.darkvince.ultrav2.MineraiIridium.MineraiIridium; import fr.darkvince.ultrav2.MineraiLinarite.ArcLinarite; import fr.darkvince.ultrav2.MineraiLinarite.BlockMineraiLinarite; import fr.darkvince.ultrav2.MineraiLinarite.GemMineraiLinarite; import fr.darkvince.ultrav2.MineraiLinarite.ItemLinariteAxe; import fr.darkvince.ultrav2.MineraiLinarite.ItemLinariteHoe; import fr.darkvince.ultrav2.MineraiLinarite.ItemLinaritePickaxe; import fr.darkvince.ultrav2.MineraiLinarite.ItemLinariteShovel; import fr.darkvince.ultrav2.MineraiLinarite.ItemLinariteSword; import fr.darkvince.ultrav2.MineraiLinarite.LinariteArmor; import fr.darkvince.ultrav2.MineraiLinarite.MineraiLinarite; import fr.darkvince.ultrav2.MineraiPlutonium.BlockMineraiPlutonium; import fr.darkvince.ultrav2.MineraiPlutonium.GemMineraiPlutonium; import fr.darkvince.ultrav2.MineraiPlutonium.MineraiPlutonium; import fr.darkvince.ultrav2.MineraiPyrite.ArcPyrite; import fr.darkvince.ultrav2.MineraiPyrite.BlockMineraiPyrite; import fr.darkvince.ultrav2.MineraiPyrite.GemMineraiPyrite; import fr.darkvince.ultrav2.MineraiPyrite.ItemPyriteAxe; import fr.darkvince.ultrav2.MineraiPyrite.ItemPyriteHoe; import fr.darkvince.ultrav2.MineraiPyrite.ItemPyritePickaxe; import fr.darkvince.ultrav2.MineraiPyrite.ItemPyriteShovel; import fr.darkvince.ultrav2.MineraiPyrite.ItemPyriteSword; import fr.darkvince.ultrav2.MineraiPyrite.MineraiPyrite; import fr.darkvince.ultrav2.MineraiPyrite.PyriteArmor; import fr.darkvince.ultrav2.autre.RenforcedStone; import fr.darkvince.ultrav2.autre.SandMove; import fr.darkvince.ultrav2.cassefauchon.CasseFauchon; import fr.darkvince.ultrav2.cassefauchon.KeyFauchon; import fr.darkvince.ultrav2.cassefauchon.Knife; import fr.darkvince.ultrav2.entity.EntityBateau; import fr.darkvince.ultrav2.four.IngotMasher; import fr.darkvince.ultrav2.obsi.Bateau; import fr.darkvince.ultrav2.pomme.PommeEmeraud; import fr.darkvince.ultrav2.pomme.PommeRenforced; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; import net.minecraftforge.common.ChestGenHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import fr.darkvince.ultrav2.pomme.PommeLinarite; @Mod(modid = "ultrav2", name = "Ultrafight V2", version = "1.0.0") public class Main { @Instance("ultrav2") public static Main instance; @SidedProxy(clientSide = "fr.darkvince.proxy.ClientProxy", serverSide = "fr.darkvince.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "ultrav2"; public static final String VERSION = "1.0"; WorldGeneration worldgeneration = new WorldGeneration(); //Minerai Linarite public static Block MineraiLinarite; public static Block BlockMineraiLinarite; public static Item GemMineraiLinarite; public static Item ArcLinarite; public static Item helmetLinarite, chestPlateLinarite, leggingsLinarite, bootsLinarite; public static ArmorMaterial armorLinarite = EnumHelper.addArmorMaterial("armorLinarite", 33, new int[] {3, 8, 6, 4}, 10); public static Item swordLinarite, pickaxeLinarite, axeLinarite, shovelLinarite, hoeLinarite; public static ToolMaterial toolLinarite = EnumHelper.addToolMaterial("toolLinarite", 3, 1854, 9.0F, 3.5F, 10); //Minerai Pyrite public static Block MineraiPyrite; public static Block BlockMineraiPyrite; public static Item GemMineraiPyrite; public static Item ArcPyrite; public static Item helmetPyrite, chestPlatePyrite, leggingsPyrite, bootsPyrite; public static ArmorMaterial armorPyrite = EnumHelper.addArmorMaterial("armorPyrite", 35, new int[] {3, 8, 7, 4}, 6); public static Item swordPyrite, pickaxePyrite, axePyrite, shovelPyrite, hoePyrite; public static ToolMaterial toolPyrite = EnumHelper.addToolMaterial("toolPyrite", 3, 2254, 9.5F, 4.0F, 6); //Minerai Iridium public static Block MineraiIridium; public static Block BlockMineraiIridium; public static Item GemMineraiIridium; public static Item ArcIridium; public static Item helmetIridium, chestPlateIridium, leggingsIridium, bootsIridium; public static ArmorMaterial armorIridium = EnumHelper.addArmorMaterial("armorIridium", 37, new int[] {4, 8, 7, 5}, 2); public static Item swordIridium, pickaxeIridium, axeIridium, shovelIridium, hoeIridium; public static ToolMaterial toolIridium = EnumHelper.addToolMaterial("toolIridium", 3, 3054, 10.0F, 5.0F, 2); //Minerai Plutonium public static Block MineraiPlutonium; public static Block BlockMineraiPlutonium; public static Item GemMineraiPlutonium; // Cases Fauchon public static Block CasseFauchon; //Key Fauchon public static Item KeyFauchon; public static Item dopplerkarambit; //Four public static Block blockIngotMasherIdle; public static Block blockIngotMasherActive; public static final int guiIDIngotMasher = 2; //autre public static Block RenforcedStone; public static Block SandMove; //obsi public static Item Bateau; //pomme public static Item PommeRenforced; public static Item PommeEmeraud; public static Item PommeLinarite; public static Item PommePyrite; public static Item PommeIridium; @EventHandler public void preInit(FMLPreInitializationEvent event) { //four blockIngotMasherIdle = new IngotMasher(false).setBlockName("IngotMasherIdle").setCreativeTab(CreativeTabs.tabBlock).setHardness(3.5F); blockIngotMasherActive = new IngotMasher(true).setBlockName("IngotMasherActive").setHardness(3.5F); GameRegistry.registerBlock(blockIngotMasherIdle, "IngotMasherIdle"); GameRegistry.registerBlock(blockIngotMasherActive, "IngotMasherActive"); //Minerai Linarite MineraiLinarite = new MineraiLinarite(Material.rock).setBlockName("MineraiLinarite").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:MineraiLinarite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(MineraiLinarite, "MineraiLinarite"); BlockMineraiLinarite = new BlockMineraiLinarite(Material.rock).setBlockName("BlockMineraiLinarite").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:BlockMineraiLinarite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(BlockMineraiLinarite, "BlockMineraiLinarite"); GemMineraiLinarite = new GemMineraiLinarite().setUnlocalizedName("GemMineraiLinarite").setTextureName("ultrav2:GemMineraiLinarite").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(GemMineraiLinarite, "GemMineraiLinarite"); helmetLinarite = new LinariteArmor(armorLinarite, 0).setUnlocalizedName("helmetLinarite").setTextureName(MODID + ":helmet_Linarite").setCreativeTab(CreativeTabs.tabBlock); chestPlateLinarite = new LinariteArmor(armorLinarite, 1).setUnlocalizedName("chestPlateLinarite").setTextureName(MODID + ":chestplate_Linarite").setCreativeTab(CreativeTabs.tabBlock); leggingsLinarite = new LinariteArmor(armorLinarite, 2).setUnlocalizedName("leggingsLinarite").setTextureName(MODID + ":leggings_Linarite").setCreativeTab(CreativeTabs.tabBlock); bootsLinarite = new LinariteArmor(armorLinarite, 3).setUnlocalizedName("bootsLinarite").setTextureName(MODID + ":boots_Linarite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(helmetLinarite, "helmetLinarite"); GameRegistry.registerItem(chestPlateLinarite, "chestPlateLinarite"); GameRegistry.registerItem(leggingsLinarite, "leggingsLinarite"); GameRegistry.registerItem(bootsLinarite, "bootsLinarite"); swordLinarite = new ItemLinariteSword(toolLinarite).setUnlocalizedName("swordLinarite").setTextureName(MODID + ":sword_Linarite"); pickaxeLinarite = new ItemLinaritePickaxe(toolLinarite).setUnlocalizedName("pickaxeLinarite").setTextureName(MODID + ":pickaxe_Linarite"); axeLinarite = new ItemLinariteAxe(toolLinarite).setUnlocalizedName("axeLinarite").setTextureName(MODID + ":axe_Linarite"); shovelLinarite = new ItemLinariteShovel(toolLinarite).setUnlocalizedName("shovelLinarite").setTextureName(MODID + ":shovel_Linarite"); hoeLinarite = new ItemLinariteHoe(toolLinarite).setUnlocalizedName("hoeLinarite").setTextureName(MODID + ":hoe_Linarite"); GameRegistry.registerItem(swordLinarite, "item_Linarite_sword"); GameRegistry.registerItem(pickaxeLinarite, "item_Linarite_pickaxe"); GameRegistry.registerItem(axeLinarite, "item_Linarite_axe"); GameRegistry.registerItem(shovelLinarite, "item_Linarite_shovel"); GameRegistry.registerItem(hoeLinarite, "item_Linarite_hoe"); ArcLinarite = new ArcLinarite().setUnlocalizedName("ArcLinarite").setTextureName("ultra:ArcLinarite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(ArcLinarite, "ArcLinarite"); //Minerai Pyrite MineraiPyrite = new MineraiPyrite(Material.rock).setBlockName("MineraiPyrite").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:MineraiPyrite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(MineraiPyrite, "MineraiPyrite"); BlockMineraiPyrite = new BlockMineraiPyrite(Material.rock).setBlockName("BlockMineraiPyrite").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:BlockMineraiPyrite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(BlockMineraiPyrite, "BlockMineraiPyrite"); GemMineraiPyrite = new GemMineraiPyrite().setUnlocalizedName("GemMineraiPyrite").setTextureName("ultrav2:GemMineraiPyrite").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(GemMineraiPyrite, "GemMineraiPyrite"); helmetPyrite = new PyriteArmor(armorPyrite, 0).setUnlocalizedName("helmetPyrite").setTextureName(MODID + ":helmet_Pyrite").setCreativeTab(CreativeTabs.tabBlock); chestPlatePyrite = new PyriteArmor(armorPyrite, 1).setUnlocalizedName("chestPlatePyrite").setTextureName(MODID + ":chestplate_Pyrite").setCreativeTab(CreativeTabs.tabBlock); leggingsPyrite = new PyriteArmor(armorPyrite, 2).setUnlocalizedName("leggingsPyrite").setTextureName(MODID + ":leggings_Pyrite").setCreativeTab(CreativeTabs.tabBlock); bootsPyrite = new PyriteArmor(armorPyrite, 3).setUnlocalizedName("bootsPyrite").setTextureName(MODID + ":boots_Pyrite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(helmetPyrite, "helmetPyrite"); GameRegistry.registerItem(chestPlatePyrite, "chestPlatePyrite"); GameRegistry.registerItem(leggingsPyrite, "leggingsPyrite"); GameRegistry.registerItem(bootsPyrite, "bootsPyrite"); swordPyrite = new ItemPyriteSword(toolPyrite).setUnlocalizedName("swordPyrite").setTextureName(MODID + ":sword_Pyrite"); pickaxePyrite = new ItemPyritePickaxe(toolPyrite).setUnlocalizedName("pickaxePyrite").setTextureName(MODID + ":pickaxe_Pyrite"); axePyrite = new ItemPyriteAxe(toolPyrite).setUnlocalizedName("axePyrite").setTextureName(MODID + ":axe_Pyrite"); shovelPyrite = new ItemPyriteShovel(toolPyrite).setUnlocalizedName("shovelPyrite").setTextureName(MODID + ":shovel_Pyrite"); hoePyrite = new ItemPyriteHoe(toolPyrite).setUnlocalizedName("hoeLinarite").setTextureName(MODID + ":hoe_Pyrite"); GameRegistry.registerItem(swordPyrite, "item_Pyrite_sword"); GameRegistry.registerItem(pickaxePyrite, "item_Pyrite_pickaxe"); GameRegistry.registerItem(axePyrite, "item_Pyrite_axe"); GameRegistry.registerItem(shovelPyrite, "item_Pyrite_shovel"); GameRegistry.registerItem(hoePyrite, "item_Pyrite_hoe"); ArcPyrite = new ArcPyrite().setUnlocalizedName("ArcPyrite").setTextureName("ultra:ArcPyrite").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(ArcPyrite, "ArcPyrite"); //Minerai Iridium MineraiIridium = new MineraiIridium(Material.rock).setBlockName("MineraiIridium").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:MineraiIridium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(MineraiIridium, "MineraiIridium"); BlockMineraiIridium = new BlockMineraiIridium(Material.rock).setBlockName("BlockMineraiIridium").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:BlockMineraiIridium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(BlockMineraiIridium, "BlockMineraiIridium"); GemMineraiIridium = new GemMineraiIridium().setUnlocalizedName("GemMineraiIridium").setTextureName("ultrav2:GemMineraiIridium").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(GemMineraiIridium, "GemMineraiIridium"); helmetIridium = new IridiumArmor(armorIridium, 0).setUnlocalizedName("helmetIridium").setTextureName(MODID + ":helmet_Iridium").setCreativeTab(CreativeTabs.tabBlock); chestPlateIridium = new IridiumArmor(armorIridium, 1).setUnlocalizedName("chestPlateIridium").setTextureName(MODID + ":chestplate_Iridium").setCreativeTab(CreativeTabs.tabBlock); leggingsIridium = new IridiumArmor(armorIridium, 2).setUnlocalizedName("leggingsIridium").setTextureName(MODID + ":leggings_Iridium").setCreativeTab(CreativeTabs.tabBlock); bootsIridium = new IridiumArmor(armorIridium, 3).setUnlocalizedName("bootsIridium").setTextureName(MODID + ":boots_Iridium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(helmetIridium, "helmetIridium"); GameRegistry.registerItem(chestPlateIridium, "chestPlateIridium"); GameRegistry.registerItem(leggingsIridium, "leggingsIridium"); GameRegistry.registerItem(bootsIridium, "bootsIridium"); swordIridium = new ItemIridiumSword(toolIridium).setUnlocalizedName("swordIridium").setTextureName(MODID + ":sword_Iridium"); pickaxeIridium = new ItemIridiumPickaxe(toolIridium).setUnlocalizedName("pickaxeIridium").setTextureName(MODID + ":pickaxe_Iridium"); axeIridium = new ItemIridiumAxe(toolIridium).setUnlocalizedName("axeIridium").setTextureName(MODID + ":axe_Iridium"); shovelIridium = new ItemIridiumShovel(toolIridium).setUnlocalizedName("shovelIridium").setTextureName(MODID + ":shovel_Iridium"); hoeIridium = new ItemIridiumHoe(toolIridium).setUnlocalizedName("hoeLinarite").setTextureName(MODID + ":hoe_Iridium"); GameRegistry.registerItem(swordIridium, "item_Iridium_sword"); GameRegistry.registerItem(pickaxeIridium, "item_Iridium_pickaxe"); GameRegistry.registerItem(axeIridium, "item_Iridium_axe"); GameRegistry.registerItem(shovelIridium, "item_Iridium_shovel"); GameRegistry.registerItem(hoeIridium, "item_Iridium_hoe"); ArcIridium = new ArcIridium().setUnlocalizedName("ArcIridium").setTextureName("ultra:ArcIridium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(ArcIridium, "ArcIridium"); //Minerai Plutonium MineraiPlutonium = new MineraiPlutonium(Material.rock).setBlockName("MineraiPlutonium").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:MineraiPlutonium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(MineraiPlutonium, "MineraiPlutonium"); BlockMineraiPlutonium = new BlockMineraiPlutonium(Material.rock).setBlockName("BlockMineraiPlutonium").setHardness(1.5F).setResistance(10.0F).setBlockTextureName("ultrav2:BlockMineraiPlutonium").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(BlockMineraiPlutonium, "BlockMineraiPlutonium"); GemMineraiPlutonium = new GemMineraiPlutonium().setUnlocalizedName("GemMineraiPlutonium").setTextureName("ultrav2:GemMineraiPlutonium").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(GemMineraiPlutonium, "GemMineraiPlutonium"); //Cases Fauchon CasseFauchon = new CasseFauchon(Material.rock).setBlockName("CasseFauchon").setBlockTextureName("ultrav2:CasseFauchon").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(CasseFauchon, "CasseFauchon"); dopplerkarambit = new Knife().setUnlocalizedName("dopplerkarambit").setTextureName(MODID + ":dopplerkarambit").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(dopplerkarambit, "dopplerkarambit"); //Key KeyFauchon = new KeyFauchon().setUnlocalizedName("KeyFauchon").setTextureName("ultrav2:KeyFauchon").setCreativeTab(CreativeTabs.tabMaterials); GameRegistry.registerItem(KeyFauchon, "KeyFauchon"); //autre RenforcedStone = new RenforcedStone(Material.rock).setBlockName("RenforcedStone").setHardness(10.0F).setResistance(25.0F).setBlockTextureName("ultrav2:RenforcedStone").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(RenforcedStone, "RenforcedStone"); SandMove = new SandMove(Material.sand).setBlockName("SandMove").setHardness(1.0F).setResistance(1.0F).setBlockTextureName("ultrav2:SandMove").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerBlock(SandMove, "SandMove"); //Obsi Bateau = new Bateau().setUnlocalizedName("Bateau").setTextureName("ultra:Bateau").setCreativeTab(CreativeTabs.tabBlock); GameRegistry.registerItem(Bateau, "Bateau"); EntityRegistry.registerModEntity(EntityBateau.class, "Bateau", 8, this, 64, 20, true); //Pomme PommeRenforced = ((ItemFood) new PommeRenforced(1, 4, 1.5F, true).setUnlocalizedName("PommeRenforced")).setAlwaysEdible().setTextureName("ultrav2:PommeRenforced"); GameRegistry.registerItem(PommeRenforced, "PommeRenforced", "ultrav2"); PommeEmeraud = ((ItemFood) new PommeEmeraud(2, 4, 1.5F, true).setUnlocalizedName("PommeEmeraud")).setAlwaysEdible().setTextureName("ultrav2:PommeEmeraud"); GameRegistry.registerItem(PommeEmeraud, "PommeEmeraud", "ultrav2"); PommeLinarite = ((ItemFood) new PommeLinarite(3, 4, 1.5F, true).setUnlocalizedName("PommeLinarite")).setAlwaysEdible().setTextureName("ultrav2:PommeLinarite"); GameRegistry.registerItem(PommeLinarite, "PommeLinarite", "ultrav2"); //Génération GameRegistry.registerWorldGenerator(worldgeneration, 0); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); MinecraftForge.EVENT_BUS.register(new PlayerEventHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); ChestGenHooks.getInfo("dungeonChest").addItem(new WeightedRandomChestContent(new ItemStack(KeyFauchon), 1, 1, 5)); ChestGenHooks.getInfo("dungeonChest").addItem(new WeightedRandomChestContent(new ItemStack(CasseFauchon), 1, 1, 5)); ChestGenHooks.getInfo("villageBlacksmith").addItem(new WeightedRandomChestContent(new ItemStack(KeyFauchon), 1, 1, 5)); ChestGenHooks.getInfo("villageBlacksmith").addItem(new WeightedRandomChestContent(new ItemStack(CasseFauchon), 1, 1, 5)); ChestGenHooks.getInfo("mineshaftCorridor").addItem(new WeightedRandomChestContent(new ItemStack(KeyFauchon), 1, 1, 5)); ChestGenHooks.getInfo("mineshaftCorridor").addItem(new WeightedRandomChestContent(new ItemStack(CasseFauchon), 1, 1, 5)); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
-
Bizarre…Essaie de Main.instance, au dessus du .openGui(), pour voir si il n’est pas null.
Essaie également d’enregistrer ton GuiHandler, plutôt dans la méthode preInit() que init(), sait-on jamais… -
@‘Plaigon’:
Bizarre…Essaie de Main.instance, au dessus du .openGui(), pour voir si il n’est pas null.
Essaie également d’enregistrer ton GuiHandler, plutôt dans la méthode preInit() que init(), sait-on jamais…Merci sa marche en mettent l’instance avec le opengui
parcontre il crash toujours quand je le pose en multi
-
Envoies le rapport de crash.
Ça ne sert à rien de dire “ça crash” sans envoyer le rapport … -
@‘robin4002’:
Envoies le rapport de crash.
Ça ne sert à rien de dire “ça crash” sans envoyer le rapport …Aucun crash rapport
java.lang.RuntimeException: class fr.darkvince.ultrav2.four.TileEntityIngotMasher is missing a mapping! This is a bug! at net.minecraft.tileentity.TileEntity.func_145841_b(TileEntity.java:84) ~[aor.class:?] at fr.darkvince.ultrav2.four.TileEntityIngotMasher.func_145841_b(TileEntityIngotMasher.java:144) ~[TileEntityIngotMasher.class:?] at org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState.<init>(CraftBlockState.java:49) ~[CraftBlockState.class:1.7.10-R0.1-SNAPSHOT] at org.bukkit.craftbukkit.v1_7_R4.block.CraftBlockState.getBlockState(CraftBlockState.java:87) ~[CraftBlockState.class:1.7.10-R0.1-SNAPSHOT] at net.minecraftforge.event.world.BlockEvent$PlaceEvent.<init>(BlockEvent.java:150) ~[BlockEvent$PlaceEvent.class:1.7.10-R0.1-SNAPSHOT] at net.minecraftforge.event.world.BlockEvent$MultiPlaceEvent.<init>(BlockEvent.java:178) ~[BlockEvent$MultiPlaceEvent.class:1.7.10-R0.1-SNAPSHOT] at net.minecraftforge.event.ForgeEventFactory.onPlayerMultiBlockPlace(ForgeEventFactory.java:59) ~[ForgeEventFactory.class:1.7.10-R0.1-SNAPSHOT] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:593) ~[ForgeHooks.class:1.7.10-R0.1-SNAPSHOT] at net.minecraft.item.ItemStack.func_77943_a(ItemStack.java:152) ~[add.class:?] at net.minecraft.server.management.ItemInWorldManager.func_73078_a(ItemInWorldManager.java:495) ~[mx.class:?] at net.minecraft.network.NetHandlerPlayServer.func_147346_a(NetHandlerPlayServer.java:853) ~[nh.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:60) ~[jo.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.func_148833_a(SourceFile:9) ~[jo.class:?] at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:245) ~[ej.class:?] at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:173) [nc.class:?] at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:991) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:431) [lt.class:?] at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:809) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:669) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] [10:37:54] [Server thread/INFO]: darkvince_ lost connection: Internal server error [10:37:54] [Server thread/INFO]: darkvince_ a quitté UltraFight
Voilà dans la console
Ligne 144
public void writeToNBT(NBTTagCompound nbt) { // 144 super.writeToNBT(nbt); nbt.setShort("PowerTime", (short)this.dualPower); nbt.setShort("CookTime", (short)this.dualCookTime); NBTTagList list = new NBTTagList(); for (int i = 0; i < this.slots.length; i++) { if (this.slots* != null) { NBTTagCompound nbt1 = new NBTTagCompound(); nbt1.setByte("Slot", (byte)i); this.slots*.writeToNBT(nbt1); list.appendTag(nbt1); } } nbt.setTag("Items", list); } ```</init></init></init>
-
Ton tile entity n’est pas enregistré …
-
@‘robin4002’:
Ton tile entity n’est pas enregistré …
J’avais oublié j’ai fait comme sa
GameRegistry.registerTileEntity(TileEntityIngotMasher.class, "blockIngotMasherIdle");
Mais sa marche pas
-
Tu as mit cette ligne où ?
Dans ta classe principale et dans la fonction init ? -
@‘robin4002’:
Tu as mit cette ligne où ?
Dans ta classe principale et dans la fonction init ?blockIngotMasherIdle = new IngotMasher(false).setBlockName("IngotMasherIdle").setCreativeTab(CreativeTabs.tabBlock).setHardness(3.5F); blockIngotMasherActive = new IngotMasher(true).setBlockName("IngotMasherActive").setHardness(3.5F); GameRegistry.registerTileEntity(TileEntityIngotMasher.class, "blockIngotMasherIdle"); GameRegistry.registerBlock(blockIngotMasherIdle, "IngotMasherIdle"); GameRegistry.registerBlock(blockIngotMasherActive, "IngotMasherActive");
Edit:
J’ai modifié mon code sa marche, mais le problème c’est que y a pas l’animation de mon Gui
package fr.darkvince.ultrav2.four; import org.lwjgl.opengl.GL11; import fr.darkvince.ultrav2.Main; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.util.ResourceLocation; public class GuiIngotMasher extends GuiContainer{ private static final ResourceLocation texture = new ResourceLocation("ultrav2:textures/gui/IngotMasherGui.png"); public TileEntityIngotMasher ingotMasher; public GuiIngotMasher(InventoryPlayer invPlayer, TileEntityIngotMasher teIngotMasher) { super(new ContainerIngotMasher(invPlayer, teIngotMasher)); this.ingotMasher = teIngotMasher; this.xSize = 176; this.ySize = 166; } protected void func_146979_b(int i, int j) { String name = this.ingotMasher.isInventoryNameLocalized() ? this.ingotMasher.getInventoryName() : I18n.format(this.ingotMasher.getInventoryName(), new Object[0]); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 5, 4210752); } protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); if (this.ingotMasher.hasPower()) { int i1 = this.ingotMasher.getPowerRemainingScaled(45); drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 53 - i1, 176, 89 - i1, 44, i1); } int j1 = this.ingotMasher.getMasherProgressScaled(44); drawTexturedModalRect(this.guiLeft + 63, this.guiTop + 19, 176, 0, j1 + 1, 44); } }