Résolu [1.7.10] Container sur un item
-
Bonjour, j’aimerais savoir comment créer un container sur un item en 1.7.10. J’ai déjà suivi le tutoriel du site mais lorsque que j’ouvre le container, mon jeu crash.
Merci.
-
Salut,
Tu as suivi ce tutoriel ? https://www.minecraftforgefrance.fr/topic/2015/créer-un-item-container-type-backpack-sac-à-dos
Quel est le crash que tu as ? (envoies un copier/coller du rapport). -
Oui j’ai suivi ce tutoriel.
Voici le rapport du crash :
---- Minecraft Crash Report ---- // Quite honestly, I wouldn't worry myself about that. Time: 30/03/19 19:13 Description: Unexpected error java.lang.NullPointerException: Unexpected error at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at fr.kraniax.arrow.proxy.ItemBackPack.onItemRightClick(ItemBackPack.java:23) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) at net.minecraft.client.Minecraft.run(Minecraft.java:962) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at fr.kraniax.arrow.proxy.ItemBackPack.onItemRightClick(ItemBackPack.java:23) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player585'/327, l='MpServer', x=-180,48, y=5,62, z=270,75]] Chunk stats: MultiplayerChunkCache: 165, 165 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (-173,4,278), Chunk: (at 3,0,6 in -11,17; contains blocks -176,0,272 to -161,255,287), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 8227 game time, 8227 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: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 166 total; [EntitySlime['Slime'/271, l='MpServer', x=-111,47, y=4,00, z=221,68], EntityCow['Cow'/15, l='MpServer', x=-260,63, y=4,00, z=228,22], EntityPig['Pig'/272, l='MpServer', x=-108,47, y=4,00, z=232,81], EntityChicken['Chicken'/273, l='MpServer', x=-111,81, y=4,00, z=241,28], EntitySheep['Sheep'/274, l='MpServer', x=-110,66, y=4,00, z=241,59], EntitySheep['Sheep'/275, l='MpServer', x=-108,13, y=4,00, z=254,56], EntitySlime['Slime'/20, l='MpServer', x=-258,50, y=4,00, z=269,06], EntitySlime['Slime'/277, l='MpServer', x=-109,39, y=4,00, z=274,00], EntitySlime['Slime'/278, l='MpServer', x=-104,23, y=4,00, z=299,03], EntitySheep['Sheep'/22, l='MpServer', x=-257,03, y=4,00, z=282,97], EntitySheep['Sheep'/279, l='MpServer', x=-104,13, y=4,00, z=324,66], EntitySheep['Sheep'/23, l='MpServer', x=-256,50, y=4,00, z=293,19], EntitySlime['Slime'/280, l='MpServer', x=-106,91, y=4,00, z=331,50], EntityChicken['Chicken'/24, l='MpServer', x=-259,28, y=4,00, z=289,97], EntitySlime['Slime'/281, l='MpServer', x=-110,78, y=4,00, z=324,00], EntitySlime['Slime'/6171, l='MpServer', x=-191,80, y=4,00, z=213,20], EntitySlime['Slime'/30, l='MpServer', x=-261,09, y=4,00, z=293,16], EntityXPOrb['Experience Orb'/292, l='MpServer', x=-84,50, y=4,26, z=314,05], EntityCow['Cow'/37, l='MpServer', x=-249,09, y=4,00, z=202,91], EntityXPOrb['Experience Orb'/293, l='MpServer', x=-81,50, y=4,35, z=318,98], EntityHorse['Horse'/38, l='MpServer', x=-248,41, y=4,00, z=214,91], EntityXPOrb['Experience Orb'/294, l='MpServer', x=-81,24, y=4,46, z=321,92], EntityHorse['Horse'/39, l='MpServer', x=-248,28, y=4,00, z=229,72], EntityChicken['Chicken'/40, l='MpServer', x=-242,94, y=4,00, z=228,06], EntityChicken['Chicken'/41, l='MpServer', x=-253,22, y=4,00, z=240,34], EntitySlime['Slime'/42, l='MpServer', x=-246,41, y=4,00, z=266,53], EntityPig['Pig'/43, l='MpServer', x=-244,50, y=4,00, z=280,75], EntityXPOrb['Experience Orb'/299, l='MpServer', x=-91,59, y=4,45, z=351,05], EntityHorse['Horse'/44, l='MpServer', x=-242,22, y=4,00, z=272,84], EntitySheep['Sheep'/45, l='MpServer', x=-244,50, y=4,00, z=279,50], EntitySheep['Sheep'/46, l='MpServer', x=-245,47, y=4,00, z=290,44], EntitySheep['Sheep'/47, l='MpServer', x=-253,78, y=4,00, z=301,84], EntitySheep['Sheep'/48, l='MpServer', x=-254,78, y=4,00, z=309,84], EntitySlime['Slime'/49, l='MpServer', x=-245,64, y=4,47, z=315,88], EntityChicken['Chicken'/53, l='MpServer', x=-238,66, y=4,00, z=214,44], EntityChicken['Chicken'/54, l='MpServer', x=-230,06, y=4,00, z=230,16], EntityHorse['Horse'/55, l='MpServer', x=-238,56, y=4,00, z=262,22], EntityPig['Pig'/56, l='MpServer', x=-225,88, y=4,00, z=271,31], EntityHorse['Horse'/57, l='MpServer', x=-227,97, y=4,00, z=271,88], EntitySlime['Slime'/58, l='MpServer', x=-229,09, y=4,80, z=266,13], EntitySheep['Sheep'/59, l='MpServer', x=-237,38, y=4,00, z=276,31], EntityPig['Pig'/60, l='MpServer', x=-233,88, y=4,00, z=282,34], EntityPig['Pig'/61, l='MpServer', x=-238,38, y=4,00, z=285,53], EntityChicken['Chicken'/62, l='MpServer', x=-225,47, y=4,00, z=342,53], EntitySlime['Slime'/65, l='MpServer', x=-213,14, y=4,00, z=268,34], EntitySlime['Slime'/66, l='MpServer', x=-219,74, y=4,31, z=330,81], EntityPig['Pig'/67, l='MpServer', x=-217,63, y=4,00, z=343,78], EntityCow['Cow'/69, l='MpServer', x=-201,47, y=4,00, z=241,47], EntitySlime['Slime'/70, l='MpServer', x=-202,25, y=4,00, z=266,66], EntitySlime['Slime'/71, l='MpServer', x=-197,93, y=5,05, z=289,85], EntityClientPlayerMP['Player585'/327, l='MpServer', x=-180,48, y=5,62, z=270,75], EntitySlime['Slime'/72, l='MpServer', x=-196,24, y=4,00, z=296,66], EntitySlime['Slime'/73, l='MpServer', x=-197,13, y=4,00, z=299,59], EntitySlime['Slime'/74, l='MpServer', x=-195,38, y=4,00, z=289,06], EntityPig['Pig'/75, l='MpServer', x=-199,72, y=4,00, z=349,28], EntityChicken['Chicken'/84, l='MpServer', x=-178,44, y=4,00, z=222,44], EntitySlime['Slime'/85, l='MpServer', x=-181,94, y=4,00, z=221,75], EntityCow['Cow'/86, l='MpServer', x=-185,75, y=4,00, z=233,78], EntityCow['Cow'/87, l='MpServer', x=-181,78, y=4,00, z=237,34], EntityCow['Cow'/88, l='MpServer', x=-183,59, y=4,00, z=223,23], EntityCow['Cow'/89, l='MpServer', x=-187,28, y=4,00, z=224,44], EntityHorse['Horse'/90, l='MpServer', x=-184,50, y=4,00, z=252,19], EntitySlime['Slime'/91, l='MpServer', x=-189,24, y=4,00, z=245,53], EntitySheep['Sheep'/92, l='MpServer', x=-177,16, y=4,00, z=267,84], EntitySlime['Slime'/93, l='MpServer', x=-192,66, y=4,00, z=283,59], EntityXPOrb['Experience Orb'/94, l='MpServer', x=-184,59, y=4,25, z=296,45], EntityXPOrb['Experience Orb'/95, l='MpServer', x=-186,96, y=4,25, z=287,59], EntityArrow['arrow'/96, l='MpServer', x=-178,09, y=4,00, z=319,28], EntitySlime['Slime'/97, l='MpServer', x=-183,08, y=4,00, z=306,41], EntitySlime['Slime'/98, l='MpServer', x=-190,19, y=4,00, z=316,91], EntityChicken['Chicken'/99, l='MpServer', x=-188,41, y=4,00, z=328,66], EntitySlime['Slime'/100, l='MpServer', x=-177,42, y=4,00, z=326,48], EntitySlime['Slime'/101, l='MpServer', x=-180,06, y=4,69, z=341,45], EntitySlime['Slime'/111, l='MpServer', x=-174,42, y=4,00, z=212,25], EntityChicken['Chicken'/112, l='MpServer', x=-164,81, y=4,00, z=224,81], EntitySlime['Slime'/113, l='MpServer', x=-170,16, y=4,69, z=232,61], EntityPig['Pig'/114, l='MpServer', x=-164,44, y=4,00, z=253,78], EntityChicken['Chicken'/115, l='MpServer', x=-168,47, y=4,00, z=252,47], EntityArrow['arrow'/116, l='MpServer', x=-174,50, y=4,00, z=249,59], EntitySlime['Slime'/117, l='MpServer', x=-168,51, y=4,00, z=242,00], EntitySlime['Slime'/118, l='MpServer', x=-162,09, y=4,00, z=247,43], EntityPig['Pig'/119, l='MpServer', x=-172,50, y=4,00, z=244,97], EntitySlime['Slime'/120, l='MpServer', x=-174,69, y=4,00, z=284,93], EntityArrow['arrow'/121, l='MpServer', x=-170,44, y=4,00, z=292,13], EntityArrow['arrow'/122, l='MpServer', x=-169,38, y=4,00, z=292,56], EntityArrow['arrow'/123, l='MpServer', x=-173,28, y=4,00, z=291,75], EntityArrow['arrow'/124, l='MpServer', x=-161,44, y=4,00, z=294,06], EntityArrow['arrow'/125, l='MpServer', x=-162,53, y=4,00, z=300,09], EntityArrow['arrow'/126, l='MpServer', x=-160,44, y=4,00, z=303,06], EntityXPOrb['Experience Orb'/127, l='MpServer', x=-160,59, y=4,25, z=302,15], EntityXPOrb['Experience Orb'/128, l='MpServer', x=-159,90, y=4,25, z=302,25], EntitySlime['Slime'/130, l='MpServer', x=-164,22, y=4,00, z=342,69], EntitySlime['Slime'/131, l='MpServer', x=-174,28, y=4,00, z=337,88], EntityPig['Pig'/137, l='MpServer', x=-155,84, y=4,00, z=212,59], EntityArrow['arrow'/138, l='MpServer', x=-148,00, y=4,00, z=255,50], EntityPig['Pig'/139, l='MpServer', x=-159,72, y=4,00, z=257,50], EntityXPOrb['Experience Orb'/140, l='MpServer', x=-152,56, y=4,25, z=268,55], EntityXPOrb['Experience Orb'/141, l='MpServer', x=-144,34, y=4,25, z=271,69], EntitySlime['Slime'/142, l='MpServer', x=-149,47, y=4,00, z=266,75], EntityXPOrb['Experience Orb'/143, l='MpServer', x=-144,49, y=4,25, z=273,59], EntityXPOrb['Experience Orb'/144, l='MpServer', x=-144,50, y=4,25, z=271,80], EntityXPOrb['Experience Orb'/145, l='MpServer', x=-152,88, y=4,25, z=275,40], EntityXPOrb['Experience Orb'/146, l='MpServer', x=-154,23, y=4,25, z=275,38], EntityArrow['arrow'/147, l='MpServer', x=-144,38, y=4,04, z=287,41], EntityXPOrb['Experience Orb'/148, l='MpServer', x=-152,83, y=4,25, z=287,56], EntityXPOrb['Experience Orb'/149, l='MpServer', x=-152,69, y=4,25, z=291,56], EntityXPOrb['Experience Orb'/150, l='MpServer', x=-155,63, y=4,25, z=291,56], EntityArrow['arrow'/151, l='MpServer', x=-146,72, y=4,05, z=288,09], EntityArrow['arrow'/152, l='MpServer', x=-147,10, y=4,05, z=288,13], EntityArrow['arrow'/153, l='MpServer', x=-158,88, y=4,00, z=289,72], EntityXPOrb['Experience Orb'/154, l='MpServer', x=-151,34, y=4,25, z=287,42], EntityArrow['arrow'/155, l='MpServer', x=-158,94, y=4,00, z=290,16], EntityArrow['arrow'/156, l='MpServer', x=-159,16, y=4,00, z=290,69], EntityArrow['arrow'/157, l='MpServer', x=-157,66, y=4,04, z=302,47], EntityArrow['arrow'/158, l='MpServer', x=-155,13, y=4,05, z=301,10], EntityArrow['arrow'/159, l='MpServer', x=-144,06, y=4,05, z=305,60], EntityArrow['arrow'/160, l='MpServer', x=-150,38, y=4,00, z=326,13], EntitySlime['Slime'/161, l='MpServer', x=-145,88, y=4,00, z=332,28], EntitySlime['Slime'/162, l='MpServer', x=-146,00, y=4,00, z=322,88], EntitySlime['Slime'/163, l='MpServer', x=-157,04, y=4,00, z=339,09], EntityChicken['Chicken'/166, l='MpServer', x=-138,44, y=4,00, z=242,44], EntityItem['item.item.slimeball'/167, l='MpServer', x=-128,19, y=4,13, z=270,31], EntityXPOrb['Experience Orb'/168, l='MpServer', x=-128,53, y=4,25, z=266,87], EntityXPOrb['Experience Orb'/169, l='MpServer', x=-129,38, y=4,25, z=281,07], EntityXPOrb['Experience Orb'/170, l='MpServer', x=-132,74, y=4,31, z=280,75], EntityItem['item.item.slimeball'/171, l='MpServer', x=-130,91, y=4,13, z=280,91], EntityXPOrb['Experience Orb'/172, l='MpServer', x=-131,54, y=4,25, z=272,91], EntitySlime['Slime'/173, l='MpServer', x=-134,87, y=4,00, z=283,00], EntityItem['item.item.slimeball'/174, l='MpServer', x=-136,59, y=4,13, z=296,41], EntityArrow['arrow'/175, l='MpServer', x=-143,06, y=4,05, z=299,10], EntityArrow['arrow'/176, l='MpServer', x=-143,09, y=4,04, z=299,38], EntityArrow['arrow'/177, l='MpServer', x=-143,44, y=4,00, z=308,16], EntityArrow['arrow'/178, l='MpServer', x=-143,47, y=4,00, z=309,25], EntityXPOrb['Experience Orb'/179, l='MpServer', x=-141,31, y=4,25, z=309,55], EntityXPOrb['Experience Orb'/180, l='MpServer', x=-141,22, y=4,52, z=314,59], EntityXPOrb['Experience Orb'/181, l='MpServer', x=-131,43, y=4,25, z=329,67], EntityArrow['arrow'/182, l='MpServer', x=-130,00, y=4,00, z=330,00], EntityArrow['arrow'/183, l='MpServer', x=-130,50, y=4,00, z=329,22], EntityArrow['arrow'/184, l='MpServer', x=-130,09, y=4,00, z=328,31], EntityArrow['arrow'/185, l='MpServer', x=-131,59, y=4,00, z=328,78], EntityArrow['arrow'/186, l='MpServer', x=-131,75, y=4,00, z=329,78], EntityArrow['arrow'/187, l='MpServer', x=-131,16, y=4,00, z=333,81], EntityArrow['arrow'/189, l='MpServer', x=-133,00, y=4,00, z=333,03], EntityArrow['arrow'/190, l='MpServer', x=-133,97, y=4,00, z=332,56], EntityArrow['arrow'/191, l='MpServer', x=-133,81, y=4,00, z=331,13], EntityArrow['arrow'/192, l='MpServer', x=-133,25, y=4,00, z=330,50], EntityArrow['arrow'/193, l='MpServer', x=-133,56, y=4,00, z=331,13], EntityArrow['arrow'/194, l='MpServer', x=-135,06, y=4,00, z=334,22], EntitySlime['Slime'/204, l='MpServer', x=-139,94, y=4,00, z=341,63], EntitySlime['Slime'/205, l='MpServer', x=-141,76, y=4,00, z=338,73], EntitySlime['Slime'/236, l='MpServer', x=-122,81, y=4,00, z=207,69], EntityChicken['Chicken'/237, l='MpServer', x=-119,30, y=4,00, z=232,36], EntityPig['Pig'/238, l='MpServer', x=-119,34, y=4,00, z=236,06], EntitySheep['Sheep'/239, l='MpServer', x=-115,84, y=4,00, z=234,84], EntitySlime['Slime'/240, l='MpServer', x=-121,71, y=4,00, z=234,12], EntityChicken['Chicken'/241, l='MpServer', x=-115,72, y=4,00, z=252,72], EntityPig['Pig'/242, l='MpServer', x=-113,31, y=4,00, z=244,50], EntitySheep['Sheep'/243, l='MpServer', x=-114,66, y=4,00, z=241,19], EntitySlime['Slime'/244, l='MpServer', x=-119,38, y=4,00, z=279,25], EntitySlime['Slime'/245, l='MpServer', x=-123,58, y=4,00, z=286,66], EntitySlime['Slime'/246, l='MpServer', x=-128,94, y=4,00, z=311,03], EntitySlime['Slime'/247, l='MpServer', x=-112,84, y=4,00, z=307,97], EntityXPOrb['Experience Orb'/248, l='MpServer', x=-131,00, y=4,30, z=333,11], EntityXPOrb['Experience Orb'/249, l='MpServer', x=-112,32, y=4,25, z=331,50], EntityXPOrb['Experience Orb'/250, l='MpServer', x=-115,43, y=4,25, z=335,54], EntitySlime['Slime'/251, l='MpServer', x=-113,63, y=4,80, z=336,56]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) at net.minecraft.client.Minecraft.run(Minecraft.java:991) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_191, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 781970872 bytes (745 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA arrow{1.0.0} [Arrow] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 398.11' Renderer: 'GeForce GTX 1050/PCIe/SSE2' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 398.11, 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)
-
L’instance de ton mod est probablement null.
Vérifies que l’annotation@Instance
se trouve bien juste au-dessus de l’instance du mod et que le modid correspond. -
Voici aussi le code :
package fr.kraniax.arrow.proxy.item; import cpw.mods.fml.common.registry.GameRegistry; import fr.kraniax.arrow.Reference; import fr.kraniax.arrow.proxy.ItemBackPack; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class ItemArrow { public static Item compoundBow; public static Item quiver; public static void init() { compoundBow = new CompoundBow().setUnlocalizedName("compound_bow").setCreativeTab(CreativeTabs.tabCombat).setTextureName(Reference.MODID + ":compound_bow"); quiver = new ItemBackPack().setUnlocalizedName("quiver").setCreativeTab(CreativeTabs.tabCombat); } public static void GameRegistry() { GameRegistry.registerItem(compoundBow, "compound_bow"); GameRegistry.registerItem(quiver, "quiver"); } public static final void registerItemsCrafts() {} }
package fr.kraniax.arrow.proxy.item; import cpw.mods.fml.common.registry.GameRegistry; import fr.kraniax.arrow.Reference; import fr.kraniax.arrow.proxy.ItemBackPack; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class ItemArrow { public static Item compoundBow; public static Item quiver; public static void init() { compoundBow = new CompoundBow().setUnlocalizedName("compound_bow").setCreativeTab(CreativeTabs.tabCombat).setTextureName(Reference.MODID + ":compound_bow"); quiver = new ItemBackPack().setUnlocalizedName("quiver").setCreativeTab(CreativeTabs.tabCombat); } public static void GameRegistry() { GameRegistry.registerItem(compoundBow, "compound_bow"); GameRegistry.registerItem(quiver, "quiver"); } public static final void registerItemsCrafts() {} }
package fr.kraniax.arrow.proxy; import cpw.mods.fml.common.registry.GameRegistry; import fr.kraniax.arrow.Main; import fr.kraniax.arrow.Reference; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemBackPack extends Item{ public static final String NAME = "quiver"; public ItemBackPack() { this.maxStackSize = 1; } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { player.openGui(Main.instance, 0, world, (int) player.posX, (int) player.posY, (int) player.posZ); return stack; } /** * @param stack * ItemStack used * @param held * true if the player is holding this item */ @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {} }
package fr.kraniax.arrow.proxy; import fr.kraniax.arrow.Reference; import fr.kraniax.arrow.proxy.item.ItemArrow; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants; public class InventoryBackPack implements IInventory { public ItemStack[] content; public int size; public InventoryBackPack(ItemStack container, int size) { this.size = size; this.content = new ItemStack[size]; if (!container.hasTagCompound()) container.setTagCompound(new NBTTagCompound()); this.readFromNBT(container.getTagCompound()); } /** * This methods reads the content of the NBTTagCompound inside the container * * @param comp the container NBTTagCompound */ public void readFromNBT(NBTTagCompound comp) { NBTTagList nbtlist = comp.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < nbtlist.tagCount(); i++) { NBTTagCompound comp1 = nbtlist.getCompoundTagAt(i); int slot = comp1.getInteger("Slot"); this.content[slot] = ItemStack.loadItemStackFromNBT(comp1); } } /** * This methods saves the content inside the container * * @param comp the NBTTagCompound to write in */ public void writeToNBT(NBTTagCompound comp) { NBTTagList nbtlist = new NBTTagList(); for (int i = 0; i < this.size; i++) { if (this.content[i] != null) { NBTTagCompound comp1 = new NBTTagCompound(); comp1.setInteger("Slot", i); this.content[i].writeToNBT(comp1); nbtlist.appendTag(comp1); } } comp.setTag("Inventory", nbtlist); } @Override public int getSizeInventory() { return this.size; } @Override public ItemStack getStackInSlot(int index) { return this.content[index]; } @Override public ItemStack decrStackSize(int index, int amount) { ItemStack stack = getStackInSlot(index); if (stack != null) { if (stack.stackSize > amount) { stack = stack.splitStack(amount); if (stack.stackSize == 0) this.content[index] = null; } else { this.content[index] = null; } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = getStackInSlot(index); if (stack != null) this.content[index] = null; return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { this.content[index] = stack; } @Override public String getInventoryName() { return Reference.MODID + ".container.backpack"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() {} @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return !(stack.getItem() instanceof ItemBackPack && !(stack.getItem() == ItemArrow.quiver)); } }
package fr.kraniax.arrow.proxy; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotBackPack extends Slot{ public SlotBackPack(IInventory inv, int index, int x, int y) { super(inv, index, x, y); } /** * Method used to prevent backpack-ception (backpacks inside backpacks) */ @Override public boolean isItemValid(ItemStack stack) { return !(stack.getItem() instanceof ItemBackPack); } }
package fr.kraniax.arrow.proxy; import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class CommonProxy implements IGuiHandler{ public void registerRenders() { } public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 9)); } return null; } public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 9)); } return null; } }
package fr.kraniax.arrow.proxy; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GuiBackPack extends GuiContainer{ public static final ResourceLocation texture = new ResourceLocation("textures/gui/container/quiver.png"); protected InventoryBackPack inv; protected InventoryPlayer playerInv; public int rows; public GuiBackPack(InventoryPlayer playerInv, InventoryBackPack inv) { super(new ContainerBackPack(playerInv, inv)); this.playerInv = playerInv; this.inv = inv; this.allowUserInput = false; this.rows = inv.getSizeInventory() / 9; this.ySize = 114 + this.rows * 18; } @Override protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { this.fontRendererObj.drawString(I18n.format(this.inv.getInventoryName(), new Object[0]), 8, 6, 4210752); this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float prt, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.rows * 18 + 17); this.drawTexturedModalRect(k, l + this.rows * 18 + 17, 0, 126, this.xSize, 96); } }
package fr.kraniax.arrow.proxy; import fr.kraniax.arrow.proxy.item.ItemArrow; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ContainerBackPack extends Container{ public InventoryBackPack invBackpack; public boolean needsUpdate; public int rows; public ContainerBackPack(InventoryPlayer playerInv, InventoryBackPack inv) { this.invBackpack = inv; this.rows = inv.getSizeInventory() / 9; int i = (this.rows - 4) * 18; int j; int k; for (j = 0; j < this.rows; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new SlotBackPack(inv, k + j * 9, 8 + k * 18, 18 + j * 18)); } } for (j = 0; j < 3; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 161 + i)); } } @Override public boolean canInteractWith(EntityPlayer player) { return player.getHeldItem() != null && player.getHeldItem().getItem() == ItemArrow.quiver; } public void writeToNBT(ItemStack stack) { if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); invBackpack.writeToNBT(stack.getTagCompound()); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); // Prevents backpack-ception (backpack inside backpack) with shift-click if (itemstack.getItem() instanceof ItemBackPack) return null; if (index < this.invBackpack.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.invBackpack.getSizeInventory(), this.inventorySlots.size(), true)) return null; } else if (!this.mergeItemStack(itemstack1, 0, this.invBackpack.getSizeInventory(), false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); this.needsUpdate = true; } } return itemstack; } /** * @param buttonPressed left click, right click, wheel click, etc. * @param flag category (e.g.: hotbar keys) */ @Override public ItemStack slotClick(int slotIndex, int buttonPressed, int flag, EntityPlayer player) { // Prevents from removing current backpack if (flag == 2 && buttonPressed == player.inventory.currentItem) return null; if (slotIndex - this.invBackpack.getSizeInventory() - 27 == player.inventory.currentItem) return null; this.needsUpdate = true; return super.slotClick(slotIndex, buttonPressed, flag, player); } @Override public void onContainerClosed(EntityPlayer player) { this.writeToNBT(player.getHeldItem()); super.onContainerClosed(player); } }
-
package fr.kraniax.arrow; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import fr.kraniax.arrow.proxy.CommonProxy; import fr.kraniax.arrow.proxy.item.ItemArrow; @Mod(modid = Reference.MODID, name = Reference.MOD_NAME, version = Reference.VERSION) public class Main { @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; @Instance("arrow") public static Main instance; @EventHandler public void preInit(FMLPreInitializationEvent e) { ItemArrow.init(); ItemArrow.GameRegistry(); } @EventHandler public void init(FMLInitializationEvent e) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
Je crois que mon instance est juste. Mon modid est bien juste.
-
Reference.MODID a bien comme valeur “arrow” ?
Si oui, le problème c’est que ton gui handler n’est pas enregistré. -
Oui “arrow” est bien mon MODID. Comment peut-on enregistré mon gui handler ? Faut-il que j’instancie la classe Common Proxy (Gui Handler) ? Si oui, comment ?
-
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new TonGuiHandler());
-
C’est bon, ça marche. Merci de m’avoir aider.
Voici le code :
package fr.kraniax.arrow; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; import fr.kraniax.arrow.item.ItemArrow; import fr.kraniax.arrow.proxy.CommonProxy; import net.minecraft.server.MinecraftServer; @Mod(modid = Reference.MODID, name = Reference.MOD_NAME, version = Reference.VERSION) public class Main { @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; @Mod.Instance(Reference.MODID) public static Main instance; @EventHandler public void preInit(FMLPreInitializationEvent e) { ItemArrow.init(); ItemArrow.GameRegistry(); proxy.registerRenders(); } @EventHandler public void init(FMLInitializationEvent e) { proxy.registerRenders(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); } @EventHandler public void postInit(FMLPostInitializationEvent e) { } }
package fr.kraniax.arrow.item; import cpw.mods.fml.common.registry.GameRegistry; import fr.kraniax.arrow.Reference; import fr.kraniax.arrow.item.quiver.ItemQuiver; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class ItemArrow { public static Item compoundBow; public static Item quiver; public static void init() { compoundBow = new CompoundBow().setUnlocalizedName("compound_bow").setCreativeTab(CreativeTabs.tabCombat).setTextureName(Reference.MODID + ":compound_bow"); quiver = new ItemQuiver().setUnlocalizedName("quiver").setCreativeTab(CreativeTabs.tabCombat).setTextureName(Reference.MODID + ":quiver"); } public static void GameRegistry() { GameRegistry.registerItem(compoundBow, "compound_bow"); GameRegistry.registerItem(quiver, "quiver"); } }
package fr.kraniax.arrow.proxy; import cpw.mods.fml.common.network.IGuiHandler; import fr.kraniax.arrow.item.quiver.ContainerQuiver; import fr.kraniax.arrow.item.quiver.GuiQuiver; import fr.kraniax.arrow.item.quiver.InventoryQuiver; import fr.kraniax.arrow.item.quiver.ItemQuiver; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class CommonProxy implements IGuiHandler{ public void registerRenders() { } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54) // Condition to check if the player has the right item in hand if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemQuiver)) return null; return new ContainerQuiver(player.inventory, new InventoryQuiver(player.getHeldItem(), 54)); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54) // Condition to check if the player has the right item in hand if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemQuiver)) return null; return new GuiQuiver(player.inventory, new InventoryQuiver(player.getHeldItem(), 54)); } return null; } }
package fr.kraniax.arrow.item.quiver; import fr.kraniax.arrow.Reference; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants; public class InventoryQuiver implements IInventory { public ItemStack[] content; public int size; public InventoryQuiver(ItemStack container, int size) { this.size = size; this.content = new ItemStack[size]; if (!container.hasTagCompound()) container.setTagCompound(new NBTTagCompound()); this.readFromNBT(container.getTagCompound()); } /** * This methods reads the content of the NBTTagCompound inside the container * * @param comp the container NBTTagCompound */ public void readFromNBT(NBTTagCompound comp) { NBTTagList nbtlist = comp.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < nbtlist.tagCount(); i++) { NBTTagCompound comp1 = nbtlist.getCompoundTagAt(i); int slot = comp1.getInteger("Slot"); this.content[slot] = ItemStack.loadItemStackFromNBT(comp1); } } /** * This methods saves the content inside the container * * @param comp the NBTTagCompound to write in */ public void writeToNBT(NBTTagCompound comp) { NBTTagList nbtlist = new NBTTagList(); for (int i = 0; i < this.size; i++) { if (this.content[i] != null) { NBTTagCompound comp1 = new NBTTagCompound(); comp1.setInteger("Slot", i); this.content[i].writeToNBT(comp1); nbtlist.appendTag(comp1); } } comp.setTag("Inventory", nbtlist); } @Override public int getSizeInventory() { return this.size; } @Override public ItemStack getStackInSlot(int index) { return this.content[index]; } @Override public ItemStack decrStackSize(int index, int amount) { ItemStack stack = getStackInSlot(index); if (stack != null) { if (stack.stackSize > amount) { stack = stack.splitStack(amount); if (stack.stackSize == 0) this.content[index] = null; } else { this.content[index] = null; } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = getStackInSlot(index); if (stack != null) this.content[index] = null; return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { this.content[index] = stack; } @Override public String getInventoryName() { return Reference.MODID + ".container.backpack"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() {} @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return !(stack.getItem() instanceof ItemQuiver); } }
package fr.kraniax.arrow.item.quiver; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GuiQuiver extends GuiContainer{ public static final ResourceLocation texture = new ResourceLocation("arrow", "textures/gui/container/generic_54.png"); protected InventoryQuiver inv; protected InventoryPlayer playerInv; public int rows; public GuiQuiver(InventoryPlayer playerInv, InventoryQuiver inv) { super(new ContainerQuiver(playerInv, inv)); this.playerInv = playerInv; this.inv = inv; this.allowUserInput = false; this.rows = inv.getSizeInventory() / 9; this.ySize = 114 + this.rows * 18; } @Override protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { this.fontRendererObj.drawString(I18n.format(this.inv.getInventoryName(), new Object[0]), 8, 6, 4210752); this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float prt, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.rows * 18 + 17); this.drawTexturedModalRect(k, l + this.rows * 18 + 17, 0, 126, this.xSize, 96); } }
package fr.kraniax.arrow.item.quiver; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ContainerQuiver extends Container{ public InventoryQuiver invBackpack; public boolean needsUpdate; public int rows; public ContainerQuiver(InventoryPlayer playerInv, InventoryQuiver inv) { this.invBackpack = inv; this.rows = inv.getSizeInventory() / 9; int i = (this.rows - 4) * 18; int j; int k; for (j = 0; j < this.rows; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new SlotQuiver(inv, k + j * 9, 8 + k * 18, 18 + j * 18)); } } for (j = 0; j < 3; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 161 + i)); } } @Override public boolean canInteractWith(EntityPlayer player) { return true; } public void writeToNBT(ItemStack stack) { if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); invBackpack.writeToNBT(stack.getTagCompound()); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); // Prevents backpack-ception (backpack inside backpack) with shift-click if (itemstack.getItem() instanceof ItemQuiver) return null; if (index < this.invBackpack.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.invBackpack.getSizeInventory(), this.inventorySlots.size(), true)) return null; } else if (!this.mergeItemStack(itemstack1, 0, this.invBackpack.getSizeInventory(), false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); this.needsUpdate = true; } } return itemstack; } /** * @param buttonPressed left click, right click, wheel click, etc. * @param flag category (e.g.: hotbar keys) */ @Override public ItemStack slotClick(int slotIndex, int buttonPressed, int flag, EntityPlayer player) { // Prevents from removing current backpack if (flag == 2 && buttonPressed == player.inventory.currentItem) return null; if (slotIndex - this.invBackpack.getSizeInventory() - 27 == player.inventory.currentItem) return null; this.needsUpdate = true; return super.slotClick(slotIndex, buttonPressed, flag, player); } @Override public void onContainerClosed(EntityPlayer player) { this.writeToNBT(player.getHeldItem()); super.onContainerClosed(player); } }
package fr.kraniax.arrow.item.quiver; import cpw.mods.fml.common.registry.GameRegistry; import fr.kraniax.arrow.Main; import fr.kraniax.arrow.Reference; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemQuiver extends Item{ public static final String NAME = "quiver"; public ItemQuiver() { this.maxStackSize = 1; } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { player.openGui(Main.instance, 0, world, (int) player.posX, (int) player.posY, (int) player.posZ); return stack; } /** * @param stack * ItemStack used * @param held * true if the player is holding this item */ @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) {} }
package fr.kraniax.arrow.item.quiver; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotQuiver extends Slot{ public SlotQuiver(IInventory inv, int index, int x, int y) { super(inv, index, x, y); } /** * Method used to prevent backpack-ception (backpacks inside backpacks) */ @Override public boolean isItemValid(ItemStack stack) { return !(stack.getItem() instanceof ItemQuiver); } }