Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Custom Recipe Handler Program Code Stuck need Help(Only for advanced Java Guys)

Featured Replies

Posted

Hey Guys, I really need your help

 

I'm programing a custom Recipe Hander, who can handle item crafting, Class crafting(Items which are instanceof any class) and crafting with nbtTags. But my problem is, in the program code is a mistake, or more, I don't really know, but I'm stuck. I searched them for like 5 hours now, but I cant find it(or them).

 

 

package de.kloon.advancedguns.morestuff;

import scala.tools.nsc.interpreter.IMain.Request.ClassBasedWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;

public class KloonsCustomRecipeHandler {

private ItemStack[] slotsBase;
private Class[][] classBasedRecipe;
private ItemStack[] classBasedRecipeOutput;
private ItemStack[][] itemBasedRecipe;
private int RecipeNumber = 0;

public KloonsCustomRecipeHandler(ItemStack[] slots, int numberofrecipes){
	this.slotsBase = new ItemStack[slots.length];
	this.classBasedRecipe = new Class[numberofrecipes][slots.length];
	this.classBasedRecipeOutput = new ItemStack[numberofrecipes];
	this.itemBasedRecipe = new ItemStack[numberofrecipes][slots.length];
}

public boolean checkforItemBasedMatchingRecipe(ItemStack[] slots){
	for(int i = 0; i < itemBasedRecipe.length; i++){
		for(int j = 0; j < slotsBase.length - 1; j++){
			if(itemBasedRecipe[i][j] != slots[j]){
				return false;
			}
		}
	}
	return true;
}

public boolean checkforClassBasedMatchingRecipe(ItemStack[] slots){
	for(int i = 0; i < classBasedRecipe.length; i++){
		for(int j = 0; j < slotsBase.length - 1; j++){
			if(slots[j]!= null){
				if(this.classBasedRecipe[i][j] == slots[j].getItem().getClass()){
					return false;
				}
			}
		} 	
	}
	return true;
}
public void addClassBasedRecipe(ItemStack output, Class <? extends Item>... classes){
	for(int i = 0; i < slotsBase.length; i++){
		if(i != slotsBase.length - 1){
			if(i < classes.length){
				this.classBasedRecipe[RecipeNumber][i] = classes[i];
			}else{
				this.classBasedRecipe[RecipeNumber][i] = null;
			}
		}else{
			this.classBasedRecipeOutput[RecipeNumber] = output;
		}
	}
	RecipeNumber++;
}

public void addItemBasedRecipe(ItemStack output, ItemStack...itemstack){
	for(int i = 0; i < slotsBase.length; i++){
		if(i != slotsBase.length - 1){
			if(i < itemstack.length){
				this.itemBasedRecipe[RecipeNumber][i] = itemstack[i];
			}else{
				this.itemBasedRecipe[RecipeNumber][i] = null;
			}

		}else{
			this.itemBasedRecipe[RecipeNumber][i] = output;
		}
	}
	RecipeNumber++;
}

public boolean checkforAnyRecipe(ItemStack[] slots){
	if(checkforClassBasedMatchingRecipe(slots) == true){
		return true;
	}
	if(checkforItemBasedMatchingRecipe(slots) == true){
		return true;
	}
	return false;
}

public ItemStack checkForAnyRecipeandCreate(ItemStack[] slots){
	if(checkforAnyRecipe(slots) == true){
		if(checkforItemBasedMatchingRecipe(slots)){
			return findMatchingRecipe(slots);
		}
		if(checkforClassBasedMatchingRecipe(slots)){
			return findMatchingRecipe(slots);
		}
	}
	return null;
}

private ItemStack findMatchingRecipe(ItemStack[] slots){
	boolean flag;
	for(int i = 0; i < itemBasedRecipe.length; i++){
		for(int j = 0; j < slotsBase.length; j++){
			if(itemBasedRecipe[i][j] != slots[j]){

			}else{
				return itemBasedRecipe[i][slotsBase.length - 1];
			}

		}
	}
	for(int i = 0; i < classBasedRecipe.length; i++){
		for(int j = 0; j < slotsBase.length; j++){
			if(slots[j] != null){
				if(classBasedRecipe[i][j] != slots[j].getItem().getClass()){
					flag = false;
				}else{
					return classBasedRecipeOutput[i];
				}
			}
		}
	}
	return null;
}

}

 

I dont know thee fuck what is going wrong, in fact, It doesn't really check if there is something in the slots and what, I dont really know, I'm as stuck, I cant really think anymore

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.