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 @robin4002
      dernière édition par

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

      Faut faire comment les inventaires, utiliser des non null list.
      NonNullList<ItemStack> previous = NonNullList.withSize(player.inventory.getSizeInventory(), ItemStack.EMPTY);

      Faudra adapter le reste du code.

      Quels genres d’adaptation?

      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

        Les array et les listes ne s’utilisent pas de la même manière.
        array[0] -> premier élément d’une array
        list.get(0) -> premier élément d’une liste

        Donc c’est ce genre de truc qu’il faut adapter.

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

          @robin4002

          donc la ligne que tu ma donné est une liste, pas un array, ducoup je dosi utiliser previous(e) et pas previous[e]

          edit:

          et pour associer un itemstack à un slot de la liste, je peut :

          previous.set(e,stack);

          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

            previous.get(e)

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

              package Gess.mod;
              
              import Gess.mod.proxy.iProxy;
              import net.minecraft.client.Minecraft;
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.inventory.Container;
              import net.minecraft.inventory.ContainerPlayer;
              import net.minecraft.item.ItemStack;
              import net.minecraft.util.NonNullList;
              import net.minecraft.util.text.TextComponentString;
              import net.minecraftforge.common.config.Configuration;
              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 util.Reference;
              @EventBusSubscriber
              @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION)
              
              public class Main 
              {
              	public static Configuration config;
              	//public static int time = 10;
              	public static Main instance; 
              	//float lastMessageTime = 0;
              	public boolean inventoryIsFull;
              	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 e){
              		 //File directory = event.getModConfigurationDirectory();
                       //config = new Configuration(new File(directory.getPath(), "FullInventoryChecker.cfg"));
                       //Config.readConfig();
              	}
              	@EventHandler
              	public void init(FMLInitializationEvent e){}
              	
              	@EventHandler
              	public void postInit(FMLPostInitializationEvent e){
              		// if (config.hasChanged()) 
                      //    config.save();
              		//}
              	}
              	
              	public void log() {
              		System.out.println("Does PckUpItm actually output anything?");
              	}
              
              	private EntityPlayer playerEntity;
              	final EntityPlayer player = (EntityPlayer)Minecraft.getMinecraft().player;
                  private boolean enabled = true;
              	private NonNullList<ItemStack> previous;
              	
                  @SubscribeEvent
              	public void PckUpItm(final TickEvent.ClientTickEvent event) {
              		if(Minecraft.getMinecraft().player != null) {
              	        this.playerEntity = player;
              	        if (enabled == true) {
              	            NonNullList<ItemStack> previous = NonNullList.withSize(player.inventory.getSizeInventory(), ItemStack.EMPTY);
              	            enabled = false;
              	        }
              			Main pui = new Main();
              			pui.log();
              			EntityPlayer player = Minecraft.getMinecraft().player;
              			int g = 0;
              			System.out.println("starting to count e");
              		for(int e=0; e < 36; e++) {
              			System.out.println("checking slot " + e);
              			ItemStack stack = player.inventory.getStackInSlot(e);
                          if(ItemStack.areItemStacksEqual(previous.get(e), stack)) {
                          	previous.set(e,stack);	
                          	if(!stack.isEmpty() && stack.getCount() == stack.getMaxStackSize()) {
              						g++;
              						System.out.println("g = " + g);
              						System.out.println("Itemstack " + e + "copied");
              						if(g > 34) {
              						Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
              						return;
              						
              					}
              				}
              				
              			}
              				
              		}
              					
              	}				
              
              }
              
              	
              	@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() % 200 == 3L && event.phase == TickEvent.Phase.END) {
              						Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
              						System.out.println("chkInv: Triggerred with s = " + s);
              						return;
              						}
              						
              					}
              				
              				}
              				
              			}
              			
              			return;
              					
              		}
              		
              	}
              	
              
              }
              

              après éssaie, toujours le même problème de timeout:

              [21:01:37] [main/INFO] [GradleStart]: Extra: []
              [21:01:37] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/[user]/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
              [21:01:38] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
              [21:01:38] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
              [21:01:38] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
              [21:01:38] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
              [21:01:38] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2768 for Minecraft 1.12.2 loading
              [21:01:38] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_212, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jre1.8.0_212
              [21:01:38] [main/ERROR] [FML]: Apache Maven library folder was not in the format expected. Using default libraries directory.
              [21:01:38] [main/ERROR] [FML]: Full: C:\Users\[user]\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-artifact\3.5.3\7dc72b6d6d8a6dced3d294ed54c2cc3515ade9f4\maven-artifact-3.5.3.jar
              [21:01:38] [main/ERROR] [FML]: Trimmed: c:/users/[user]/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact/3.5.3/
              [21:01:38] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
              [21:01:38] [main/INFO] [FML]: Detected deobfuscated environment, loading log configs for colored console logs.
              2019-10-20 21:01:40,811 main WARN Disabling terminal, you're running in an unsupported environment.
              [21:01:40] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin), we are in deobf and it's a forge core plugin
              [21:01:40] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin), we are in deobf and it's a forge core plugin
              [21:01:41] [main/INFO] [FML]: Searching D:\Modding\Minecraft\FullinventorycheckerRenewal\run\.\mods for mods
              [21:01:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
              [21:01:41] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
              [21:01:41] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
              [21:01:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
              [21:01:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
              [21:01:41] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
              [21:01:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
              [21:01:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
              [21:01:41] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
              [21:01:44] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
              [21:01:44] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
              [21:01:44] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
              [21:01:45] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
              [21:01:45] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
              [21:01:45] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
              [21:01:45] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
              [21:01:47] [main/INFO] [minecraft/Minecraft]: Setting user: Player431
              [21:01:56] [main/WARN] [minecraft/GameSettings]: Skipping bad option: lastServer:
              [21:01:56] [main/INFO] [minecraft/Minecraft]: LWJGL Version: 2.9.4
              [21:01:57] [main/INFO] [FML]: -- System Details --
              Details:
              	Minecraft Version: 1.12.2
              	Operating System: Windows 8.1 (amd64) version 6.3
              	Java Version: 1.8.0_212, Oracle Corporation
              	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
              	Memory: 852327856 bytes (812 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
              	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
              	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
              	FML: 
              	Loaded coremods (and transformers): 
              	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 431.60' Renderer: 'GeForce GT 1030/PCIe/SSE2'
              [21:01:57] [main/INFO] [FML]: MinecraftForge v14.23.5.2768 Initialized
              [21:01:57] [main/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients.
              [21:01:58] [main/INFO] [FML]: Replaced 1036 ore ingredients
              [21:01:59] [main/INFO] [FML]: Searching D:\Modding\Minecraft\FullinventorycheckerRenewal\run\.\mods for mods
              [21:02:03] [main/INFO] [FML]: Forge Mod Loader has identified 5 mods to load
              [21:02:04] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, fullinvchecker] at CLIENT
              [21:02:04] [main/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, fullinvchecker] at SERVER
              [21:02:05] [Thread-3/INFO] [FML]: Using alternative sync timing : 200 frames of Display.update took 6157975628 nanos
              [21:02:05] [main/INFO] [minecraft/SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Full Inventory Checker
              [21:02:06] [main/INFO] [FML]: Processing ObjectHolder annotations
              [21:02:06] [main/INFO] [FML]: Found 1168 ObjectHolder annotations
              [21:02:06] [main/INFO] [FML]: Identifying ItemStackHolder annotations
              [21:02:06] [main/INFO] [FML]: Found 0 ItemStackHolder annotations
              [21:02:06] [main/INFO] [FML]: Configured a dormant chunk cache size of 0
              [21:02:06] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
              [21:02:06] [main/INFO] [FML]: Applying holder lookups
              [21:02:06] [main/INFO] [FML]: Holder lookups applied
              [21:02:06] [main/INFO] [FML]: Applying holder lookups
              [21:02:06] [main/INFO] [FML]: Holder lookups applied
              [21:02:06] [main/INFO] [FML]: Applying holder lookups
              [21:02:06] [main/INFO] [FML]: Holder lookups applied
              [21:02:06] [main/INFO] [FML]: Applying holder lookups
              [21:02:06] [main/INFO] [FML]: Holder lookups applied
              [21:02:06] [main/INFO] [FML]: Injecting itemstacks
              [21:02:06] [main/INFO] [FML]: Itemstack injection complete
              [21:02:07] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Found status: UP_TO_DATE Target: null
              [21:02:14] [Sound Library Loader/INFO] [minecraft/SoundManager]: Starting up SoundSystem...
              [21:02:14] [Thread-5/INFO] [minecraft/SoundManager]: Initializing LWJGL OpenAL
              [21:02:14] [Thread-5/INFO] [minecraft/SoundManager]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
              [21:02:14] [Thread-5/INFO] [minecraft/SoundManager]: OpenAL initialized.
              [21:02:15] [Sound Library Loader/INFO] [minecraft/SoundManager]: Sound engine started
              [21:02:26] [main/INFO] [FML]: Max texture size: 16384
              [21:02:27] [main/INFO] [minecraft/TextureMap]: Created: 512x512 textures-atlas
              [21:02:33] [main/INFO] [FML]: Applying holder lookups
              [21:02:33] [main/INFO] [FML]: Holder lookups applied
              [21:02:33] [main/INFO] [FML]: Injecting itemstacks
              [21:02:33] [main/INFO] [FML]: Itemstack injection complete
              [21:02:33] [main/INFO] [FML]: Forge Mod Loader has successfully loaded 5 mods
              [21:02:33] [main/WARN] [minecraft/GameSettings]: Skipping bad option: lastServer:
              [21:02:33] [main/INFO] [mojang/NarratorWindows]: Narrator library for x64 successfully loaded
              [21:02:36] [Realms Notification Availability checker #1/INFO] [mojang/RealmsClient]: Could not authorize you against Realms server: Invalid session id
              [21:03:52] [main/INFO] [minecraft/GuiConnecting]: Connecting to localhost, 25565
              [21:03:52] [Server Connector #1/ERROR] [minecraft/GuiConnecting]: Couldn't connect to server
              java.lang.NullPointerException: group
              	at io.netty.bootstrap.AbstractBootstrap.group(AbstractBootstrap.java:84) ~[AbstractBootstrap.class:?]
              	at net.minecraft.network.NetworkManager.createNetworkManagerAndConnect(NetworkManager.java:367) ~[NetworkManager.class:?]
              	at net.minecraft.client.multiplayer.GuiConnecting$1.run(GuiConnecting.java:68) [GuiConnecting$1.class:?]
              [21:03:54] [main/INFO] [minecraft/GuiConnecting]: Connecting to localhost, 25565
              [21:03:55] [Netty Client IO #1/INFO] [FML]: Aborting client handshake "VANILLA"
              [21:03:55] [Netty Client IO #1/INFO] [FML]: [Netty Client IO #1] Client side vanilla connection established
              [21:04:20] [Netty Client IO #1/ERROR] [FML]: NetworkDispatcher exception
              java.io.IOException: Une connexion existante a dû être fermée par l’hôte distant
              	at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_212]
              	at sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[?:1.8.0_212]
              	at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[?:1.8.0_212]
              	at sun.nio.ch.IOUtil.read(Unknown Source) ~[?:1.8.0_212]
              	at sun.nio.ch.SocketChannelImpl.read(Unknown Source) ~[?:1.8.0_212]
              	at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) ~[PooledUnsafeDirectByteBuf.class:4.1.9.Final]
              	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) ~[AbstractByteBuf.class:4.1.9.Final]
              	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) ~[NioSocketChannel.class:4.1.9.Final]
              	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [AbstractNioByteChannel$NioByteUnsafe.class:4.1.9.Final]
              	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624) [NioEventLoop.class:4.1.9.Final]
              	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559) [NioEventLoop.class:4.1.9.Final]
              	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) [NioEventLoop.class:4.1.9.Final]
              	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) [NioEventLoop.class:4.1.9.Final]
              	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:4.1.9.Final]
              	at java.lang.Thread.run(Unknown Source) [?:1.8.0_212]
              [21:04:21] [main/INFO] [FML]: Applying holder lookups
              [21:04:21] [main/INFO] [FML]: Holder lookups applied
              [21:04:32] [main/INFO] [minecraft/GuiConnecting]: Connecting to localhost, 25565
              [21:04:32] [Netty Client IO #2/INFO] [FML]: Aborting client handshake "VANILLA"
              [21:04:32] [Netty Client IO #2/INFO] [FML]: [Netty Client IO #2] Client side vanilla connection established
              [21:04:45] [main/INFO] [minecraft/Minecraft]: Stopping!
              [21:04:52] [main/INFO] [minecraft/SoundManager]: SoundSystem shutting down...
              [21:04:52] [main/WARN] [minecraft/SoundManager]: Author: Paul Lamb, www.paulscode.com
              Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
              
              
              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