mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-22 13:09:45 +00:00
Unified build script (#175)
* Update build script * Update build script to import fix for shadow in dev and sources artifacts * Update fixed build script to shadow csv dependency in dev jar as well * Moved jitpack * Move new files
This commit is contained in:
1 parent
43b71b1de6
commit
a7ca6c8527
188 files changed
+646
-968
No files matched your search
@@ -0,0 +1,176 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ShapelessRecipeHandler extends ShapedRecipeHandler
|
||||
{
|
||||
public int[][] stackorder = new int[][]{
|
||||
{0, 0},
|
||||
{1, 0},
|
||||
{0, 1},
|
||||
{1, 1},
|
||||
{0, 2},
|
||||
{1, 2},
|
||||
{2, 0},
|
||||
{2, 1},
|
||||
{2, 2}};
|
||||
|
||||
public class CachedShapelessRecipe extends CachedRecipe
|
||||
{
|
||||
public CachedShapelessRecipe() {
|
||||
ingredients = new ArrayList<>();
|
||||
}
|
||||
|
||||
public CachedShapelessRecipe(ItemStack output) {
|
||||
this();
|
||||
setResult(output);
|
||||
}
|
||||
|
||||
public CachedShapelessRecipe(Object[] input, ItemStack output) {
|
||||
this(Arrays.asList(input), output);
|
||||
}
|
||||
|
||||
public CachedShapelessRecipe(List<?> input, ItemStack output) {
|
||||
this(output);
|
||||
setIngredients(input);
|
||||
}
|
||||
|
||||
public void setIngredients(List<?> items) {
|
||||
ingredients.clear();
|
||||
int itemsSize = items.size();
|
||||
if (itemsSize > stackorder.length) {
|
||||
NEIClientConfig.logger.error("RECIPE BUG: Too many items (" + itemsSize + ") for " + this.result.toString());
|
||||
itemsSize = stackorder.length;
|
||||
}
|
||||
for (int ingred = 0; ingred < itemsSize; ingred++) {
|
||||
PositionedStack stack = new PositionedStack(items.get(ingred), 25 + stackorder[ingred][0] * 18, 6 + stackorder[ingred][1] * 18);
|
||||
stack.setMaxSize(1);
|
||||
ingredients.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public void setResult(ItemStack output) {
|
||||
result = new PositionedStack(output, 119, 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getIngredients() {
|
||||
return getCycledIngredients(cycleticks / 20, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
}
|
||||
|
||||
public String getRecipeName() {
|
||||
return NEIClientUtils.translate("recipe.shapeless");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(String outputId, Object... results) {
|
||||
if (outputId.equals("crafting") && getClass() == ShapelessRecipeHandler.class) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessRecipes)
|
||||
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapelessOreRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
} else {
|
||||
super.loadCraftingRecipes(outputId, results);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessRecipes)
|
||||
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapelessOreRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe irecipe : allrecipes) {
|
||||
CachedShapelessRecipe recipe = null;
|
||||
if (irecipe instanceof ShapelessRecipes)
|
||||
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapelessOreRecipe)
|
||||
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
|
||||
if (recipe.contains(recipe.ingredients, ingredient)) {
|
||||
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
|
||||
arecipes.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
|
||||
if(recipe.recipeItems == null) //because some mod subclasses actually do this
|
||||
return null;
|
||||
|
||||
try {
|
||||
return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput());
|
||||
} catch (ClassCastException e) { //because some mod subclasses put whatever they want in recipeItems
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public CachedShapelessRecipe forgeShapelessRecipe(ShapelessOreRecipe recipe) {
|
||||
ArrayList<Object> items = recipe.getInput();
|
||||
|
||||
for (Object item : items)
|
||||
if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
|
||||
return null;
|
||||
|
||||
try {
|
||||
return new CachedShapelessRecipe(items, recipe.getRecipeOutput());
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Error loading recipe: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipe2x2(int recipe) {
|
||||
return getIngredientStacks(recipe).size() <= 4;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user