Jump to content

[1.12.1] Crafting Manager not Working properly


ResaloliPT

Recommended Posts

Hello there,

 

Im trying to get my Custom Workbench to work but without sucess, i can craft my on recipes on the whole grid wherever i place (Shapeless), but when i try with vanilla recipes it only works on the upper left corner 3x3 of my 5x5 grid.

 

All my code is available at github HERE

 

At attachments i have some images of whats happening.

 

Iv tried multiple changes and none work

 

I also did a breakpoint on the part that findMatchingRecipe compares the recipes and weither inside or outside the 3x3 grid, the contents of variables are the same.

 

Just in case if needed, my IDE is IntelliJ IDEA.

 

Thanx in advance.

My recipe splited on both spaces.png

Vanilla inside 3x3.png

Vanilla outside 3x3.png

Edited by ResaloliPT
Link to comment
Share on other sites

https://github.com/ResaloliPT/ExtrasInMinecraft/blob/master/src/main/java/com/resaloli/eim/content/crafting/CraftingManagerDCT.java#L34

Vanilla IRecipe implementations assume a 3x3 grid:

    /**
     * Used to check if a recipe matches current crafting inventory
     */
    public boolean matches(InventoryCrafting inv, World worldIn)
    {
        for (int i = 0; i <= 3 - this.recipeWidth; ++i)
        {
            for (int j = 0; j <= 3 - this.recipeHeight; ++j)
            {
                if (this.checkMatch(inv, i, j, true))
                {
                    return true;
                }

                if (this.checkMatch(inv, i, j, false))
                {
                    return true;
                }
            }
        }

        return false;
    }

 

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.

Link to comment
Share on other sites

9 minutes ago, Draco18s said:

https://github.com/ResaloliPT/ExtrasInMinecraft/blob/master/src/main/java/com/resaloli/eim/content/crafting/CraftingManagerDCT.java#L34

Vanilla IRecipe implementations assume a 3x3 grid:


    /**
     * Used to check if a recipe matches current crafting inventory
     */
    public boolean matches(InventoryCrafting inv, World worldIn)
    {
        for (int i = 0; i <= 3 - this.recipeWidth; ++i)
        {
            for (int j = 0; j <= 3 - this.recipeHeight; ++j)
            {
                if (this.checkMatch(inv, i, j, true))
                {
                    return true;
                }

                if (this.checkMatch(inv, i, j, false))
                {
                    return true;
                }
            }
        }

        return false;
    }

 

Thx for  posting,

 

Hmm, weird no wonder i would never find, when i use IntelliJ to goto definition it show a nearly empty IRecipe interface :/

 

Where could i get the default IRecipe to copy from?

IntelliJ IRecipe.png

Link to comment
Share on other sites

That's an interface. You need to look at the classes that implement it. The snippet I showed was from ShapedRecipes.

 

Right click on IRecipe and then in the context menu, click "open type hierarchy."

 

Edit:
Forge is also assuming a max width of 3:

 

    public static final int MAX_CRAFT_GRID_WIDTH = 3;
    public static final int MAX_CRAFT_GRID_HEIGHT = 3;

    @Override
    public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world)
    {
        for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
        {
            for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
            {
                if (checkMatch(inv, x, y, false))
                {
                    return true;
                }

                if (mirrored && checkMatch(inv, x, y, true))
                {
                    return true;
                }
            }
        }

        return false;
    }

 

Edited by Draco18s

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.

Link to comment
Share on other sites

32 minutes ago, Draco18s said:

That's an interface. You need to look at the classes that implement it. The snippet I showed was from ShapedRecipes.

 

Right click on IRecipe and then in the context menu, click "open type hierarchy."

 

Edit:
Forge is also assuming a max width of 3:

 


    public static final int MAX_CRAFT_GRID_WIDTH = 3;
    public static final int MAX_CRAFT_GRID_HEIGHT = 3;

    @Override
    public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world)
    {
        for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
        {
            for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
            {
                if (checkMatch(inv, x, y, false))
                {
                    return true;
                }

                if (mirrored && checkMatch(inv, x, y, true))
                {
                    return true;
                }
            }
        }

        return false;
    }

 

Ohh nice Will try new things then will reply back

Link to comment
Share on other sites

Indeed ShapedRecipes limited to 3x3, Shapeless already was using inv.get[Width/Height]() by default so i only made a ShapedRecipes implementing my own IRecipes and did some other changes, now when i place a item in the 3x3 it errors but doesnt crash, i push again the code to git.

 

The changes can be seen HERE

 

And here is the error i get:

Spoiler

[22:18:33] [Server thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class com.resaloli.eim.content.crafting.CraftingManagerDCT
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_121]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_121]
	at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:796) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.resaloli.eim.content.crafting.CraftingManagerDCT
	at com.resaloli.eim.content.container.ContainerDCT.onCraftMatrixChanged(ContainerDCT.java:69) ~[ContainerDCT.class:?]
	at com.resaloli.eim.content.crafting.DCTCrafting.decrStackSize(DCTCrafting.java:111) ~[DCTCrafting.class:?]
	at net.minecraft.inventory.Slot.decrStackSize(Slot.java:136) ~[Slot.class:?]
	at net.minecraft.inventory.Container.slotClick(Container.java:321) ~[Container.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processClickWindow(NetHandlerPlayServer.java:1212) ~[NetHandlerPlayServer.class:?]
	at net.minecraft.network.play.client.CPacketClickWindow.processPacket(CPacketClickWindow.java:47) ~[CPacketClickWindow.class:?]
	at net.minecraft.network.play.client.CPacketClickWindow.processPacket(CPacketClickWindow.java:12) ~[CPacketClickWindow.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_121]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_121]
	at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
	... 5 more

 

EDIT: On the commit i posted as can be seen on the CraftingManager i changed findMatchingRecipe to findMatchingRecipes and getRecipe to getRecipes because both where giving me clashing error.

 

Error it would give: findMatchingRecipe(InventoryCrafting, World) in 'com.resaloli.eim.content.CraftingManagerDCT' clashes with  findMatchingRecipe(InventoryCrafting, World) in 'net.minecraft.item.crafting.CraftingManager'; attempting to use incompatible type

 

And same for getRecipe:  getRecipe(ResourceLocation) in 'com.resaloli.eim.content.CraftingManagerDCT' clashes with  getRecipe(ResourceLocation) in 'net.minecraft.item.crafting.CraftingManager'; attempting to use incompatible type

Edited by ResaloliPT
More info of changes
Link to comment
Share on other sites

On 01/10/2017 at 11:09 PM, LexManos said:

Works like a charm, thx for the patch :D

 

EDIT: Github link just for future reference: HERE!

Vanilla outside 3x3 working.png

Edited by ResaloliPT
add github link
Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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