Jump to content

Show recipe items in a string when holding a certain button (item tooltip)


iiBlake
 Share

Recommended Posts

hello, I was recently playing a 1.6.4 modpack and saw ICBM has recipes in the lore when holding J (http://prntscr.com/cdkvwq). Is there any way I can do this in my mod? Getting the recipe for an itemStack, I already know how to do the lore based on keys held. I had a look in the CraftingManager class but found nothing that could help. Thanks for any help!

Link to comment
Share on other sites

I think what you're asking for is essentially an uncrafting method, right? Like you want to take an item that was crafted and know what could be used to craft it again?

 

Uncrafting is actually fairly complicated. I did work it out for 1.8 when I made an "uncrafting table" where you can put something in and get the ingredients out.

 

Here is the code repository where I did the deconstructor recipe analysis. Look at all the classes starting with "Deconstructing": https://github.com/jabelar/JadensMod/tree/master/src/main/java/com/blogspot/jabelarminecraft/blocksmith/recipes

 

The idea is that during post initialization of the mod (because I also want recipes from any other mod that is loaded), I use these classes once to go through the various crafting recipes and store their ingredients for future use.

 

If you look into the classes you'll see they require some tricky programming, because there are several different types of recipes.

 

One of the other things is that some crafting recipes produce more than 1 output. So you'll see that I have modes for my table that spread out the ingredients to be fair -- like you wouldn't want game to allow you to get more ingredients back than you used in the first place. In your case, if you just want to display the recipe, you might not care about that.

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Okay, i tried using the CraftingDeconstructor class, and I'm doing it like this:

	List<String> d = new ArrayList<String>();
	CraftingDeconstructor decon = new CraftingDeconstructor();

	ItemStack[] ingredients = decon.getDeconstructResults(item);

	for (ItemStack i : ingredients) {
		d.add(i.getUnlocalizedName());
	}

	return d;

But it is throwing a NPE in it:

 

 

[21:43:40] [Client thread/INFO] [sTDOUT]: [me.iiblake.testmod.CraftingDeconstructor:getDeconstructResults:24]: Looking for deconstructing a recipe for item.ballisticsGel

[21:43:40] [Client thread/INFO] [sTDOUT]: [me.iiblake.testmod.CraftingDeconstructor:getCraftingGrid:90]: getCraftingGrid for shapeless ore recipe with input array size = 1

[21:43:41] [server thread/INFO]: Stopping server

[21:43:41] [server thread/INFO]: Saving players

[21:43:41] [server thread/INFO]: Saving worlds

[21:43:41] [server thread/INFO]: Saving chunks for level 'New World'/Overworld

[21:43:41] [server thread/INFO]: Saving chunks for level 'New World'/Nether

[21:43:41] [server thread/INFO]: Saving chunks for level 'New World'/The End

[21:43:42] [server thread/INFO] [FML]: Unloading dimension 0

[21:43:42] [server thread/INFO] [FML]: Unloading dimension -1

[21:43:42] [server thread/INFO] [FML]: Unloading dimension 1

[21:43:42] [server thread/INFO] [FML]: Applying holder lookups

[21:43:42] [server thread/INFO] [FML]: Holder lookups applied

[21:43:42] [Client thread/FATAL]: Reported exception thrown!

net.minecraft.util.ReportedException: Rendering screen

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1168) ~[EntityRenderer.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1068) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_79]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_79]

at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

Caused by: java.lang.NullPointerException

at me.iiblake.testmod.items.ItemBallisticsGel.getTooltipStrings(ItemBallisticsGel.java:30) ~[itemBallisticsGel.class:?]

at me.iiblake.testmod.items.ItemBase.addInformation(ItemBase.java:17) ~[itemBase.class:?]

at net.minecraft.item.ItemStack.getTooltip(ItemStack.java:641) ~[itemStack.class:?]

at net.minecraft.client.gui.GuiScreen.renderToolTip(GuiScreen.java:124) ~[GuiScreen.class:?]

at net.minecraft.client.gui.inventory.GuiContainerCreative.renderToolTip(GuiContainerCreative.java:769) ~[GuiContainerCreative.class:?]

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:186) ~[GuiContainer.class:?]

at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44) ~[inventoryEffectRenderer.class:?]

at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:673) ~[GuiContainerCreative.class:?]

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137) ~[EntityRenderer.class:?]

... 11 more

[21:43:42] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----

// This doesn't make any sense!

 

Time: 3/09/16 9:43 PM

Description: Rendering screen

 

java.lang.NullPointerException: Rendering screen

at me.iiblake.testmod.items.ItemBallisticsGel.getTooltipStrings(ItemBallisticsGel.java:30)

at me.iiblake.testmod.items.ItemBase.addInformation(ItemBase.java:17)

at net.minecraft.item.ItemStack.getTooltip(ItemStack.java:641)

at net.minecraft.client.gui.GuiScreen.renderToolTip(GuiScreen.java:124)

at net.minecraft.client.gui.inventory.GuiContainerCreative.renderToolTip(GuiContainerCreative.java:769)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:186)

at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44)

at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:673)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1068)

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(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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 me.iiblake.testmod.items.ItemBallisticsGel.getTooltipStrings(ItemBallisticsGel.java:30)

at me.iiblake.testmod.items.ItemBase.addInformation(ItemBase.java:17)

at net.minecraft.item.ItemStack.getTooltip(ItemStack.java:641)

at net.minecraft.client.gui.GuiScreen.renderToolTip(GuiScreen.java:124)

at net.minecraft.client.gui.inventory.GuiContainerCreative.renderToolTip(GuiContainerCreative.java:769)

at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:186)

at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44)

at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:673)

 

-- Screen render details --

Details:

Screen name: net.minecraft.client.gui.inventory.GuiContainerCreative

Mouse location: Scaled: (283, 138). Absolute: (567, 202)

Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player406'/133, l='MpServer', x=1128.26, y=11.73, z=-82.05]]

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: (1140,4,280), Chunk: (at 4,0,8 in 71,17; contains blocks 1136,0,272 to 1151,255,287), Region: (2,0; contains chunks 64,0 to 95,31, blocks 1024,0,0 to 1535,255,511)

Level time: 131385 game time, 147096 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: 7 total; [EntityItem['item.item.arrow'/137, l='MpServer', x=1145.91, y=4.13, z=-113.56], EntityItem['item.item.rottenFlesh'/136, l='MpServer', x=1140.53, y=4.13, z=-78.91], EntitySpider['Spider'/139, l='MpServer', x=1167.41, y=4.00, z=-32.78], EntityItem['item.item.bone'/138, l='MpServer', x=1145.69, y=4.13, z=-112.91], EntityItem['item.item.rottenFlesh'/135, l='MpServer', x=1137.63, y=4.13, z=-105.00], EntityClientPlayerMP['Player406'/133, l='MpServer', x=1128.26, y=11.73, z=-82.05], EntityItem['item.item.rottenFlesh'/134, l='MpServer', x=1131.00, y=4.13, z=-107.81]]

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:2567)

at net.minecraft.client.Minecraft.run(Minecraft.java:983)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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)

 

 

Sorry if this is a basic mistake, I'm not sure what is making the error :/

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • This is my first time making a pack and i just wanted to add mods that i know or that look interesting. So When making the pack i get this error with Refined Storage https://pastebin.com/DxtTbVZW
    • Hello! When I'm trying to get items by tag during the recipe serialization, I'm getting an empty list. I have a guess that item tags're not loaded by the time minecraft loads my recipes. Here's my code: Class that saves information about ingredient's count Recipe serializer with some aux methods: Registry: Example of the json recipe file:  
    • I tried to install client forge on my linux desktop. But after "installation" it's missing forge[version].jar file in .minecraft/versions. I tried java 11 and 8 environment with same result. Here link to log file from installation: https://drive.google.com/file/d/1vtg9NT-WX5ilb1aNUvZlOv54gKWJuaT1/view?usp=share_link. I don't know what to do. I give for every directory permissions that I don't think that is issue. I will try check older versions if universal file work. Debian 11 (kernel 5.10)
    • I recently got error 1 in the launcher, so I restarted the .minecraft. After restarting it, I can't get the Forge 1.19.2 - 43.1.1 installer to run, I tried other versions and I get the same result, it opens a black box that closes instantly and nothing happens. I already tried to restart my pc, minecraft, update and reinstall java, run vanilla 1.19.2 and more recent versions of the game, disable Windows Firewall and antivirus and I still haven't solved it. Many times I installed forge and never ran into this problem. If I could receive assistance I would be very grateful.  
    • Here's the default loot table for gravel block: { "type": "minecraft:block", "pools": [ { "rolls": 1.0, "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:match_tool", "predicate": { "enchantments": [ { "enchantment": "minecraft:silk_touch", "levels": { "min": 1 } } ] } } ], "name": "minecraft:gravel" }, { "type": "minecraft:alternatives", "conditions": [ { "condition": "minecraft:survives_explosion" } ], "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:table_bonus", "enchantment": "minecraft:fortune", "chances": [ 0.1, 0.14285715, 0.25, 1.0 ] } ], "name": "minecraft:flint" }, { "type": "minecraft:item", "name": "minecraft:gravel" } ] } ] } ] } ] } This is a finicky loot table. If I add anything to it, nothing drops. I've added pools, entries, children ... you name it. Does anyone know the particulars about this table? I mean, periodically gravel drops flint instead of a gravel block. I understand the condition that could drop flint if the block survives an explosion. Otherwise, it drops the gravel block itself. I would like to further understand why the use of `children` and the set of `chance` values given in the explosion child entry. What I do understand is that `"type" : "minecraft:alternatives"` means that if this child/entry is successful, then it stops generating loot for this entry/pool. How often does the flint drop and is that taken care of in another location? Is that in a `"condition" : "minecraft:table_bonus"` loot table? Hmmm... I'll have to go take a look and see if there is something called table_bonus.json.
  • Topics

×
×
  • Create New...

Important Information

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