MFF

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

    Création d'un mod client-side qui notifie son utilisateur quand son inventaire est full

    Planifier Épinglé Verrouillé Déplacé Non résolu Sans suite
    1.12.2
    45 Messages 4 Publieurs 1.9k Vues 3 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.
    • G Hors-ligne
      Gess1t
      dernière édition par Gess1t

      tout est dans la même class maintenant :

      package Gess.mod;
      
      import Gess.mod.proxy.iProxy;
      import net.minecraft.client.Minecraft;
      import net.minecraft.util.text.TextComponentString;
      import net.minecraftforge.fml.common.Mod;
      import net.minecraftforge.fml.common.Mod.EventHandler;
      import net.minecraftforge.fml.common.SidedProxy;
      import net.minecraftforge.fml.common.event.FMLInitializationEvent;
      import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
      import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
      import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
      import net.minecraftforge.fml.common.gameevent.TickEvent;
      import util.Reference;
      
      
      @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION)
      
      public class Main 
      {
      	public static Main instance;
      	
      	public static final String CLIENT = "gess.mod.proxy.ClientProxy";
      	public static final String SERVER = "gess.mod.proxy.CommonProxy";
      	@SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
      	public static iProxy proxy;
      	
      	@EventHandler
      	public void preInit(FMLPreInitializationEvent event){}
      	@EventHandler
      	public void init(FMLInitializationEvent event){}
      	@EventHandler
      	public void postInit(FMLPostInitializationEvent event){}
      	
      	public Main() {
      		
      		for(int i=0; i < 37; i++) {
      		if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) {
      			Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
      			return;
      			}
      		}
      		return;
      	}
      	@SubscribeEvent
      	public static void chkInv(TickEvent.ClientTickEvent event) {
      		if(Minecraft.getMinecraft().player != null) {
      			Minecraft.getMinecraft().player.sendMessage(new TextComponentString("you're ingame"));
      			Main main = new Main();
      			
      		}
      	}
      }
      

      j’éssaie de voir comment fix le problème de ticks maintenant

      FIXED les messages s’envoient je dois juste mettre du delay entre les message pour éviter un spam intensif :

      package Gess.mod;
      
      import Gess.mod.proxy.iProxy;
      import net.minecraft.client.Minecraft;
      import net.minecraft.util.text.TextComponentString;
      import net.minecraftforge.fml.common.Mod;
      import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
      import net.minecraftforge.fml.common.Mod.EventHandler;
      import net.minecraftforge.fml.common.SidedProxy;
      import net.minecraftforge.fml.common.event.FMLInitializationEvent;
      import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
      import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
      import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
      import net.minecraftforge.fml.common.gameevent.TickEvent;
      import net.minecraftforge.fml.relauncher.Side;
      import net.minecraftforge.fml.relauncher.SideOnly;
      import util.Reference;
      
      @EventBusSubscriber
      @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION)
      
      public class Main 
      {
      	public static Main instance;
      	
      	public static final String CLIENT = "gess.mod.proxy.ClientProxy";
      	public static final String SERVER = "gess.mod.proxy.CommonProxy";
      	@SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
      	public static iProxy proxy;
      	
      	@EventHandler
      	public void preInit(FMLPreInitializationEvent event){}
      	@EventHandler
      	public void init(FMLInitializationEvent event){}
      	@EventHandler
      	public void postInit(FMLPostInitializationEvent event){}
      	
      	public Main() {
      		
      	}
      	
      	@SubscribeEvent
      	public static void chkInv(TickEvent.ClientTickEvent event) throws InterruptedException {
      		if(Minecraft.getMinecraft().player != null) {
      			int s = 0;
      			for(int i=0; i < 37; i++) {
      				if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) {
      					s++;
      					if(s > 35) {
      					Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
      					return;
      					}
      					
      				}
      				
      			}
      			
      			return;
      
      		}
      	
      	}
      }
      

      le Seul truc que j’ai réussis à faire ces trois dernière heures c’est réussir à casser mon code, heuresement que j’ai la backup sur github^^ j’ai éssayer d’ajouter du délai entre chaque message et à chaque fois, plus aucun message apparaît.

      j’ai notamment éssayé de call la méthod pour mon TickHandler(TickEvent.ClientTickEvent event) mais dès que j’éssaie de call la méthode via une instance, plus rien.

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

        J’AI RIEN DIT! on peut utiliser getTotalWorldTime dans des method static apparement, ducoup ça marche! ya 10 secondes de délai entre chaques message, mais ducoup, quand la method est call avec full inv, il y a 2 messages qui apparaissent, je me demandais pourquoi.

        
        package Gess.mod;
        
        import Gess.mod.proxy.iProxy;
        import net.minecraft.client.Minecraft;
        import net.minecraft.util.text.TextComponentString;
        import net.minecraftforge.fml.common.Mod;
        import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
        import net.minecraftforge.fml.common.Mod.EventHandler;
        import net.minecraftforge.fml.common.SidedProxy;
        import net.minecraftforge.fml.common.event.FMLInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
        import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
        import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
        import net.minecraftforge.fml.common.gameevent.TickEvent;
        import net.minecraftforge.fml.relauncher.Side;
        import net.minecraftforge.fml.relauncher.SideOnly;
        import util.Reference;
        
        @EventBusSubscriber
        @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION)
        
        public class Main 
        {
        	public static Main instance;
        	
        	public static final String CLIENT = "gess.mod.proxy.ClientProxy";
        	public static final String SERVER = "gess.mod.proxy.CommonProxy";
        	@SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
        	public static iProxy proxy;
        	
        	@EventHandler
        	public void preInit(FMLPreInitializationEvent event){}
        	@EventHandler
        	public void init(FMLInitializationEvent event){}
        	@EventHandler
        	public void postInit(FMLPostInitializationEvent event){}
        	
        	public Main() {
        		
        	}
        	
        	@SubscribeEvent
        	public static void chkInv(TickEvent.ClientTickEvent event) throws InterruptedException {
        		if(Minecraft.getMinecraft().player != null) {
        			int s = 0;
        			for(int i=0; i < 37; i++) {
        				if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) {
        					s++;
        					if(s > 35) {
        						if(Minecraft.getMinecraft().world.getTotalWorldTime() % 300 == 3L ) {
        						Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
        						}
        						
        					}
        					
        				}
        				
        			}
        			
        			return;
        
        		}
        	
        	}
        	//@SideOnly(Side.CLIENT)
        	//public void TickhHandler(TickEvent.ClientTickEvent event) throws InterruptedException {
        	//wait(200);
        } 
        	
        //}
        
        

        j’ai update mon repo avec le code et une liste de choses que je doit encore faire avant de build et potentiellement release le mod

        1 réponse Dernière réponse Répondre Citer 0
        • isadorI Hors-ligne
          isador Moddeurs confirmés Modérateurs
          dernière édition par

          car tu teste en solo et que en solo tu es à la fois client et serveur

          G 1 réponse Dernière réponse Répondre Citer 0
          • G Hors-ligne
            Gess1t @isador
            dernière édition par Gess1t

            @isador34 nope, c’est aussi le cas sur server et puis le solo utilise aussi server.jar pour fonctionner

            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

              TickEvent.ClientTickEvent n’est qu’appelé sur le client donc il n’y a pas de problème de double appel client + serveur.

              Le problème vient du fait que l’event est appelé deux fois par phase, au début du tick et à la fin.
              Ajouter un if (event.phase == TickEvent.Phase.END) devrait régler le problème.

              isadorI G 2 réponses Dernière réponse Répondre Citer 0
              • isadorI Hors-ligne
                isador Moddeurs confirmés Modérateurs @robin4002
                dernière édition par

                @robin4002 Effectivement, j’avais oublié cette notion de phase

                1 réponse Dernière réponse Répondre Citer 0
                • G Hors-ligne
                  Gess1t @robin4002
                  dernière édition par Gess1t

                  @robin4002 a dit dans Création d'un mod client-side qui notifie son utilisateur quand son inventaire est full :

                  if (event.phase == TickEvent.Phase.END)

                  C’est fais, àa marche, mais ducoup je me demandais aussi pourquoi le jeu met autant de temps avant de redémarrer un autre check même si je l’ai pas déclanché une nouvelle fois depuis les 300 ticks expiré, c’est sensé être un clienttickEvent nan?
                  ce serais pas un problème d’ordes par hasard? si oui je crois savoir qu’il faut que je run mon délai pour attendre après avoir envoyé le message je supose?

                  Ma class actuellement

                  @SubscribeEvent
                  	public static void chkInv(TickEvent.ClientTickEvent event) throws InterruptedException {
                  		if(Minecraft.getMinecraft().player != null) {
                  			int s = 0;
                  			for(int i=0; i < 37; i++) {
                  				if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty() && Minecraft.getMinecraft()
                  						.player.inventory.getStackInSlot(i).getCount() == Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getMaxStackSize()) {
                  					s++;
                  					if(s > 35) {
                  						if(Minecraft.getMinecraft().world.getTotalWorldTime() % 240 == 3L && event.phase == TickEvent.Phase.END) {
                  						Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
                  						return;
                  						}
                  						
                  					}
                  					
                  				}
                  				
                  			}
                  			
                  			return;
                  

                  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 robin4002

                    L’event est toujours appelé à chaque tick. 300 tick c’est 12 secondes, tu es sûr que le message ne s’affiche pas toutes les 12 secondes ? (au passage tes return ne servent absolument à rien).

                    G 1 réponse Dernière réponse Répondre Citer 0
                    • G Hors-ligne
                      Gess1t @robin4002
                      dernière édition par Gess1t

                      @robin4002
                      je l’ai modifié, le message s’envois toutes les 12 secondes quand j’ai un inventaire plein, mais il faut attendre 12s quand je vais ingame pour que le premiers message apparaît, pareil quand je recupère un item au sol pour remplir l’inventaire, 12s après avoir recup l’item, le message est envoyé

                      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 robin4002

                        Vu comment ton code est fait c’est normal.

                        Il faudrait utiliser un boolean et mettre ceci sur false dès que le message est affiché et si elle est sur false lancer le compteur puis remettre sur true à la fin du compteur.

                        G 2 réponses Dernière réponse Répondre Citer 0
                        • G Hors-ligne
                          Gess1t @robin4002
                          dernière édition par Gess1t

                          @robin4002

                          ya une fonction pour detecter un message client side?
                          si c’est pas le cas au pire j’ai juste à utiliser une variable right?

                          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

                            Pourquoi tu veux une fonction pour ça ?
                            Tu as justement besoin d’une variable en effet.

                            1 réponse Dernière réponse Répondre Citer 0
                            • G Hors-ligne
                              Gess1t @robin4002
                              dernière édition par Gess1t

                              @robin4002 a dit dans Création d'un mod client-side qui notifie son utilisateur quand son inventaire est full :

                              Vu comment ton code est fait c’est normal.

                              Il faudrait utiliser un boolean et mettre ceci sur false dès que le message est affiché et si elle est sur false lancer le compteur puis remettre sur true à la fin du compteur.

                              donc je créer une bolean timer = true; au début de ma method chkInv, après mon message je met timer = !timer;
                              mais je suis sensé lancer le check comment si je ne peux pas lancer le compteur en dehors de la boucle if?
                              je suis sensé run if(Minecraft.getMinecraft().world.getTotalWorldTime() % 240 == 3L ) comme première commande? comme genre
                              :

                              EDIT: le message n’est plus déclenché donc j’ai ya un truc qui va pas, j’me relis 2s pour voir.
                              RE: je vois pas ce qui empêche le message de s’envoyer.
                              —> bon bas ma method n’a plus l’air de fonctionner dutout, pas d’errors, impossible de savoir d’où ça vient. même avec un manual undo

                              EDIT2: les backups, c’est la vie. ducoup ma class de backup marche, juste perdu la boolean.
                              quand j’ai supprimé la bolean et que j’ai remis la fonction worldgetTotalWorldTime() manuellement à sa place, le problème étais toujours là, donc aucune idée de pourquoi j’ai eu le problème d’avant.

                              @SubscribeEvent
                              	public static void chkInv(TickEvent.ClientTickEvent event) throws InterruptedException {
                              		
                              		boolean timer = false;
                              		if(Minecraft.getMinecraft().player != null ) {
                              			if(Minecraft.getMinecraft().world.getTotalWorldTime() % 200 == 3L && timer = false)
                              				int s = 0;
                              				for(int i=0; i < 37; i++) {
                              					if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty() && Minecraft.getMinecraft()
                              						.player.inventory.getStackInSlot(i).getCount() == Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getMaxStackSize()) {
                              						s++;
                              						if(s > 35) {
                              							if(event.phase == TickEvent.Phase.END && timer == false) {
                              								Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
                              								timer = !timer;
                              								return;
                              							}
                              						}
                              					return;
                              					}
                              				
                              				}
                              			
                              				
                              			}
                              			
                              			{
                              			return;
                              
                              		}
                              		
                              	}
                              

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

                                j’étais en train de créer mon fichier de config puis j’ai tenté de démarrer le jeu mais ça a crash et la ligne “if(cfg.haschanged()) {” en serait la cause
                                mon fichier config

                                public static void readConfig() {
                                		Configuration cfg = CommonProxy.config;
                                		try {
                                            cfg.load();
                                            initGeneralConfig(cfg);
                                        } finally {
                                            if (cfg.hasChanged()) {
                                                cfg.save();
                                            }
                                        }
                                    }
                                

                                le crash report :

                                net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Full Inventory Checker (fullinvchecker)
                                Caused by: java.lang.NullPointerException
                                	at Gess.mod.config.Config.readConfig(Config.java:21)
                                	at Gess.mod.Main.preInit(Main.java:41)
                                	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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:611)
                                	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
                                	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
                                	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
                                	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
                                	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
                                	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
                                	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
                                	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:253)
                                	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:231)
                                	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 com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
                                	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
                                	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
                                	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
                                	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
                                	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
                                	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
                                	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:148)
                                	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:604)
                                	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:266)
                                	at net.minecraft.client.Minecraft.init(Minecraft.java:508)
                                	at net.minecraft.client.Minecraft.run(Minecraft.java:416)
                                	at net.minecraft.client.main.Main.main(Main.java:118)
                                	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 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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
                                	at GradleStart.main(GradleStart.java:25)
                                

                                si jamais tu veux voir ma method preInit :
                                line 41 = Config.readConfig();

                                @EventHandler
                                	public void preInit(FMLPreInitializationEvent event){
                                		File directory = event.getModConfigurationDirectory();
                                        config = new Configuration(new File(directory.getPath(), "FullInventoryChecker.cfg"));
                                        Config.readConfig();
                                	}
                                

                                j’ai aussi éssayer de faire jouer un son du côté client avec Minecraft.getMinecraft().getSoundHandler().playSound(); mais ya une erreur dans mon code, quelque soit le code, j’ai éssayé de voir dans des exemples ou d’autres mods open source, mais ya rien qui marche

                                pour finir, je me demandais si dans

                                if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty() && Minecraft.getMinecraft()
                                				.player.inventory.getStackInSlot(i).getCount() == Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getMaxStackSize())
                                

                                je pouvais ajouter l’ID d’un item comme exception car sur certain serveurs comme hypixel skyblock ou wynncraft, ya une limite custom de stacks par items .

                                je vais passer par un else et ajouter les ID manuellement, et si j’arrive à faire fonctionner ce fichier de config, alors j’ajouterais un filtre d’exception. je n’arrive pas à trouver comment comparer le stack trouvé avec getStackInSlot avec un item genre mineccraft:head (je supose je dois utiliser getItem() mais ya aucun moyen de savoir comment elle marche)

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

                                  vu que j’avais plus de réponses sur ce forum, j’ai utilisé le forum officiel, puis j’ai fais une pause, car perdre son temps pour rien et pas spécialement mon truc, j’éssaye de faire marcher “e.entity” pour trouver un moyen de faire fonctionner le mod sur un serveur, le problème étant que “e.” ne marche pas, donc je me demandais à quoi ça correspondait.e.entity.PNG

                                  je viens de faire un texte et genre event.getEntityPlayer() et tous les autres arguments pour minecraft ne fonctionnent plus et remplacé par ça :
                                  Capture d’écran (587).png

                                  event.[autre argument en rapport avec mc] ne marche plus sur tous mes projets.

                                  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 quoi le contexte complet dans lequel se trouve ta variable event ?

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

                                      dans une methode test avec comme genre

                                      @SubscribeEvent
                                      public void test(TickEvent.ClientTickEvent event) {
                                      if(event.
                                      }
                                      

                                      et ya rien qui s’affiche alors que c’était le cas avant

                                      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

                                        TickEvent.ClientTickEvent est bien reconnu ?

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

                                          yep, sur mes autres methodes aussi

                                          Edit: pour ma méthode qui détecte client-side quand mon inventaire change (je cherche toujouts à la faire marcher):

                                          	private ItemStack[] previous;
                                          	private ItemStack[] now;
                                          	
                                          	@SubscribeEvent
                                          	public void PckUpItm(TickEvent.ClientTickEvent event) {
                                          		if(Minecraft.getMinecraft().player != null) {
                                          			EntityPlayer player = Minecraft.getMinecraft().player;
                                          			int g = 0;
                                          		for(int e=0; e < 36; e++) {
                                          			System.out.println("checking slot " + e);
                                          			ItemStack stack = player.inventory.getStackInSlot(e);
                                                      if(previous[e] != stack) {
                                          					if(!stack.isEmpty() && stack.getCount() == stack.getMaxStackSize()) {
                                          						g++;
                                          						System.out.println("g = " + g);
                                          						previous[e] = stack;
                                          						System.out.println("Itemstack " + e + "copied");
                                          						if(g > 34) {
                                          						Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
                                          						return;
                                          						
                                          					}
                                          				
                                                                         }
                                          				
                                          			}
                                          				
                                          		}
                                          					
                                          	}				
                                          
                                          }
                                          

                                          la méthode ne trigger même pas ingame, elle est sesné être déclenchée tous les ticks pourtant non?

                                          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

                                            Étrange, essaies de refaire un setup de la workspace ?

                                            Et pour l’event, vérifies que la classe d’event est bien enregistré.

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB