Un soucie pour des sacs à dos



  • Bonjour j'ais voulue réaliser le tutoriel de Scarex sur les backpack : https://www.minecraftforgefrance.fr/showthread.php?tid=2197

    Le tutoriel est trés bien expliqué mais j'ais un crash qui dois venir je pense de mon @Instance mais je ne suis pas sur.

    Le rapport de crash :

    [18:48:24] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
    // You're mean.
    
    Time: 04/09/16 18:48
    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.extazilia.extaziliamod.common.sac.ItemBackPack.onItemRightClick(ItemBackPack.java:36)
    at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164)
    at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557)
    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)
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Stacktrace:
    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.extazilia.extaziliamod.common.sac.ItemBackPack.onItemRightClick(ItemBackPack.java:36)
    at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164)
    at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557)
    
    -- Affected level --
    Details:
    Level name: MpServer
    All players: 1 total; [EntityClientPlayerMP['Player653'/294, l='MpServer', x=-88,17, y=79,62, z=247,02]]
    Chunk stats: MultiplayerChunkCache: 623, 623
    Level seed: 0
    Level generator: ID 00 - default, ver 1\. Features enabled: false
    Level generator options:
    Level spawn location: World: (-148,64,256), Chunk: (at 12,4,0 in -10,16; contains blocks -160,0,256 to -145,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 32654 game time, 32654 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 80 total; [EntityZombie['Zombie'/2568, l='MpServer', x=-159,50, y=22,00, z=175,50], EntityZombie['Zombie'/5903, l='MpServer', x=-117,50, y=59,00, z=222,50], EntityZombie['Zombie'/5904, l='MpServer', x=-117,50, y=59,00, z=223,50], EntityCreeper['Creeper'/4377, l='MpServer', x=-165,50, y=23,00, z=213,50], EntityCreeper['Creeper'/4378, l='MpServer', x=-167,50, y=23,00, z=213,50], EntityZombie['Zombie'/6432, l='MpServer', x=-162,50, y=13,00, z=201,50], EntityCreeper['Creeper'/6439, l='MpServer', x=-16,50, y=33,00, z=322,50], EntityCreeper['Creeper'/6440, l='MpServer', x=-15,50, y=33,00, z=323,50], EntityZombie['Zombie'/6442, l='MpServer', x=-14,50, y=33,00, z=321,50], EntityZombie['Zombie'/4919, l='MpServer', x=-20,50, y=30,00, z=218,50], EntityZombie['Zombie'/6458, l='MpServer', x=-30,50, y=18,00, z=252,50], EntityZombie['Zombie'/5949, l='MpServer', x=-118,50, y=63,00, z=248,50], EntityZombie['Zombie'/5950, l='MpServer', x=-115,97, y=65,00, z=251,50], EntityCreeper['Creeper'/6720, l='MpServer', x=-99,50, y=12,00, z=178,50], EntityCreeper['Creeper'/5954, l='MpServer', x=-118,50, y=63,00, z=246,50], EntityClientPlayerMP['Player653'/294, l='MpServer', x=-88,17, y=79,62, z=247,02], EntityZombie['Zombie'/4943, l='MpServer', x=-111,50, y=59,00, z=224,50], EntitySkeleton['Skeleton'/6223, l='MpServer', x=-40,50, y=17,00, z=313,50], EntitySlime['Slime'/80, l='MpServer', x=-149,22, y=63,00, z=242,78], EntityCreeper['Creeper'/6224, l='MpServer', x=-38,50, y=17,00, z=312,50], EntityCreeper['Creeper'/6225, l='MpServer', x=-15,50, y=20,00, z=212,50], EntityWitch['Witch'/4443, l='MpServer', x=-105,50, y=17,00, z=171,50], EntityWitch['Witch'/4444, l='MpServer', x=-111,41, y=19,00, z=177,50], EntityBat['Bat'/4957, l='MpServer', x=-108,25, y=60,10, z=236,50], EntityBat['Bat'/4960, l='MpServer', x=-158,97, y=20,49, z=234,13], EntityBat['Bat'/102, l='MpServer', x=-108,25, y=60,10, z=236,25], EntityBat['Bat'/104, l='MpServer', x=-111,03, y=63,10, z=240,25], EntitySpider['Spider'/7016, l='MpServer', x=-159,50, y=14,00, z=208,50], EntityZombie['Zombie'/7017, l='MpServer', x=-160,50, y=14,00, z=200,50], EntityBat['Bat'/106, l='MpServer', x=-100,94, y=59,10, z=236,69], EntitySpider['Spider'/107, l='MpServer', x=-106,93, y=77,00, z=255,45], EntityCreeper['Creeper'/110, l='MpServer', x=-92,31, y=73,00, z=247,63], EntitySheep['Sheep'/111, l='MpServer', x=-95,72, y=71,00, z=283,78], EntityZombie['Zombie'/5494, l='MpServer', x=-12,50, y=17,00, z=220,50], EntitySheep['Sheep'/137, l='MpServer', x=-67,19, y=69,00, z=289,81], EntitySheep['Sheep'/143, l='MpServer', x=-73,16, y=63,00, z=327,88], EntitySheep['Sheep'/148, l='MpServer', x=-68,03, y=64,00, z=325,94], EntitySheep['Sheep'/149, l='MpServer', x=-66,16, y=65,00, z=321,94], EntityBat['Bat'/4760, l='MpServer', x=-39,25, y=28,10, z=302,25], EntityBat['Bat'/4509, l='MpServer', x=-21,75, y=20,10, z=241,25], EntitySheep['Sheep'/164, l='MpServer', x=-54,78, y=70,00, z=242,38], EntityPig['Pig'/165, l='MpServer', x=-46,03, y=70,00, z=250,94], EntitySheep['Sheep'/166, l='MpServer', x=-58,84, y=67,00, z=272,13], EntitySheep['Sheep'/167, l='MpServer', x=-60,16, y=68,00, z=286,16], EntitySheep['Sheep'/172, l='MpServer', x=-59,06, y=66,00, z=313,97], EntitySheep['Sheep'/175, l='MpServer', x=-37,22, y=70,00, z=187,47], EntityPig['Pig'/176, l='MpServer', x=-40,81, y=69,00, z=222,63], EntitySheep['Sheep'/177, l='MpServer', x=-36,81, y=75,00, z=241,50], EntityPig['Pig'/178, l='MpServer', x=-42,53, y=68,00, z=230,28], EntitySheep['Sheep'/179, l='MpServer', x=-38,81, y=70,00, z=245,09], EntityPig['Pig'/180, l='MpServer', x=-29,91, y=70,00, z=239,16], EntitySheep['Sheep'/181, l='MpServer', x=-40,75, y=64,00, z=269,19], EntitySheep['Sheep'/184, l='MpServer', x=-37,13, y=65,00, z=279,16], EntitySheep['Sheep'/185, l='MpServer', x=-32,13, y=65,00, z=280,19], EntitySheep['Sheep'/186, l='MpServer', x=-35,09, y=65,00, z=282,06], EntitySheep['Sheep'/187, l='MpServer', x=-37,88, y=67,00, z=286,84], EntityCreeper['Creeper'/4797, l='MpServer', x=-113,50, y=58,00, z=222,50], EntityZombie['Zombie'/6333, l='MpServer', x=-107,50, y=18,00, z=176,50], EntityZombie['Zombie'/6334, l='MpServer', x=-106,50, y=18,00, z=174,50], EntityZombie['Zombie'/6335, l='MpServer', x=-110,13, y=18,00, z=177,50], EntitySheep['Sheep'/192, l='MpServer', x=-38,47, y=70,00, z=293,53], EntitySheep['Sheep'/193, l='MpServer', x=-40,47, y=80,00, z=303,63], EntityBat['Bat'/5313, l='MpServer', x=-67,90, y=26,65, z=305,60], EntitySheep['Sheep'/194, l='MpServer', x=-24,88, y=69,00, z=186,94], EntitySheep['Sheep'/195, l='MpServer', x=-20,91, y=77,00, z=216,91], EntitySheep['Sheep'/196, l='MpServer', x=-26,34, y=74,00, z=240,56], EntitySheep['Sheep'/197, l='MpServer', x=-30,66, y=74,00, z=247,50], EntitySheep['Sheep'/199, l='MpServer', x=-27,78, y=68,00, z=265,53], EntityCow['Cow'/200, l='MpServer', x=-18,59, y=72,00, z=283,63], EntitySkeleton['Skeleton'/6090, l='MpServer', x=-167,16, y=23,00, z=170,50], EntityCow['Cow'/206, l='MpServer', x=-17,91, y=90,00, z=302,94], EntitySheep['Sheep'/215, l='MpServer', x=-14,41, y=76,00, z=215,84], EntityZombie['Zombie'/6359, l='MpServer', x=-87,50, y=30,00, z=328,50], EntitySheep['Sheep'/218, l='MpServer', x=-14,78, y=77,00, z=231,50], EntityCow['Cow'/223, l='MpServer', x=-12,81, y=81,00, z=279,44], EntitySkeleton['Skeleton'/2543, l='MpServer', x=-28,50, y=24,00, z=296,50], EntityCreeper['Creeper'/4336, l='MpServer', x=-128,50, y=65,00, z=239,50], EntitySkeleton['Skeleton'/5620, l='MpServer', x=-169,50, y=49,00, z=221,50], EntityCreeper['Creeper'/5622, l='MpServer', x=-123,50, y=58,00, z=213,50], EntityZombie['Zombie'/6909, l='MpServer', x=-163,50, y=54,00, z=285,50]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
    Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566)
    at net.minecraft.client.Minecraft.run(Minecraft.java:991)
    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)
    
    – System Details --
    Details:
    Minecraft Version: 1.7.10
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_101, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 667558592 bytes (636 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: 12, tallocated: 94
    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
    UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)
    UCHIJAAAA Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)
    UCHIJAAAA extaziliamod{1.3} [Extazilia Mod] (bin)
    GL info: ' Vendor: 'Intel' Version: '4.3.0 - Build 10.18.15.4248' Renderer: 'Intel(R) HD Graphics 4400'
    Launched Version: 1.7.10
    LWJGL: 2.9.1
    OpenGL: Intel(R) HD Graphics 4400 GL version 4.3.0 - Build 10.18.15.4248, Intel
    GL Caps: Using GL 1.3 multitexturing.
    Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
    Anisotropic filtering is supported and maximum anisotropy is 16.
    Shaders are available because OpenGL 2.1 is supported.
    
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: []
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Anisotropic Filtering: Off (1)
    [18:48:24] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\yves\Desktop\mod exta\forge\eclipse\.\crash-reports\crash-2016-09-04_18.48.24-client.txt
    

    La classe GuiBackPack :

    package fr.extazilia.extaziliamod.common.sac;
    
    import org.lwjgl.opengl.GL11;
    
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    
    public class GuiBackPack extends GuiContainer
    {
    public static final ResourceLocation texture = new ResourceLocation("textures/gui/container/generic_54.png");
    protected InventoryBackPack inv2;
    protected InventoryPlayer playerinv2;
    public int rows;
    
    public GuiBackPack(InventoryPlayer playerInv, InventoryBackPack inv) {
    
    super(new ContainerBackPack(playerInv, inv));
    this.playerinv2 = playerInv;
    this.inv2 = inv;
    this.allowUserInput = false;
    // Calculate the number of rows
    this.rows = inv.getSizeInventory() / 9;
    // Height of the GUI using the number of rows
    this.ySize = 114 + this.rows * 18;
    }
    
    @Override
    protected void drawGuiContainerForegroundLayer(int x, int y) {
    this.fontRendererObj.drawString(I18n.format(this.inv2.getInventoryName(), new Object[0]), 8, 6, 4210752);
    this.fontRendererObj.drawString(this.playerinv2.hasCustomInventoryName() ? this.playerinv2.getInventoryName() : I18n.format(this.playerinv2.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752);
    }
    
    @Override
    protected void drawGuiContainerBackgroundLayer(float prt, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(texture);
    
    // Centering GUI
    int k = (this.width - this.xSize) / 2;
    int l = (this.height - this.ySize) / 2;
    
    // Drawing the first part of the GUI (slots of the backpack)
    this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.rows * 18 + 17);
    // And after the slots from the player's inventory
    this.drawTexturedModalRect(k, l + this.rows * 18 + 17, 0, 126, this.xSize, 96);
    }
    }
    

    Et une partie de ma classe principal avec le @Instance :

    @Mod(modid = "extaziliamod" , name = "Extazilia Mod",version = "1.3" )
    
    public class Main {
    
    public static final String modid = "extaziliamod";
    public static SimpleNetworkWrapper network;
    
    @Instance("extaziliamod")
    public static Main instance;
    

  • Administrateurs

    Salut,
    Peux-tu envoyer le code de ton gui handler ?



  • @'robin4002':

    Salut,
    Peux-tu envoyer le code de ton gui handler ?

    Biensur mais je vois pas de quel classe il s'agit



  • @'robin4002':

    Salut,
    Peux-tu envoyer le code de ton gui handler ?

    package fr.extazilia.extaziliamod.proxy;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import cpw.mods.fml.common.network.IGuiHandler;
    import fr.extazilia.extaziliamod.common.sac.ContainerBackPack;
    import fr.extazilia.extaziliamod.common.sac.GuiBackPack;
    import fr.extazilia.extaziliamod.common.sac.InventoryBackPack;
    import fr.extazilia.extaziliamod.common.sac.ItemBackPack;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.world.World;
    
    public class CommonProxy implements IGuiHandler{
    private final static Map <string, nbttagcompound="">extendedEntityData = new HashMap<string, nbttagcompound="">();
    
    public void registerRender(){System.out.println("test serveur"); }
    
    public static void storeEntityData(String name, NBTTagCompound compound) {
    extendedEntityData.put(name, compound);
    }
    
    public static NBTTagCompound getEntityData(String name) {
    return extendedEntityData.remove(name);
    }
    
    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) {
    switch (ID) {
    case 0:
    // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54)
    // Condition to check if the player has the right item in hand
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)){ return null;}
    else{return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));}
    }
    return null;
    }
    
    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world,int x, int y, int z) {
    switch (ID) {
    case 0:
    // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54)
    // Condition to check if the player has the right item in hand
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) {return null;}
    else {return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));}
    }
    return null;
    }
    
    }
    ```</string,></string,>

  • Administrateurs

    Ton gui handler ne devrait pas être mélangé avec ton proxy.



  • C'est tout à fait possible si c'est bien fait


  • Administrateurs

    Oui mais c'est source d'erreur, donc vaut mieux éviter.
    S'il y a ré-implémenté les fonctions en mettant return null dans le client proxy, ça expliquerai le souci.

    Si ce n'est pas le cas, je pense que le gui handler est tout simplement pas enregistré.



  • @'robin4002':

    Ton gui handler ne devrait pas être mélangé avec ton proxy.

    Ah d'accord néanmoins cela crash encore, je pense que j'ais mal réalisé ma classe :

    package fr.extazilia.extaziliamod.proxy;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;
    import fr.extazilia.extaziliamod.common.sac.ContainerBackPack;
    import fr.extazilia.extaziliamod.common.sac.GuiBackPack;
    import fr.extazilia.extaziliamod.common.sac.InventoryBackPack;
    import fr.extazilia.extaziliamod.common.sac.ItemBackPack;
    
    public class GuiHandler implements IGuiHandler{
    
    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
    case 0:
    // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54)
    // Condition to check if the player has the right item in hand
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;
    return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));
    }
    return null;
    }
    
    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
    case 0:
    // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54)
    // Condition to check if the player has the right item in hand
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBackPack)) return null;
    return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54));
    }
    return null;
    }
    
    }
    
    


  • Où as-tu enregistré ton gui handler ?



  • @'SCAREX':

    Où as-tu enregistré ton gui handler ?

    Dans ma classe principal avec :

    MinecraftForge.EVENT_BUS.register(new GuiHandler());
    
    FMLCommonHandler.instance().bus().register(new GuiHandler());
    


  • Ceci ne vas pas l'enregistrer comme GuiHandler mais comme classe d'évents, normal que ça ne marche pas. Il faut faire NetworkRegistry.INSTANCE.registerGuiHandler(new GuiHandler());



  • Merci à tous