Nombre d'items dans l'inventaire
-
Robin -> euh oui, je me suis trompé de sujet : internet explorer sur windows phone fait un peu de la merde.
Rajoute des logs pour savoir si à chaque fois le slot est vide.
-
Voila, j’ai modifié de cette façon:
for (int i = 0; i < bank.getSizeInventory(); i++) { else if (bank.getStackInSlot(i) != null && bank.getStackInSlot(i).getItem() == Items.emerald) { bankEmeraldNumber += (bank.getStackInSlot(i).stackSize); System.out.println("Item: " + i); } else { System.out.println("No: " + i); } }
Et sur la console, je n’est que des no:
:::
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 0
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 1
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 2
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 3
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 4
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 5
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 6
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 7
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 8
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 9
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 10
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 11
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 12
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 13
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 14
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 15
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 16
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 17
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 18
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 19
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 20
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 21
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 22
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 23
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 24
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 25
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 26
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 0
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 1
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 2
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 3
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 4
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 5
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 6
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 7
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 8
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 9
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 10
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 11
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 12
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 13
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 14
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 15
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 16
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 17
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 18
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 19
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 20
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 21
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 22
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 23
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 24
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 25
[22:43:04] [Client thread/INFO] [STDOUT]: [com.plasmania.wynnplus.events.EventManager:renderEmeraldsNumber:60]: No: 26
::: -
Oui visiblement le contenu est toujours null.
Je ne sais pas d’où ça vient.
Il faudrait pouvoir lire la liste directement dans le tag du joueur, pas sûr que cela soit possible. -
Salut, j’ai fait ça mais problème : vois is an invalid type for the variable renderArgent :S
package fr.altiscraft.altiscraft.common; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; public class EventManager { public ItemStack Argent = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(3); public int size = 0; InventoryPlayer inv = Minecraft.getMinecraft().thePlayer.inventory; { for (int i = 0; i < inv.getSizeInventory(); i++) { if (inv.getStackInSlot(i) != null && inv.getStackInSlot(i).getItem() == Items.emerald) size += inv.getStackInSlot(i).stackSize; } @SubscribeEvent public void renderArgent(RenderGameOverlayEvent event) { if(event.type == ElementType.JUMPBAR || event.type == ElementType.EXPERIENCE) { Minecraft.getMinecraft().fontRenderer.drawString("Argent porté : " + Argent, 2, 2, 0xFFFFFF); } } } }
-
Merci de ne pas up les posts des autres si ce n’est pas pour apporter une solution.
Créé plutôt une autre discussion.
Également apprends la programmation en Java, car si tu ne connaissais au moins les bases tu n’aurai jamais fait ce que tu as fait (ton code est complètement faux, tu appelles des fonctions sans être dans une fonction)