Jump to content

Recommended Posts

Posted
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.

Posted

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

Posted
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.

Posted
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

Posted (edited)
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 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.

Posted

[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
 

Posted

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.

  • Like 1

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.

Posted
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.

  • Like 1

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.

Posted

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

Posted

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?

Posted

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?

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.