MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    OnItemRightClick sur une entity.

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    125 Messages 8 Publieurs 21.6k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • BrokenSwingB Hors-ligne
      BrokenSwing Moddeurs confirmés Rédacteurs
      dernière édition par

      Envoie ta classe principale et ton packet

      1 réponse Dernière réponse Répondre Citer 0
      • GabsG Hors-ligne
        Gabs
        dernière édition par

        Class Principale:

        Class Packet:

        package com.AltisMine.mod;
        
        import io.netty.buffer.ByteBuf;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.entity.player.EntityPlayerMP;
        import net.minecraft.nbt.NBTTagCompound;
        import net.minecraftforge.event.entity.EntityJoinWorldEvent;
        import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
        import cpw.mods.fml.common.eventhandler.SubscribeEvent;
        import cpw.mods.fml.common.network.simpleimpl.IMessage;
        import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
        import cpw.mods.fml.common.network.simpleimpl.MessageContext;
        
        public class PacketAlcool implements IMessage, IMessageHandler <packettrafficchannel, imessage="">{
        
        public class Handler {
        
        @SubscribeEvent
        public void onEntityConstructing(EntityConstructing event) {
        
        if (event.entity instanceof EntityPlayer
        && ExtendedEntityPropAlcool.get((EntityPlayer) event.entity) == null)
        
        ExtendedEntityPropAlcool.register((EntityPlayer) event.entity);
        }
        
               @SubscribeEvent
        public void onEntityJoinWorld(EntityJoinWorldEvent event) {
        if (!event.entity.worldObj.isRemote
        && event.entity instanceof EntityPlayer) {
        NBTTagCompound playerData = AltisMineMod.proxy.getEntityData(((EntityPlayer) event.entity).getDisplayName());
        if (playerData != null) {
        ((ExtendedEntityPropAlcool) (event.entity.getExtendedProperties(ExtendedEntityPropAlcool.EXT_PROP_NAME))).loadNBTData(playerData);
        }
        
        ((ExtendedEntityPropAlcool) (event.entity.getExtendedProperties(ExtendedEntityPropAlcool.EXT_PROP_NAME))).sync();
        }
               }
        }
        
        private int alcool;
        
        public PacketAlcool() {}
        
        public PacketAlcool(int alcool) {
        this.alcool = alcool;
        }
        
        public IMessage onMessage(PacketAlcool message, MessageContext ctx) {
        EntityPlayerMP player = ctx.getServerHandler().playerEntity;
        ExtendedEntityPropAlcool props = ExtendedEntityPropAlcool
        .get(player);
        props.setAlcool(message.alcool);
        return message;
        }
        
        @Override
        public void fromBytes(ByteBuf buf) {
                        this.alcool = buf.readInt();
        }
        
        @Override
        public void toBytes(ByteBuf buf) {
                        buf.writeInt(this.alcool);
        }
        
        @Override
        public IMessage onMessage(PacketTrafficChannel message, MessageContext ctx) {
        // TODO Auto-generated method stub
        return null;
        }
        
        }
        
        ```</packettrafficchannel,>
        1 réponse Dernière réponse Répondre Citer 0
        • robin4002R Hors-ligne
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
          dernière édition par

          La classe de ton paquet est complètement fausse.
          Je t’invite à aller voir le tutoriel sur les paquets du site.

          1 réponse Dernière réponse Répondre Citer 0
          • GabsG Hors-ligne
            Gabs
            dernière édition par

            Ouais merci prob résolu je vais essayé ça je vous dis la réponse .
            Class packet ( ou cas ou si j’aurai oublier quelques trucs ) :

            public class PacketAlcool implements IMessage{
            
            private int alcool;
            
            public PacketAlcool() {}
            
            public PacketAlcool(int alcool) {
            this.alcool = alcool;
            }
            
            @Override
            public void fromBytes(ByteBuf buf) {
                            this.alcool = buf.readInt();
            }
            
            @Override
            public void toBytes(ByteBuf buf) {
                            buf.writeInt(this.alcool);
            }
            
             public static class Handler implements IMessageHandler <packetalcool, imessage="">{
            
            @Override
            public IMessage onMessage(PacketAlcool message, MessageContext ctx) {
            EntityPlayerMP player = ctx.getServerHandler().playerEntity;
            ExtendedEntityPropAlcool props = ExtendedEntityPropAlcool
            .get(player);
            props.setAlcool(message.alcool);
            return message;
            }
             }
            
            }
            
            ```</packetalcool,>
            1 réponse Dernière réponse Répondre Citer 0
            • robin4002R Hors-ligne
              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
              dernière édition par

              C’est en effet mieux comme ça.
              Ça ne fonctionne toujours pas ?

              1 réponse Dernière réponse Répondre Citer 0
              • GabsG Hors-ligne
                Gabs
                dernière édition par

                sisi c’est bon l’erreur est réglée il manque juste que je l’essaye sur mon serveur

                1 réponse Dernière réponse Répondre Citer 0
                • GabsG Hors-ligne
                  Gabs
                  dernière édition par

                  Marche pas je crois que vous avez pas compris se que je voulais faire.
                  Je veux faire que l’osque que on clic droit sur un joueur on obtient son niveau d’alcoolémie .
                  //EDIT:
                  Les codes marches mais le problème c’est que ça prend mon niveau d’alcoolémie l’osque je fais clic droit sur un joueur et pas celui du joueur …

                  1 réponse Dernière réponse Répondre Citer 0
                  • robin4002R Hors-ligne
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                    dernière édition par

                    Envoies un .zip de ton dossier src je vais regarder de mon côté.

                    1 réponse Dernière réponse Répondre Citer 0
                    • GabsG Hors-ligne
                      Gabs
                      dernière édition par

                      J’ai pas pu te le mettre en pièce jointe c’est trop lourd du coup tien:
                      http://armacraft.net/Flow/src.zip
                      Attend encore quelques minutes c’est en upload d’ici 2min c’est bon

                      1 réponse Dernière réponse Répondre Citer 0
                      • robin4002R Hors-ligne
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                        dernière édition par

                        Au pire je me serai passé des 25 mo de son x)

                        1 réponse Dernière réponse Répondre Citer 0
                        • GabsG Hors-ligne
                          Gabs
                          dernière édition par

                          C’est vrai ^^ j’avais la flemme 🙂

                          1 réponse Dernière réponse Répondre Citer 0
                          • robin4002R Hors-ligne
                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                            dernière édition par

                            Ho putain le truc horrible que tu as fait x)
                            En plus ça ne risque pas du tout de fonctionner car tu utilises la même instance pour tout et en plus qui sort de nul part. En gros là si un joueur bois ça va augmenter le niveau d’alcool de tout le monde …
                            Voila un truc plus propre :

                            package com.AltisMine.mod;
                            
                            import ibxm.Player;
                            
                            import java.util.List;
                            
                            import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                            import net.minecraft.client.renderer.texture.IIconRegister;
                            import net.minecraft.entity.Entity;
                            import net.minecraft.entity.EntityLivingBase;
                            import net.minecraft.entity.player.EntityPlayer;
                            import net.minecraft.item.Item;
                            import net.minecraft.item.ItemStack;
                            import net.minecraft.nbt.NBTTagCompound;
                            import net.minecraft.util.ChatComponentText;
                            import net.minecraft.world.World;
                            import net.minecraftforge.common.util.Constants;
                            import net.minecraftforge.event.entity.player.EntityInteractEvent;
                            
                            public class AT extends Item
                            {
                            public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity)
                            {
                            if(entity instanceof EntityPlayer)
                            {
                            EntityPlayer target = (EntityPlayer)entity;
                            if(!stack.hasTagCompound())
                            {
                            stack.setTagCompound(new NBTTagCompound());
                            }
                            ExtendedEntityPropAlcool prop = ExtendedEntityPropAlcool.get(target);
                            stack.getTagCompound().setInteger("level", prop.getAlcool());
                            }
                            return true;
                            }
                            
                            public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
                            {
                            if(!stack.hasTagCompound())
                            {
                            stack.setTagCompound(new NBTTagCompound());
                            }
                            if(stack.getTagCompound().hasKey("level", Constants.NBT.TAG_INT))
                            {
                            list.add("le niveau d'alcoolemie de la personne est de : " + stack.getTagCompound().getInteger("level"));
                            }
                            else
                            {
                            list.add("Faite clic droit sur le joueur pour ");
                            list.add("obtenir son niveau d'alcoolemie.");
                            }
                            }
                            }
                            

                            Et du-coup dans tes items comme IMF tu vires ça :
                            AT alcohol = new AT();
                            public int Fixlvl = 0;
                            Et tu définie le niveau d’alcool dans ExtendedEntityPropAlcool

                            1 réponse Dernière réponse Répondre Citer 0
                            • GabsG Hors-ligne
                              Gabs
                              dernière édition par

                              Merci! mais,
                              Je définie le niveau d’alcool avec mon ancien système ?
                              code:
                              if (lvl != 0)
                                   lvl2 = Math.abs(lvl / 2);
                                 else if (lvl == 0) {
                                   lvl2 = Math.abs(lvl);
                                 }
                                 this.lvlS = Integer.toString(lvl2);

                              1 réponse Dernière réponse Répondre Citer 0
                              • robin4002R Hors-ligne
                                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                dernière édition par

                                J’ai viré ça car j’ai pas réussi a comprendre l’intérêt x)  (Math.abs(0) ça fait 0, et puis sauf si ton niveau d’alcool peut se retrouver dans le négatif (wtf ?!?) il n’a pas d’intérêt non plus dans la première condition).
                                Mais oui tu peux le remettre.

                                1 réponse Dernière réponse Répondre Citer 0
                                • GabsG Hors-ligne
                                  Gabs
                                  dernière édition par

                                  Bah sinon donne moi un autre code car mon non plus j’ai pas compris mdr je les trouvé sur internet

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • robin4002R Hors-ligne
                                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                    dernière édition par

                                    x)
                                    GG
                                    Le code que je t’ai donné fonctionne normalement.

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • GabsG Hors-ligne
                                      Gabs
                                      dernière édition par

                                      crash: at com.AltisMine.mod.AT.func_111207_a(AT.java:32)
                                      ligne 32:
                                      stack.getTagCompound().setInteger(“level”, prop.getAlcool());

                                      EDIT:
                                      C’est je crois que j’ai trouvé .

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • robin4002R Hors-ligne
                                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                        dernière édition par

                                        Rapport de crash complet ?

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • GabsG Hors-ligne
                                          Gabs
                                          dernière édition par

                                          –-- Minecraft Crash Report ----
                                          // I let you down. Sorry :(
                                          
                                          Time: 24/12/15 00:06
                                          Description: Unexpected error
                                          
                                          java.lang.NullPointerException: Unexpected error
                                          at com.AltisMine.mod.AT.func_111207_a(AT.java:32)
                                          at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:324)
                                          at net.minecraft.entity.player.EntityPlayer.func_70998_m(EntityPlayer.java:1135)
                                          at net.minecraft.client.multiplayer.PlayerControllerMP.func_78768_b(PlayerControllerMP.java:413)
                                          at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1431)
                                          at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1953)
                                          at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:973)
                                          at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:898)
                                          at net.minecraft.client.main.Main.main(SourceFile:148)
                                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                          at java.lang.reflect.Method.invoke(Method.java:483)
                                          at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                                          at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                          
                                          A detailed walkthrough of the error, its code path and all known details is as follows:
                                          ---------------------------------------------------------------------------------------
                                          
                                          -- Head --
                                          Stacktrace:
                                          at com.AltisMine.mod.AT.func_111207_a(AT.java:32)
                                          at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:324)
                                          at net.minecraft.entity.player.EntityPlayer.func_70998_m(EntityPlayer.java:1135)
                                          at net.minecraft.client.multiplayer.PlayerControllerMP.func_78768_b(PlayerControllerMP.java:413)
                                          at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1431)
                                          
                                          -- Affected level --
                                          Details:
                                          Level name: MpServer
                                          All players: 3 total; [MCH_ViewEntityDummy['McHeliDummyEntity'/14, l='MpServer', x=677,50, y=66,62, z=153,50], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=696,27, y=73,62, z=1097,51], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72]]
                                          Chunk stats: MultiplayerChunkCache: 71, 71
                                          Level seed: 0
                                          Level generator: ID 02 - largeBiomes, ver 0\. Features enabled: false
                                          Level generator options:
                                          Level spawn location: World: (677,64,153), Chunk: (at 5,4,9 in 42,9; contains blocks 672,0,144 to 687,255,159), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511)
                                          Level time: 275531588 game time, 102350000 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: survival (ID 0). Hardcore: false. Cheats: false
                                          Forced entities: 8 total; [EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=718,63, y=73,00, z=1186,53], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=699,27, y=72,71, z=1130,01], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=696,27, y=73,62, z=1097,51], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=746,45, y=72,62, z=1136,70], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=745,06, y=71,00, z=1134,88], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=739,08, y=73,12, z=1086,82]]
                                          Retry entities: 0 total; []
                                          Server brand: cauldron,craftbukkit,mcpc,fml,forge
                                          Server type: Non-integrated multiplayer server
                                          Stacktrace:
                                          at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:373)
                                          at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2444)
                                          at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:927)
                                          at net.minecraft.client.main.Main.main(SourceFile:148)
                                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                                          at java.lang.reflect.Method.invoke(Method.java:483)
                                          at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                                          at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                                          
                                          – System Details --
                                          Details:
                                          Minecraft Version: 1.7.10
                                          Operating System: Windows 7 (amd64) version 6.1
                                          Java Version: 1.8.0_25, Oracle Corporation
                                          Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                                          Memory: 626870992 bytes (597 MB) / 1430659072 bytes (1364 MB) up to 2134114304 bytes (2035 MB)
                                          JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
                                          AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                                          IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 103
                                          FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 Optifine OptiFine_1.7.10_HD_B7 23 mods loaded, 23 mods active
                                          States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                                          UCHIJA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
                                          UCHIJA FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1448-1.7.10.jar)
                                          UCHIJA Forge{10.13.4.1448} [Minecraft Forge] (forge-1.7.10-10.13.4.1448-1.7.10.jar)
                                          UCHIJA amm{1.0} [§aAltisMineMod] (AltisMineModV1.0(1.7.10).jar)
                                          UCHIJA BiblioCraft{1.9.0} [BiblioCraft] (BiblioCraft[v1.9.0][MC1.7.10].jar)
                                          UCHIJA AlcoholMod{1.5-Beta} [Alcohol Mod] (booze.jar)
                                          UCHIJA CarpentersBlocks{3.2.5} [Carpenter's Blocks] (Carpenters-Blocks-Mod-1.7.10.zip)
                                          UCHIJA chisel{1.5.7} [Chisel] (Chisel-1.7.10-1.5.7.jar)
                                          UCHIJA customnpcs{1.7.10c} [CustomNpcs] (CustomNPCs_1.7.10c.jar)
                                          UCHIJA PTRModelLib{1.0.0} [PTRModelLib] (Decocraft-2.1.1_1.7.10.jar)
                                          UCHIJA props{2.1.1} [Decocraft] (Decocraft-2.1.1_1.7.10.jar)
                                          UCHIJA Dynmap{2.2-143} [Dynmap] (Dynmap-2.2-forge-1.7.10.jar)
                                          UCHIJA flansmod{4.10.0} [Flan's Mod] (Flans Mod.jar)
                                          UCHIJA flenixcities{0.9.0} [FlenixCities] (FlenixCitiesCore_[1.7.10]-0.9.0.jar)
                                          UCHIJA mcheli{0.10.7} [MC Helicopter] (mcheli)
                                          UCHIJA Monoblocks{1.9.11} [§1M§2o§3n§4o§5b§6l§7o§8c§9k§as] (Monoblocks-1.9.11.jar)
                                          UCHIJA MonoblocksMultipart{1.9.11} [MonoblocksMultipart] (Monoblocks-1.9.11.jar)
                                          UCHIJA cfm{3.3.5} [§6MrCrayfish's Furniture Mod] (MrCrayfishs-Furniture-Mod-1.7.10.jar)
                                          UCHIJA MumbleLink{4.1.1-2b3035b} [MumbleLink for Forge] (MumbleLink-1.7.10-4.1.1-2b3035b.jar)
                                          UCHIJA ExtendedPASupport{1.0.0-2b3035b} [ExtendedPASupport for MumbleLink] (MumbleLink-1.7.10-4.1.1-2b3035b.jar)
                                          UCHIJA pseudoeraser{0.1} [Pseudo' Eraser] (Pseudo' Eraser v0.1 - 1.7.10.jar)
                                          UCHIJA RopesPlus{1.6.3} [Ropes+] (Ropes-Plus-Mod-1.7.10.jar)
                                          UCHIJA thirstmod{1.8.8} [Thirst Mod] (thirstmod-1.8.8.jar)
                                          Launched Version: 1.7.10-Forge10.13.4.1448-1.7.10
                                          LWJGL: 2.9.1
                                          OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 355.82, NVIDIA Corporation
                                          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)
                                          

                                          Au fait j’ai pas trouvé pour le crash.

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • robin4002R Hors-ligne
                                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                            dernière édition par

                                            Tu as enregistré ton ExtendedEntityPropAlcool ?

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 4 / 7
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB