Jump to content

Recommended Posts

Posted
for (Item item : ForgeRegistries.ITEMS) {
  IRecipe<?> iRecipe = world.getRecipeManager().getRecipe(Objects.requireNonNull(item.getRegistryName())).orElse(null);
  if (iRecipe != null) {
    // get ingredients ...
  }

 

I'm using the above function to get the recipes of items that have been registered referencing ForgeRegistries. This is successful and I'm able to get the ingredients for a smelting recipe for example, for all vanilla items; however, getRecipes() returns null when item belongs to my mod. There are recipes for smelting/blasting those items and work with a normal furnace/blast furnace in-game yet don't return a IRecipe<?> like the vanilla items do.

 

Just trying to figure out what I'm missing that Minecraft/Forge implements that I don't to get a null return and not valid IRecipe<?>

 

Any help to this would be much appreciated and any pointers to where to further look would be appreciated as well.

Posted
1 hour ago, diesieben07 said:

This doesn't make sense. This is getting a recipe with the same name as an item.

Not only that, but registry names CAN'T be null, so "require non-null" is useless.

 

Now...where are my recipe utils...

Hm, not updated since 1.12, but might give some insight.

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/util/RecipesUtils.java#L164

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Sorry, was trying to be a bit more general for all applications. It's for a custom smelter so currently how it works as just a quickly thrown together system is that when the tile entity is loaded into the world it executed the function, as shown above, and adds the ingredient and result to a map that I then iterate over if the contents for the 0th slot (input slot) are changed and gets corresponding result from the ingredient if it's in that map.

 

I was trying to find a way if I could get a recipe output from the ingredient that's placed inside first, which is how a crafting table works (I believe), but hadn't had any success with trying to implement that so went with the function I showed above and have it only execute once which is upon the tile being placed into the world once it has loaded from the mod starting up.

 

It's apparent that this isn't the greatest way to implement the system but was struggling to find resources on how it should be implemented.

 

 

1 hour ago, diesieben07 said:

RecipeManager#getRecipe(IRecipeType, C, World)

If I placed cobblestone into the input slot, would this then return stone if I fetch its smelting/blasting recipe? If so that'd be what I'm looking for, and assuming by what you said this is the case. This would also remove the need to load all recipes on the tile entity being loaded which is just a bodge solution to the scenario.

 

Do I need world or just call RecipeManager?

 

 

26 minutes ago, Draco18s said:

Not only that, but registry names CAN'T be null, so "require non-null" is useless.

It's IntelliJ's Lint for doing that. It's pretty clear that this is indeed the case so I don't understand why it needs to be flagged but I guess IntelliJ isn't that intelligent.

 

 

28 minutes ago, Draco18s said:

Thanks for the reference, just took brief look at it. It's a bit annoying trying to get what the replacement methods and functions are from 1.12 to 1.14/1.15 as CraftingManager doesn't exist but I'll try to implement something similar along with what Diesie suggested.

 

 

Thanks in advance as well with what has been suggested.

Posted
1 hour ago, Blu_Nighttime said:

Thanks for the reference, just took brief look at it. It's a bit annoying trying to get what the replacement methods and functions are from 1.12 to 1.14/1.15 as CraftingManager doesn't exist but I'll try to implement something similar along with what Diesie suggested.

Yeah, its changed, but the info is still there somewhere.

I just haven't updated it because the portion of my mod that relied on it I haven't re-written yet. So its been low priority.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So I've implemented the following statement to be as similar to what's in AbstractFurnaceTileEntity#tick 

IRecipe<?> irecipe = world.getRecipeManager().getRecipe(IRecipeType.SMELTING, this, world).orElse(null);

My tile entity class now implements ISidedInventory like AbstractTileEntity does but now I only ever receive null. Should the param this actually reference my container class for the block or am I missing something else?

 

If I should be referencing the container class, how would I go about doing that to satisfy the inventoryIn param?

Posted
1 hour ago, Blu_Nighttime said:

My tile entity class now implements ISidedInventory like AbstractTileEntity does but now I only ever receive null. Should the param this actually reference my container class for the block or am I missing something else?

Don't. Get rid of ISidedInventory and use ItemStackHandler fields instead.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/SifterTileEntity.java#L39

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/entity/SifterTileEntity.java#L147

 

I don't deal with recipes in the same way the furnace does, but that's how you use ItemStackHandlers. The output wrapper is a custom ItemStackWrapper class that accepts another in its constructor and prevents insertion, so that it can be exposed via getCapability to allow extraction, but the original stack handler can still modified by the machine itself.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Thanks for the examples, shows me some options on how I might be able to restructure my class if needs be in the future.

 

However, I'm failing to understand what I'm passing into getRecipe() that satisfies C as the inventoryIn as the second parameter. the input slot for the custom smelter is an ItemStackHandler but passing this isn't allowed and I'm not sure if it's something that needs casting/converting to something else or what that would mean that C is satisfied.

Any knowledge on this is greatly appreciated.

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 seems to have fixed it, thank you!
    • I am having some issues starting an RLCraft server on a minimal install of Debian 12. I have Java installed and I'm able to start the vanilla Minecraft server jar no problem and people can join and play without any issues, as soon as I try to create a new directory with the Forge jar the initial install with the INSTALLER jar works when I use the java command with the --installServer flag, but as soon as I try to start the server using the forge jar that is NOT labelled with installer I get the following error: A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:569)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more   I have tried using newer versions of Java directly from Oracle as well. Has anybody been successful in starting and running a RLCraft server from the terminal on a Linux machine? I cannot figure out why it doesn't want to work but the vanilla jar works without issue. Thank you in advance!
    • This is my latest attempt :  public class ManaScreen extends Screen { Mana mana = new Mana(); boolean removeManaBar = false; ResourceLocation manaBar = ResourceLocation.fromNamespaceAndPath(RSGArmoury.MOD_ID, "/textures/block/spawnable_arena_wall.png"); public ManaScreen() { super(Component.literal("Mana")); } @Override protected void init() { super.init(); Minecraft.getInstance().setScreen(this); } @Override public boolean isPauseScreen() { return false; } @Override public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { pGuiGraphics.blit(manaBar, 10, -10, 0, 0, mana.getMana(), 10, mana.getMana(), 10); if (removeManaBar) { this.onClose(); return; } super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); } public void addManaBar() { removeManaBar = false; Minecraft.getInstance().setScreen(new ManaScreen()); } public boolean removeManaBar() { return removeManaBar = true; } }
    • I tried a few different things that all didnt work. Right now I have nothing but what I had that seemed most likely to work was just a guiOverlay.blit(x, y, z, vx, vy, getMana()). I dont remember the exact code but it was somthing along those lines. It was in a new class extending screen I believe.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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