Jump to content

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


Recommended Posts

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

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