Gui et ExtendedEntityProperties



  • Bonjour,
    J'ai créé hier une propriété d'argent avec ce tuto ExtendedEntityProperties. Donc aujourd'hui j'ai voulu obtenir la valeur de l'argent dans un gui. Sauf qu'après avoir lancé minecraft et ouverts le gui le client a crash. Je ne pense pas que le problème viens directement de quand je récupère la valeur en String puisque j'utilise ```java
    String.valueOf(imoney.getMoney())

    ```java
    ExtendedEntityPropTuto imoney = ExtendedEntityPropTuto.get(player);
    

    mais après je ne vois pas pourquoi ça crash.

    Voici mes codes:

    -Log:

    –-- Minecraft Crash Report ----
    // Everything's going to plan. No, really, that was supposed to happen.
    
    Time: 23/10/15 16:44
    Description: Unexpected error
    
    java.lang.NullPointerException: Unexpected error
    at tarael.extendedentity.ExtendedEntityPropTuto.get(ExtendedEntityPropTuto.java:64)
    at tarael.gui.GuiAtelierSwordT1.<init>(GuiAtelierSwordT1.java:44)
    at tarael.client.ClientProxy.keyTestTyped(ClientProxy.java:88)
    at tarael.client.ClientProxy.onEvent(ClientProxy.java:81)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_0_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138)
    at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:581)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:2041)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1087)
    at net.minecraft.client.Minecraft.run(Minecraft.java:376)
    at net.minecraft.client.main.Main.main(Main.java:117)
    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 tarael.extendedentity.ExtendedEntityPropTuto.get(ExtendedEntityPropTuto.java:64)
    at tarael.gui.GuiAtelierSwordT1.<init>(GuiAtelierSwordT1.java:44)
    at tarael.client.ClientProxy.keyTestTyped(ClientProxy.java:88)
    at tarael.client.ClientProxy.onEvent(ClientProxy.java:81)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_0_ClientProxy_onEvent_KeyInputEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:138)
    at net.minecraftforge.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:581)
    
    -- Affected level --
    Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player250'/311, l='MpServer', x=-144,61, y=83,78, z=272,97]]
    Chunk stats: MultiplayerChunkCache: 587, 587
    Level seed: 0
    Level generator: ID 00 - default, ver 1\. Features enabled: false
    Level generator options:
    Level spawn location: -185,00,64,00,197,00 - World: (-185,64,197), Chunk: (at 7,4,5 in -12,12; contains blocks -192,0,192 to -177,255,207), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 39417 game time, 1078 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 128 total; [EntitySheep['Sheep'/260, l='MpServer', x=-85,06, y=66,00, z=212,00], EntityItem['item.item.egg'/261, l='MpServer', x=-88,88, y=67,00, z=246,50], EntityChicken['Chicken'/262, l='MpServer', x=-95,41, y=67,00, z=247,50], EntitySheep['Sheep'/263, l='MpServer', x=-88,50, y=67,00, z=242,44], EntityItem['item.item.egg'/264, l='MpServer', x=-82,03, y=66,00, z=260,38], EntitySheep['Sheep'/265, l='MpServer', x=-86,44, y=66,00, z=267,31], EntitySheep['Sheep'/266, l='MpServer', x=-94,91, y=66,00, z=275,09], EntitySheep['Sheep'/267, l='MpServer', x=-91,22, y=66,00, z=275,09], EntitySheep['Sheep'/268, l='MpServer', x=-80,03, y=69,00, z=288,97], EntitySheep['Sheep'/269, l='MpServer', x=-82,56, y=70,00, z=289,63], EntityChicken['Chicken'/273, l='MpServer', x=-71,50, y=67,00, z=193,63], EntitySheep['Sheep'/274, l='MpServer', x=-79,97, y=66,00, z=238,00], EntitySheep['Sheep'/275, l='MpServer', x=-67,56, y=67,00, z=245,66], EntityChicken['Chicken'/277, l='MpServer', x=-79,63, y=65,00, z=268,41], EntitySkeleton['Skeleton'/279, l='MpServer', x=-72,31, y=12,00, z=275,78], EntityChicken['Chicken'/280, l='MpServer', x=-78,22, y=67,00, z=282,53], EntityChicken['Chicken'/281, l='MpServer', x=-73,63, y=72,00, z=279,38], EntitySkeleton['Skeleton'/67, l='MpServer', x=-219,91, y=63,00, z=225,47], EntityPlayerSP['Player250'/311, l='MpServer', x=-144,61, y=83,78, z=272,97], EntityBat['Bat'/68, l='MpServer', x=-216,53, y=65,16, z=234,97], EntityBat['Bat'/78, l='MpServer', x=-224,38, y=53,10, z=315,22], EntityCreeper['Creeper'/89, l='MpServer', x=-211,34, y=22,00, z=211,91], EntityCreeper['Creeper'/90, l='MpServer', x=-214,28, y=62,00, z=229,72], EntityCreeper['Creeper'/91, l='MpServer', x=-220,72, y=59,00, z=239,72], EntitySkeleton['Skeleton'/92, l='MpServer', x=-220,69, y=59,00, z=237,41], EntityPig['Pig'/93, l='MpServer', x=-219,56, y=72,00, z=231,75], EntitySkeleton['Skeleton'/94, l='MpServer', x=-217,56, y=64,00, z=236,09], EntityZombie['Zombie'/95, l='MpServer', x=-221,06, y=4,41, z=270,31], EntityCreeper['Creeper'/96, l='MpServer', x=-213,31, y=28,16, z=266,25], EntityCreeper['Creeper'/97, l='MpServer', x=-210,56, y=25,00, z=270,94], EntityBat['Bat'/98, l='MpServer', x=-213,75, y=51,10, z=258,81], EntityRabbit['Rabbit'/99, l='MpServer', x=-214,19, y=73,00, z=282,56], EntityRabbit['Rabbit'/100, l='MpServer', x=-217,00, y=65,00, z=283,97], EntityRabbit['Rabbit'/101, l='MpServer', x=-211,53, y=65,00, z=281,84], EntityZombie['Zombie'/102, l='MpServer', x=-216,03, y=18,00, z=297,56], EntityBat['Bat'/103, l='MpServer', x=-208,56, y=45,91, z=292,34], EntityBat['Bat'/104, l='MpServer', x=-216,41, y=51,08, z=298,59], EntityBat['Bat'/105, l='MpServer', x=-207,63, y=45,28, z=293,31], EntityBat['Bat'/106, l='MpServer', x=-206,16, y=45,06, z=289,25], EntityRabbit['Rabbit'/107, l='MpServer', x=-221,81, y=75,00, z=339,31], EntityCreeper['Creeper'/120, l='MpServer', x=-197,41, y=15,00, z=228,97], EntityCreeper['Creeper'/121, l='MpServer', x=-196,50, y=20,00, z=228,50], EntityRabbit['Rabbit'/122, l='MpServer', x=-198,41, y=67,00, z=228,25], EntitySheep['Sheep'/123, l='MpServer', x=-202,06, y=74,00, z=224,13], EntitySpider['Spider'/124, l='MpServer', x=-203,31, y=18,23, z=250,03], EntitySpider['Spider'/125, l='MpServer', x=-203,31, y=21,97, z=251,06], EntityRabbit['Rabbit'/126, l='MpServer', x=-192,25, y=64,00, z=253,44], EntityBat['Bat'/127, l='MpServer', x=-204,25, y=65,10, z=240,75], EntityCreeper['Creeper'/129, l='MpServer', x=-203,81, y=59,00, z=289,34], EntitySkeleton['Skeleton'/130, l='MpServer', x=-197,16, y=59,00, z=298,38], EntityZombie['Zombie'/138, l='MpServer', x=-184,72, y=40,00, z=197,16], EntityZombie['Zombie'/139, l='MpServer', x=-185,31, y=20,05, z=211,69], EntityPig['Pig'/140, l='MpServer', x=-177,97, y=69,00, z=216,28], EntityCreeper['Creeper'/141, l='MpServer', x=-182,31, y=23,00, z=230,28], EntityCreeper['Creeper'/142, l='MpServer', x=-182,00, y=25,00, z=231,44], EntityBat['Bat'/143, l='MpServer', x=-178,56, y=31,38, z=255,19], EntitySpider['Spider'/144, l='MpServer', x=-188,28, y=32,00, z=249,28], EntityCreeper['Creeper'/145, l='MpServer', x=-185,84, y=48,00, z=262,28], EntityEnderman['Enderman'/146, l='MpServer', x=-185,38, y=48,00, z=261,44], EntityCreeper['Creeper'/147, l='MpServer', x=-186,72, y=48,00, z=262,69], EntityRabbit['Rabbit'/148, l='MpServer', x=-182,31, y=71,00, z=327,91], EntitySheep['Sheep'/149, l='MpServer', x=-176,97, y=71,00, z=330,09], EntityRabbit['Rabbit'/150, l='MpServer', x=-189,34, y=71,00, z=336,38], EntityRabbit['Rabbit'/151, l='MpServer', x=-182,94, y=71,00, z=345,16], EntityRabbit['Rabbit'/152, l='MpServer', x=-186,78, y=68,00, z=351,16], EntityRabbit['Rabbit'/153, l='MpServer', x=-182,56, y=68,00, z=348,38], EntitySkeleton['Skeleton'/161, l='MpServer', x=-162,09, y=28,00, z=206,53], EntityBat['Bat'/162, l='MpServer', x=-163,53, y=16,88, z=205,47], EntitySpider['Spider'/164, l='MpServer', x=-169,72, y=22,00, z=223,28], EntityZombie['Zombie'/165, l='MpServer', x=-163,25, y=34,00, z=218,16], EntitySheep['Sheep'/166, l='MpServer', x=-168,56, y=66,00, z=304,03], EntitySheep['Sheep'/167, l='MpServer', x=-162,94, y=69,00, z=318,00], EntityCreeper['Creeper'/168, l='MpServer', x=-168,53, y=52,00, z=330,28], EntityCreeper['Creeper'/169, l='MpServer', x=-164,59, y=54,00, z=323,91], EntityZombie['Zombie'/170, l='MpServer', x=-165,03, y=42,00, z=348,56], EntityCreeper['Creeper'/171, l='MpServer', x=-163,44, y=50,00, z=336,03], EntityRabbit['Rabbit'/177, l='MpServer', x=-158,50, y=63,00, z=201,69], EntitySheep['Sheep'/178, l='MpServer', x=-152,84, y=63,00, z=211,19], EntityZombie['Zombie'/179, l='MpServer', x=-155,53, y=39,00, z=225,88], EntityZombie['Zombie'/180, l='MpServer', x=-153,41, y=30,00, z=254,97], EntityZombie['Zombie'/181, l='MpServer', x=-155,91, y=33,00, z=251,53], EntitySheep['Sheep'/182, l='MpServer', x=-157,94, y=63,00, z=251,88], EntityZombie['Zombie'/183, l='MpServer', x=-145,50, y=17,00, z=277,91], EntitySheep['Sheep'/184, l='MpServer', x=-157,84, y=64,00, z=297,88], EntityEnderman['Enderman'/195, l='MpServer', x=-134,31, y=39,00, z=200,19], EntityCreeper['Creeper'/196, l='MpServer', x=-125,34, y=40,00, z=204,50], EntityBat['Bat'/197, l='MpServer', x=-134,31, y=43,10, z=200,28], EntityZombie['Zombie'/198, l='MpServer', x=-142,28, y=32,00, z=215,84], EntitySquid['Squid'/199, l='MpServer', x=-129,63, y=62,13, z=215,25], EntitySquid['Squid'/200, l='MpServer', x=-132,97, y=61,00, z=211,25], EntityCreeper['Creeper'/201, l='MpServer', x=-139,75, y=12,00, z=238,09], EntityCreeper['Creeper'/202, l='MpServer', x=-129,03, y=22,00, z=233,59], EntityZombie['Zombie'/203, l='MpServer', x=-142,56, y=39,00, z=238,88], EntitySquid['Squid'/204, l='MpServer', x=-131,38, y=60,38, z=226,84], EntitySquid['Squid'/205, l='MpServer', x=-128,69, y=61,00, z=231,28], EntityCreeper['Creeper'/206, l='MpServer', x=-128,34, y=16,00, z=248,09], EntityZombie['Zombie'/207, l='MpServer', x=-136,50, y=39,00, z=243,50], EntitySkeleton['Skeleton'/208, l='MpServer', x=-143,50, y=17,00, z=256,69], EntitySkeleton['Skeleton'/209, l='MpServer', x=-138,63, y=42,00, z=263,78], EntityCreeper['Creeper'/210, l='MpServer', x=-139,38, y=42,00, z=272,03], EntitySquid['Squid'/211, l='MpServer', x=-131,88, y=61,56, z=252,81], EntityZombie['Zombie'/212, l='MpServer', x=-133,50, y=47,00, z=282,13], EntitySheep['Sheep'/213, l='MpServer', x=-141,16, y=64,00, z=271,16], EntityCreeper['Creeper'/214, l='MpServer', x=-132,25, y=24,00, z=293,81], EntityEnderman['Enderman'/219, l='MpServer', x=-114,72, y=34,00, z=206,38], EntityBat['Bat'/220, l='MpServer', x=-118,25, y=39,10, z=231,25], EntitySquid['Squid'/221, l='MpServer', x=-121,72, y=61,00, z=286,72], EntitySquid['Squid'/222, l='MpServer', x=-122,19, y=61,66, z=281,50], EntitySquid['Squid'/223, l='MpServer', x=-113,50, y=61,00, z=272,47], EntitySkeleton['Skeleton'/224, l='MpServer', x=-116,03, y=20,00, z=292,56], EntitySquid['Squid'/225, l='MpServer', x=-124,53, y=61,00, z=294,50], EntitySheep['Sheep'/226, l='MpServer', x=-134,84, y=67,00, z=319,03], EntityRabbit['Rabbit'/239, l='MpServer', x=-105,50, y=66,00, z=197,56], EntityRabbit['Rabbit'/240, l='MpServer', x=-97,81, y=67,00, z=202,44], EntityCreeper['Creeper'/241, l='MpServer', x=-108,63, y=29,00, z=261,44], EntityBat['Bat'/242, l='MpServer', x=-117,19, y=26,44, z=276,22], EntitySkeleton['Skeleton'/243, l='MpServer', x=-107,88, y=24,00, z=278,50], EntitySkeleton['Skeleton'/244, l='MpServer', x=-108,53, y=24,00, z=274,91], EntityBat['Bat'/245, l='MpServer', x=-90,34, y=33,91, z=279,34], EntityBat['Bat'/246, l='MpServer', x=-112,41, y=32,10, z=280,25], EntitySheep['Sheep'/247, l='MpServer', x=-107,56, y=68,00, z=300,34], EntitySheep['Sheep'/248, l='MpServer', x=-97,53, y=69,00, z=293,22], EntitySheep['Sheep'/249, l='MpServer', x=-108,47, y=64,00, z=293,53], EntitySheep['Sheep'/250, l='MpServer', x=-109,78, y=69,00, z=297,47], EntitySheep['Sheep'/251, l='MpServer', x=-110,13, y=68,00, z=312,91], EntitySheep['Sheep'/252, l='MpServer', x=-113,78, y=67,00, z=333,47], EntitySheep['Sheep'/253, l='MpServer', x=-102,22, y=71,00, z=331,44], EntityZombie['Zombie'/254, l='MpServer', x=-104,16, y=56,00, z=347,34]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
    Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614)
    at net.minecraft.client.Minecraft.run(Minecraft.java:405)
    at net.minecraft.client.main.Main.main(Main.java:117)
    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.8
    Operating System: Windows 8.1 (amd64) version 6.3
    Java Version: 1.8.0_25, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 583955272 bytes (556 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 6, allocated: 12, tallocated: 94
    FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1446 5 mods loaded, 5 mods active
    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Forge{11.14.3.1446} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    examplemod{1.0} [examplemod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    tm{Drakaelia_0.01_4.b} [Mod Drakaelia] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Loaded coremods (and transformers):
    GL info: ' Vendor: 'Intel' Version: '4.2.0 - Build 10.18.10.3355' Renderer: 'Intel(R) HD Graphics 4400'
    Launched Version: 1.8
    LWJGL: 2.9.1
    OpenGL: Intel(R) HD Graphics 4400 GL version 4.2.0 - Build 10.18.10.3355, Intel
    GL Caps: Using GL 1.3 multitexturing.
    Using GL 1.3 texture combiners.
    Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
    Shaders are available because OpenGL 2.1 is supported.
    VBOs are available because OpenGL 1.5 is supported.
    
    Using VBOs: No
    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)
    

    -ExtendedEntityPropTuto:

    package tarael.extendedentity;
    
    import tarael.client.CommonProxy;
    import tarael.common.ModTarael;
    import tarael.packet.PacketMoney;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.EntityPlayerMP;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.IChatComponent;
    import net.minecraft.world.World;
    import net.minecraftforge.common.IExtendedEntityProperties;
    
    public class ExtendedEntityPropTuto implements IExtendedEntityProperties 
    {
    
    public final static String EXT_PROP_NAME = "ExtPropTuto";
    
    private final EntityPlayer player;
    
    public int money;
        public int maxMoney;
    
        public ExtendedEntityPropTuto(EntityPlayer player) {
    this.player = player;
    this.money = 0;
    this.maxMoney = 999999999;
    }
    
    @Override
    public void saveNBTData(NBTTagCompound compound) {
    // TODO Auto-generated method stub
    NBTTagCompound properties = new NBTTagCompound();
    
    properties.setInteger("Money", this.money);
    properties.setInteger("MaxMoney", this.maxMoney);
    
    compound.setTag(EXT_PROP_NAME, properties);
    }
    
    @Override
    public void loadNBTData(NBTTagCompound compound) {
    // TODO Auto-generated method stub
    NBTTagCompound properties = (NBTTagCompound) compound
    .getTag(EXT_PROP_NAME);
    this.money = properties.getInteger("Money");
    this.maxMoney = properties.getInteger("MaxMoney");
    }
    
    @Override
    public void init(Entity entity, World world) {
    // TODO Auto-generated method stub
    
    }
    
    public static final void register(EntityPlayer player) 
    {
    player.registerExtendedProperties(ExtendedEntityPropTuto.EXT_PROP_NAME,
    new ExtendedEntityPropTuto(player));
    }
    
    public static final ExtendedEntityPropTuto get(EntityPlayer player) 
    {
    return (ExtendedEntityPropTuto) player.getExtendedProperties(EXT_PROP_NAME);
    }
    
    public final void sync() {
    PacketMoney packetMoney = new PacketMoney(this.maxMoney, this.money);
           //La ligne suivante dépend de votre manière d'envoyer les packets. Celle-ci vient de mon mod, je ne la changerais pas car je ne peux l'appliquer à votre mod, mais elle reste bonne pour un exemple.
    ModTarael.network.sendToServer(packetMoney);
    
    if (!player.worldObj.isRemote) {
    EntityPlayerMP player1 = (EntityPlayerMP) player;
                //Ici, même chose que précédemment, sauf que le packet est envoyé au player.
    ModTarael.network.sendTo(packetMoney, player1);
    }
    }
    
    private static String getSaveKey(EntityPlayer player) {
    return player.getDisplayName() + ":" + EXT_PROP_NAME;
    }
    
    public static void saveProxyData(EntityPlayer player) {
    ExtendedEntityPropTuto playerData = ExtendedEntityPropTuto.get(player);
    NBTTagCompound savedData = new NBTTagCompound();
    
    playerData.saveNBTData(savedData);
    CommonProxy.storeEntityData(getSaveKey(player), savedData);
    }
    
    public static void loadProxyData(EntityPlayer player) {
    ExtendedEntityPropTuto playerData = ExtendedEntityPropTuto.get(player);
    NBTTagCompound savedData = CommonProxy
    .getEntityData(getSaveKey(player));
    
    if (savedData != null) {
    playerData.loadNBTData(savedData);
    }
    playerData.sync();
    }
    
    public boolean pay(int amount) {
    boolean sufficient = amount <= this.money;
    
    if (sufficient) {
    this.money -= amount;
    this.sync();
    } else {
    return false;
    }
    
    return sufficient;
    }
    
    public void addMoney(int amount) {
    this.money += amount;
    this.sync();
    }
    
    public int getMoney() {
    return this.money;
    }
    
    public void setMoney(int newMoney) {
    this.money = newMoney;
    this.sync();
    }
    
    }
    
    

    -GuiAtelierSwordT1:

    package tarael.gui;
    
    import java.awt.Color;
    
    import org.lwjgl.opengl.GL11;
    
    import scala.Int;
    import tarael.common.ListeItems;
    import tarael.extendedentity.ExtendedEntityPropTuto;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiScreen;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.ResourceLocation;
    
    public class GuiAtelierSwordT1 extends GuiScreen
    {
    private ResourceLocation ast1 = new ResourceLocation(
    "tm:textures/client/gui/ast1.png");
    public final int xSizeOfTexture = 227;
    public final int ySizeOfTexture = 182;
    EntityPlayer player;
    
    //String argent = Long.toString(props.getMoney());
    private String name1;
    private String name2;
    private String name3;
    private int name1n;
    private int name2n;
    private int name3n;
    private String smoney;
    public int rarity = 0;
    private int craftnum;
    private String craftnumstr;
    private String name1craft;
    private String name2craft;
    
    public GuiAtelierSwordT1(EntityPlayer player)
    {
    name1 = "\u00a70KatanaDI";
    name2 = "\u00a70GateTruth";
    name3 = "null";
    ExtendedEntityPropTuto imoney = ExtendedEntityPropTuto.get(player);
    String smoney = String.valueOf(imoney.getMoney());
    }
    
    @Override
    public void drawScreen(int x, int y, float f) {
    drawDefaultBackground();
    
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(ast1);
    
    int posX = (this.width - xSizeOfTexture) / 2;
    int posY = (this.height - ySizeOfTexture) / 2;
    
    drawTexturedModalRect(posX, posY, 0, 0, xSizeOfTexture, ySizeOfTexture);
    
    this.fontRendererObj.drawString(name1, posX+6, posY+28, 0xFF0000);
    this.fontRendererObj.drawString(name2, posX+6, posY+50, 0xFF0000);
    this.fontRendererObj.drawString(name3, posX+6, posY+72, 0xFF0000);
    this.fontRendererObj.drawString(craftnumstr, posX+61, posY+23, 0xFF0000);
    this.fontRendererObj.drawString("Craft : " + name2craft, posX+67, posY+29, 0xFF0000);
    this.fontRendererObj.drawString(smoney, posX + 150, posY, 0xFF0000);
    
    super.drawScreen(x, y, f);
    }
    
    @Override
    public boolean doesGuiPauseGame() {
    return false;
    }
    
    public void initGui() {
    this.buttonList.clear();
    int posX = (this.width - xSizeOfTexture) / 2;
    int posY = (this.height - ySizeOfTexture) / 2;
    this.buttonList.add(new GuiButton(0, posX+210, posY, 16, 20, "X"));
    this.buttonList.add(new GuiButton(10, posX+4, posY+4, 22, 14, "\u00a7e\u00a7lS"));
    this.buttonList.add(new GuiButton(11, posX+39, posY+4, 22, 14, "\u00a75\u00a7lA"));
    this.buttonList.add(new GuiButton(12, posX+74, posY+4, 22, 14, "\u00a76\u00a7lB"));
    this.buttonList.add(new GuiButton(4, posX + 5, posY + 39, 47, 9, "choisir"));
    this.buttonList.add(new GuiButton(5, posX + 5, posY + 61, 47, 9, "choisir"));
    this.buttonList.add(new GuiButton(6, posX + 5, posY + 83, 47, 9, "choisir"));
    this.buttonList.add(new GuiButton(51, posX + 117, posY + 160, 48, 15, "CRAFT"));
    }
    
    public void actionPerformed(GuiButton button) {
    switch (button.id) {
    case 0: {
    mc.thePlayer.sendChatMessage("Closing Gui");
    this.mc.thePlayer.closeScreen();
    }
    break;
    
    case 10: 
    {
    name1 = "\u00a70KatanaDI";
    name2 = "\u00a70GateTruth";
    name3 = "null";
    name1n = 0;
    name2n = 0;
    name3n = 0;
    
    }
    break;
    
    case 11: 
    {
    name1 = "\u00a75EpeeMDCE";
    name2 = "\u00a75Papillon";
    name3 = "null";
    name1n = 1;
    name2n = 1;
    name3n = 1;
    }
    break;
    
    case 12: 
    {
    name1 = "\u00a76HacheDGS";
    name2 = "null";
    name3 = "null";
    name1n = 2;
    name2n = 2;
    name3n = 2;
    }
    break;
    
    case 4: 
    {
    
    if(name1n == 0)
    {
    craftnum = 1;
    craftnumstr = "1";
    name2craft = "\u00a7eKatana Des Intempéries";
    }
    else if(name1n == 1)
    {
    craftnum = 2;
    craftnumstr = "2";
    name2craft = "\u00a75\u00c9p\u00e9e maudite du ciel \u00e9toil\u00e9";
    }
    else if (name1n == 2)
    {
    craftnum = 3;
    craftnumstr = "3";
    name2craft = "\u00a76Hache Du Barbare Sanguinaire";
    }
    
    }
    break;
    case 5: 
    {
    if(name2n == 0)
    {
    craftnum = 11;
    craftnumstr = "11";
    name2craft = "\u00a7eGate Of Truth";
    }
    else if (name2n == 1)
    {
    craftnum = 12;
    craftnumstr = "12";
    name2craft = "\u00a75Lame D\u00e9monique du Papillon";
    }
    else if (name2n == 2)
    {
    craftnum = 13;
    craftnumstr = "13";
    name2craft = "null";
    }
    }
    break;
    case 51: 
    {
    /*if(craftnum == 1)
    {
    mc.thePlayer.inventory.addItemStackToInventory(new ItemStack(ListeItems.katanafoudre));
    }
    if(craftnum == 2)
    {
    mc.thePlayer.inventory.addItemStackToInventory(new ItemStack(ListeItems.dblade));
    }
    if(craftnum == 3)
    {
    mc.thePlayer.inventory.addItemStackToInventory(new ItemStack(ListeItems.hachede));
    }
    if(craftnum == 11)
    {
    mc.thePlayer.inventory.addItemStackToInventory(new ItemStack(ListeItems.item_test));
    }
    if(craftnum == 12)
    {
    mc.thePlayer.inventory.addItemStackToInventory(new ItemStack(ListeItems.dark_butterfly));
    }*/
    
    }
    default:
    break;
    
    }
    }
    
    public void updateScreen()
    {
    
    super.updateScreen();
    }
    
    }
    
    

    Je tiens aussi à préciser que c'est la première fois que j'utilise une ExtendedEntityProperties et donc tout conseil sera le bienvenu 🙂 .</init></init>



  • Ton joueur est null, envoi ton ClientProxy



  • Voici mon client proxy :

    package tarael.client;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.model.ModelBiped;
    import net.minecraft.client.settings.KeyBinding;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.world.World;
    import net.minecraftforge.client.MinecraftForgeClient;
    import net.minecraftforge.fml.client.registry.ClientRegistry;
    import net.minecraftforge.fml.client.registry.RenderingRegistry;
    import net.minecraftforge.fml.common.FMLCommonHandler;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
    
    import org.lwjgl.input.Keyboard;
    
    import tarael.common.ListeBlocks;
    import tarael.common.ListeItems;
    import tarael.common.ModTarael;
    import tarael.common.TaraelArmors;
    import tarael.Entity.EntityGolem1;
    import tarael.Entity.EntityMount1;
    import tarael.Entity.ModelGolem1;
    import tarael.Entity.ModelMount1;
    import tarael.gui.GuiAdmin;
    import tarael.gui.GuiAtelierSwordT1;
    import tarael.render.RenderCasqueGuerrier;
    import tarael.render.RenderGolem1;
    import tarael.render.RenderMount1;
    import tarael.render.SamuraiArmor;
    import tarael.render.SamuraiArmorRed;
    
    public class ClientProxy extends CommonProxy
    {
    //RenderItem registerMesher = Minecraft.getMinecraft().getRenderItem();
    public static final Map <item, modelbiped="">armorModels = new HashMap<item, modelbiped="">();
    public static final Map <item, modelbiped="">armorModelsr = new HashMap<item, modelbiped="">();
    private static KeyBinding keyBindTest;
    private EntityPlayer player;
    private World par2World;
    private EntityGolem1 npc;
    
    public ClientProxy()
    {
    keyBindTest = new KeyBinding("modtest.key", Keyboard.KEY_C, "key.categories.gameplay");
    ClientRegistry.registerKeyBinding(keyBindTest);
    }
    
    @Override
    public void registerRenders()
    {
    ListeBlocks.registerRenders();
    ListeItems.registerRenders();
    MinecraftForgeClient.registerItemRenderer(TaraelArmors.CasqueGuerrier, new RenderCasqueGuerrier());
    SamuraiArmor armures1 = new SamuraiArmor(0.5F);
    SamuraiArmorRed armures2 = new SamuraiArmorRed(0.5F);
    armorModels.put(TaraelArmors.CasqueS1, armures1);
    armorModels.put(TaraelArmors.TorseS1, armures1);
    armorModels.put(TaraelArmors.PantalonS1, armures1);
    armorModelsr.put(TaraelArmors.CasqueS2, armures2);
    armorModelsr.put(TaraelArmors.TorseS2, armures2);
    armorModelsr.put(TaraelArmors.PantalonS2, armures2);
    
    RenderingRegistry.registerEntityRenderingHandler(EntityGolem1.class, new RenderGolem1(Minecraft.getMinecraft().getRenderManager(), new ModelGolem1(), 0.5F));
    RenderingRegistry.registerEntityRenderingHandler(EntityMount1.class, new RenderMount1(Minecraft.getMinecraft().getRenderManager(), new ModelMount1(), 0.5F));
    
    }
    
    @SubscribeEvent
    public void onEvent(KeyInputEvent event)
    {
    if(keyBindTest.isPressed())
    {
    keyTestTyped();
    }
    }
    
    private void keyTestTyped()
    {
    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText("Ouverture du gui"));
    Minecraft.getMinecraft().displayGuiScreen(new GuiAtelierSwordT1(player));
    //Minecraft.getMinecraft().thePlayer.openGui(ModTarael.instance, 2, par2World, (int) player.posX, (int)player.posY, (int)player.posZ);
    }
    }
    
    ```</item,></item,></item,></item,>


  • Euh, es-tu au courant que tu déclares un joueur dans ton ClientProxy, ainsi qu'un world et un golem sans les initialisés ? De plus juste au-dessus (ligne 86), tu utilises le joueur, pourquoi ne pas le mettre en paramètre ?


  • Administrateurs

    Les trois variables de ton client proxy :
    private EntityPlayer player;
    private World par2World;
    private EntityGolem1 npc;
    Sont tous null (comme SCAREX l'a dit) et ne servent à rien. Retires-les.
    Et dans cette ligne :
    Minecraft.getMinecraft().displayGuiScreen(new GuiAtelierSwordT1(player));
    Mets Minecraft.getMinecraft().thePlayer à la place de player.



  • Merci c’était ça en effet ^^. Je passe en résolu.