mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 06:24:35 +00:00
Update buildscript & apply automatic formatting rules
This commit is contained in:
1 parent
a7683b885d
commit
f7a900e910
173 files changed
+4581
-5321
No files matched your search
@@ -9,6 +9,9 @@ import codechicken.nei.api.DefaultOverlayRenderer;
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IRecipeOverlayRenderer;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -18,14 +21,8 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
{
|
||||
public class CachedShapedRecipe extends CachedRecipe
|
||||
{
|
||||
public class ShapedRecipeHandler extends TemplateRecipeHandler {
|
||||
public class CachedShapedRecipe extends CachedRecipe {
|
||||
public ArrayList<PositionedStack> ingredients;
|
||||
public PositionedStack result;
|
||||
|
||||
@@ -47,8 +44,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
public void setIngredients(int width, int height, Object[] items) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
if (items[y * width + x] == null)
|
||||
continue;
|
||||
if (items[y * width + x] == null) continue;
|
||||
|
||||
PositionedStack stack = new PositionedStack(items[y * width + x], 25 + x * 18, 6 + y * 18, false);
|
||||
stack.setMaxSize(1);
|
||||
@@ -67,8 +63,7 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
public void computeVisuals() {
|
||||
for (PositionedStack p : ingredients)
|
||||
p.generatePermutations();
|
||||
for (PositionedStack p : ingredients) p.generatePermutations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +87,10 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedRecipes)
|
||||
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe)
|
||||
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
if (irecipe instanceof ShapedRecipes) recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe) recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
if (recipe == null) continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
arecipes.add(recipe);
|
||||
@@ -113,13 +105,10 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedRecipes)
|
||||
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe)
|
||||
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
if (irecipe instanceof ShapedRecipes) recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe) recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null)
|
||||
continue;
|
||||
if (recipe == null) continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
arecipes.add(recipe);
|
||||
@@ -131,13 +120,10 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
|
||||
CachedShapedRecipe recipe = null;
|
||||
if (irecipe instanceof ShapedRecipes)
|
||||
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe)
|
||||
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
if (irecipe instanceof ShapedRecipes) recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
|
||||
else if (irecipe instanceof ShapedOreRecipe) recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
|
||||
|
||||
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
|
||||
continue;
|
||||
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem())) continue;
|
||||
|
||||
recipe.computeVisuals();
|
||||
if (recipe.contains(recipe.ingredients, ingredient)) {
|
||||
@@ -154,8 +140,8 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
|
||||
Object[] items = recipe.getInput();
|
||||
for (Object item : items)
|
||||
if (item instanceof List && ((List<?>) item).isEmpty()) //ore handler, no ores
|
||||
return null;
|
||||
if (item instanceof List && ((List<?>) item).isEmpty()) // ore handler, no ores
|
||||
return null;
|
||||
|
||||
return new CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
|
||||
} catch (Exception e) {
|
||||
@@ -175,35 +161,30 @@ public class ShapedRecipeHandler extends TemplateRecipeHandler
|
||||
}
|
||||
|
||||
public boolean hasOverlay(GuiContainer gui, Container container, int recipe) {
|
||||
return super.hasOverlay(gui, container, recipe) ||
|
||||
isRecipe2x2(recipe) && RecipeInfo.hasDefaultOverlay(gui, "crafting2x2");
|
||||
return super.hasOverlay(gui, container, recipe)
|
||||
|| isRecipe2x2(recipe) && RecipeInfo.hasDefaultOverlay(gui, "crafting2x2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int recipe) {
|
||||
IRecipeOverlayRenderer renderer = super.getOverlayRenderer(gui, recipe);
|
||||
if (renderer != null)
|
||||
return renderer;
|
||||
if (renderer != null) return renderer;
|
||||
|
||||
IStackPositioner positioner = RecipeInfo.getStackPositioner(gui, "crafting2x2");
|
||||
if (positioner == null)
|
||||
return null;
|
||||
if (positioner == null) return null;
|
||||
return new DefaultOverlayRenderer(getIngredientStacks(recipe), positioner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOverlayHandler getOverlayHandler(GuiContainer gui, int recipe) {
|
||||
IOverlayHandler handler = super.getOverlayHandler(gui, recipe);
|
||||
if (handler != null)
|
||||
return handler;
|
||||
if (handler != null) return handler;
|
||||
|
||||
return RecipeInfo.getOverlayHandler(gui, "crafting2x2");
|
||||
}
|
||||
|
||||
public boolean isRecipe2x2(int recipe) {
|
||||
for (PositionedStack stack : getIngredientStacks(recipe))
|
||||
if (stack.relx > 43 || stack.rely > 24)
|
||||
return false;
|
||||
for (PositionedStack stack : getIngredientStacks(recipe)) if (stack.relx > 43 || stack.rely > 24) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user