Custom Crafting station doesn't work as intended

Started by frootloopgoop on

Topic category: Help with modding (Java Edition)

Last seen on 09:51, 8. Jun 2023
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom Crafting station doesn't work as intended

The way this specific crafting station is supposed to work is it will check all slots 0-8 for potion ingredients, and if it has found one it will fill slots 9-12 with items representing the potion effect of the ingredient.

The slot will fill with the item as intended, but when multiple ingredients are added, the slot in 9 is overwritten rather than adding 1 to the variable adding an additional item in slot 10.

The procedure updates on GUI tick

 

Image of how it should work:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Image showing it not working:

 

The Code:

Last seen on 04:04, 3. Feb 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Break will exit your loop,…
Sat, 12/24/2022 - 10:40

Break will exit your loop, not the if/else condition. This means it is only running once.

Your current logic looks like this:

repeat 9 times
{
	if( it's a potion ingredient )
	{
		if( water breathing ingredient )
		{
			Put bubbles in slot
			Jump to @OUT
		}
		else if( poison ingredient )
		{
			Put skull in slot
			Jump to @out
		}
		
		if( tagged with potion effect )
		{
			move to next effect slot
		)
	}
	else
	{
		move to next ingredient slot
	}
}
if( not a goop ingredient )
{
	clear effect slots
}
@OUT

What you want is this:

repeat 9 times
{
	if( number of items in slot > 0 )
	{
		if( it's a potion ingredient )
		{
			if( water breathing )
			{
				put bubbles in effect slot
				move to next effect slot
			}
			else if( poison )
			{
				put skull in effect slot
				move to next effect slot
			}
		}
		else
		{
			clear effect slots
		}
	}
}

more test

Last seen on 04:04, 3. Feb 2023
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm not able to edit the…
Sat, 12/24/2022 - 10:43

I'm not able to edit the post above, ignore the 'more test' at the end and maybe add a 'move to next ingredient slot' at the bottom (inside the repeat)

Last seen on 09:51, 8. Jun 2023
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you a lot and have a…
Sat, 12/24/2022 - 22:55

Thank you a lot and have a Merry Christmas if you celebrate it.