February 4, 20178 yr 31 minutes ago, Villfuk02 said: But there are capabilities for storing items, fluids and energy, but i need to just store some ints bools doubles and some fields so what? So you create your own. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
February 4, 20178 yr Author Can you please translete this to english for me? In general terms, a capability is declared and registered through a single method call to CapabilityManager.INSTANCE.register(). One possibility is to define a static register()method inside a dedicated class for the capability, but this is not required by the capability system. For the purpose of this documentation we will be describing each part as a separate named class, although anonymous classes are an option. CapabilityManager.INSTANCE.register(capability interface class, storage, default implementation factory); The first parameter to this method, is the type that describes the capability feature. In our example, this will be IExampleCapability.class. The second parameter is an instance of a class that implements Capability.IStorage<T>, where T is the same class we specified in the first parameter. This storage class will help manage saving and loading for the default implementation, and it can, optionally, also support other implementations. private static class Storage implements Capability.IStorage<IExampleCapability> { @Override public NBTBase writeNBT(Capability<IExampleCapability> capability, IExampleCapability instance, EnumFacing side) { // return an NBT tag } @Override public void readNBT(Capability<IExampleCapability> capability, IExampleCapability instance, EnumFacing side, NBTBase nbt) { // load from the NBT tag } } The last parameter is a callable factory that will return new instances of the default implementation. private static class Factory implements Callable<IExampleCapability> { @Override public IExampleCapability call() throws Exception { return new Implementation(); } } Finally, we will need the default implementation itself, to be able to instantiate it in the factory. Designing this class is up to you, but it should at least provide a basic skeleton that people can use to test the capability, if it’s not a fully usable implementation on itself. thanks
February 4, 20178 yr 40 minutes ago, Villfuk02 said: Can you please translete this to english for me? No. I suggest you look up any terms you don't understand and look at examples in Forge's code. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
February 4, 20178 yr Author Ok i have something now, is there a way to set some of the values when is the item crafted? Different materials - different values
February 4, 20178 yr Author Also, it doesn't work ¯\_(ツ)_/¯ IDK what am i doing wrong, because i don't understand it properly
February 4, 20178 yr 50 minutes ago, Villfuk02 said: I BROKE MY DETECTOR HALP We CANNOT help you if you show us nothing and complain about something is broke.. 0 code, your github hasn't been updated for a day, so I'm guessing its out of date. Take some time and think about what your doing and please get github working... It has great integration with IDEA and its easy to setup.. Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
February 5, 20178 yr 10 hours ago, Villfuk02 said: Ok i have something now, is there a way to set some of the values when is the item crafted? Different materials - different values Either set those values on the ItemStack before you add a recipe for it or create your own recipe class and set them in IRecipe#getCraftingResult. Edited February 5, 20178 yr by Choonster Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
February 5, 20178 yr Author Ok, updated my GitHub https://github.com/Villfuk02/Archeology Edited February 5, 20178 yr by Villfuk02
February 5, 20178 yr Author it crashes when it tries to interact with the Capability i added for example when i use the item
February 5, 20178 yr Author [15:43:30] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: ---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 2/5/17 3:43 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error at vms.archeology.items.Detector.onItemUse(Detector.java:102) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) at net.minecraft.client.Minecraft.run(Minecraft.java:407) 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:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at vms.archeology.items.Detector.onItemUse(Detector.java:102) at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:486) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player774'/1, l='MpServer', x=4.01, y=6.00, z=12.36]] Chunk stats: MultiplayerChunkCache: 81, 81 Level seed: 0 Level generator: ID 01 - flat, ver 0. Features enabled: false Level generator options: Level spawn location: World: (8,4,8), Chunk: (at 8,0,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 69924 game time, 69924 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: 1 total; [EntityPlayerSP['Player774'/1, l='MpServer', x=4.01, y=6.00, z=12.36]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774) at net.minecraft.client.Minecraft.run(Minecraft.java:436) 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:26) -- System Details -- Details: Minecraft Version: 1.11.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_111, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1888181704 bytes (1800 MB) / 2130051072 bytes (2031 MB) up to 2130051072 bytes (2031 MB) JVM Flags: 3 total; -Xincgc -Xmx2048M -Xms2048M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.38 Powered by Forge 13.20.0.2210 6 mods loaded, 6 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA minecraft{1.11.2} [Minecraft] (minecraft.jar) UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.0.2210.jar) UCHIJAAAA forge{13.20.0.2210} [Minecraft Forge] (forgeSrc-1.11.2-13.20.0.2210.jar) UCHIJAAAA archeology{0.0.0 (Alpha)} [Archeology] (bin) UCHIJAAAA jei{4.2.2.215} [Just Enough Items] (jei_1.11.2-4.2.2.215.jar) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 369.09' Renderer: 'GeForce GT 610/PCIe/SSE2' Launched Version: 1.11.2 LWJGL: 2.9.4 OpenGL: GeForce GT 610/PCIe/SSE2 GL version 4.5.0 NVIDIA 369.09, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes 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) CPU: 2x Pentium(R) Dual-Core CPU E5700 @ 3.00GHz [15:43:31] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:600]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Villfuk\Desktop\ancient\run\.\crash-reports\crash-2017-02-05_15.43.30-client.txt AL lib: (EE) alc_cleanup: 1 device not closed Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
February 5, 20178 yr What is line 102 from your Detector class? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 5, 20178 yr Author look at GitHub detector.setFound(false); basicly the first line, where it tries to do something with the Capability
February 5, 20178 yr You never register CapabilityHandler on the Forge event bus, so CapabiltiyHandler#attachCapability is never called and the capability is never attached to any ItemStack. What diesieben07 said also applies, though. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
February 5, 20178 yr Try using an if statement to test if they have the capability before trying to use it...? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 5, 20178 yr Author And should i call initCapabilities in constructor, or override it, or call it form somewhere else?
February 5, 20178 yr 6 minutes ago, Villfuk02 said: And should i call initCapabilities in constructor, or override it, or call it form somewhere else? Override it. Forge will call it when required, you don't call it yourself. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
February 5, 20178 yr Author ok, works, thanks Now how do i make it so, when i craft the item, the capability has different values depending on the crafting recipe? Basically i set the valuses when is the item crafted
February 5, 20178 yr Author someBODY once told me you can set NBT for itemStack in the crafting recipe, if it's true, i could just read from NBT and set the values from it. Is it possible?
February 5, 20178 yr Author i made it so different recipes make different NBT public static NBTTagCompound generateNBT(int coil, int display, int rod, int battery){ NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("coil", coil); nbt.setInteger("display", display); nbt.setInteger("rod", rod); nbt.setInteger("battery", battery); return nbt; } public static void registerCraftingRecipes() { GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(1, 1, 1, 1)), new Object[] {"ingotIron", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(2, 2, 2, 2)), new Object[] {"ingotGold", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModTools.metal_detector, 1, 0, generateNBT(3, 3, 3, 3)), new Object[] {Blocks.OBSIDIAN, "chest"})); } (the recipes are just placeholders) but the item allways has the default values how do i make it read from the NBT and save it to the capability?
February 5, 20178 yr Author thx, did it like this: public static ItemStack generateDetector(int coil, int display, int rod, int battery){ ItemStack stack = new ItemStack(ModTools.metal_detector); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setCoil(coil); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setDisplay(display); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setRod(rod); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setBattery(battery); return stack; } public static void registerCraftingRecipes() { GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(1, 1, 1, 1), new Object[] {"ingotIron", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(2, 2, 2, 2), new Object[] {"ingotGold", "chest"})); GameRegistry.addRecipe(new ShapelessOreRecipe(generateDetector(3, 3, 3, 7), new Object[] {Blocks.OBSIDIAN, "chest"})); } now, what if i want to be able to replace parts of the detector like if i put in crafting detector and coil, i'll get detector same as the one i put there, but with different coil how can i do this else than making a recipe for every detector-part combination?
February 5, 20178 yr Author Ok, i made this: @SubscribeEvent public void handleAnvilEvent(AnvilUpdateEvent evt) { ItemStack stack = evt.getLeft(); if(stack.equals(ModTools.metal_detector)){ if (evt.getRight().equals(Items.DYE)){ if(evt.getRight().getMetadata() < 7) evt.setCost(4); stack.getCapability(DetectorProvider.DETECTOR_CAP, null).setBattery(evt.getRight().getMetadata() + 1); evt.setOutput(stack); } } } but it does just nothing am i supposed to register it somewhere, or set something to true, or something? i couldn't find the solution myself
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.