Update buildscript & apply automatic formatting rules

This commit is contained in:
Raven Szewczyk authored and Jason Mitchell committed 2022-06-27 10:23:18 -07:00
1 parent a7683b885d
commit f7a900e910
173 files changed
+4581 -5321

No files matched your search

@@ -1,10 +1,18 @@
package codechicken.nei.recipe;
import static net.minecraft.init.Items.potionitem;
import codechicken.nei.ItemStackSet;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.API;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
import net.minecraft.client.gui.inventory.GuiBrewingStand;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemPotion;
@@ -13,19 +21,8 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
import static net.minecraft.init.Items.potionitem;
public class BrewingRecipeHandler extends TemplateRecipeHandler
{
public static class BrewingRecipe
{
public class BrewingRecipeHandler extends TemplateRecipeHandler {
public static class BrewingRecipe {
public PositionedStack precursorPotion;
public PositionedStack result;
public PositionedStack ingredient;
@@ -37,8 +34,7 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
}
}
public class CachedBrewingRecipe extends CachedRecipe
{
public class CachedBrewingRecipe extends CachedRecipe {
public final BrewingRecipe recipe;
public CachedBrewingRecipe(BrewingRecipe recipe) {
@@ -81,23 +77,22 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("brewing") && getClass() == BrewingRecipeHandler.class)//don't want subclasses getting a hold of this
for (BrewingRecipe recipe : apotions)
arecipes.add(new CachedBrewingRecipe(recipe));
else
super.loadCraftingRecipes(outputId, results);
if (outputId.equals("brewing")
&& getClass() == BrewingRecipeHandler.class) // don't want subclasses getting a hold of this
for (BrewingRecipe recipe : apotions) arecipes.add(new CachedBrewingRecipe(recipe));
else super.loadCraftingRecipes(outputId, results);
}
@Override
public void loadCraftingRecipes(ItemStack result) {
if (result.getItem() != potionitem) return;
int damage = result.getItemDamage();
// Note: Not safe as written for parallelStream
apotions.stream()
.filter(recipe -> recipe.result.item.getItemDamage() == damage)
.map(CachedBrewingRecipe::new)
.collect(Collectors.toCollection(() -> arecipes));
.filter(recipe -> recipe.result.item.getItemDamage() == damage)
.map(CachedBrewingRecipe::new)
.collect(Collectors.toCollection(() -> arecipes));
}
@Override
@@ -106,9 +101,10 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
// Note: Not safe as written for parallelStream
apotions.stream()
.filter(recipe -> NEIServerUtils.areStacksSameType(recipe.ingredient.item, ingredient) || NEIServerUtils.areStacksSameType(recipe.precursorPotion.item, ingredient))
.map(CachedBrewingRecipe::new)
.collect(Collectors.toCollection(() -> arecipes));
.filter(recipe -> NEIServerUtils.areStacksSameType(recipe.ingredient.item, ingredient)
|| NEIServerUtils.areStacksSameType(recipe.precursorPotion.item, ingredient))
.map(CachedBrewingRecipe::new)
.collect(Collectors.toCollection(() -> arecipes));
}
@Override
@@ -130,36 +126,43 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
do {
HashSet<Integer> newPotions = new HashSet<>();
for (Integer basePotion : searchPotions) {
if (ItemPotion.isSplash(basePotion))
continue;
if (ItemPotion.isSplash(basePotion)) continue;
for (ItemStack ingred : ingredients.values()) {
int result = PotionHelper.applyIngredient(basePotion, ingred.getItem().getPotionEffect(ingred));
int result = PotionHelper.applyIngredient(
basePotion, ingred.getItem().getPotionEffect(ingred));
if (ItemPotion.isSplash(result)) {//splash potions qualify
if (ItemPotion.isSplash(result)) { // splash potions qualify
addPotion(ingred, basePotion, result, allPotions, newPotions);
continue;
}
List<?> baseMods = potionitem.getEffects(basePotion);
List<?> newMods = potionitem.getEffects(result);//compare ID's
if (basePotion > 0 && baseMods == newMods || //same modifers and not water->empty
baseMods != null && (baseMods.equals(newMods) || newMods == null) || //modifiers different and doesn't lose modifiers
basePotion == result ||//same potion
levelModifierChanged(basePotion, result))//redstone/glowstone cycle
continue;
List<?> newMods = potionitem.getEffects(result); // compare ID's
if (basePotion > 0 && baseMods == newMods
|| // same modifers and not water->empty
baseMods != null && (baseMods.equals(newMods) || newMods == null)
|| // modifiers different and doesn't lose modifiers
basePotion == result
|| // same potion
levelModifierChanged(basePotion, result)) // redstone/glowstone cycle
continue;
addPotion(ingred, basePotion, result, allPotions, newPotions);
}
}
searchPotions = newPotions;
}
while (!searchPotions.isEmpty());
} while (!searchPotions.isEmpty());
API.setItemListEntries(potionitem, allPotions.stream().map(potionID -> new ItemStack(potionitem, 1, potionID)).collect(Collectors.toList()));
API.setItemListEntries(
potionitem,
allPotions.stream()
.map(potionID -> new ItemStack(potionitem, 1, potionID))
.collect(Collectors.toList()));
API.addSubset("Items.Potions", new ItemStackSet().with(potionitem));
API.addSubset("Items.Potions.Splash", item -> item.getItem() == potionitem && (item.getItemDamage() & 0x4000) != 0);
API.addSubset(
"Items.Potions.Splash", item -> item.getItem() == potionitem && (item.getItemDamage() & 0x4000) != 0);
ItemStackSet positivepots = new ItemStackSet();
ItemStackSet negativepots = new ItemStackSet();
@@ -170,12 +173,11 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
int type = 0;
if (effectlist != null && !effectlist.isEmpty())
for (PotionEffect potioneffect : effectlist)
if (Potion.potionTypes[potioneffect.getPotionID()].isBadEffect())
type--;
else
type++;
if (Potion.potionTypes[potioneffect.getPotionID()].isBadEffect()) type--;
else type++;
(type == 0 ? neutralpots : type > 0 ? positivepots : negativepots).add(new ItemStack(potionitem, 1, potionID));
(type == 0 ? neutralpots : type > 0 ? positivepots : negativepots)
.add(new ItemStack(potionitem, 1, potionID));
}
API.addSubset("Items.Potions.Positive", positivepots);
@@ -190,10 +192,11 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler
return basemod != 0 && basemod != resultmod;
}
private static void addPotion(ItemStack ingred, int basePotion, int result, TreeSet<Integer> allPotions, HashSet<Integer> newPotions) {
private static void addPotion(
ItemStack ingred, int basePotion, int result, TreeSet<Integer> allPotions, HashSet<Integer> newPotions) {
apotions.add(new BrewingRecipe(ingred, basePotion, result));
if (allPotions.add(result))//it's new
newPotions.add(result);
if (allPotions.add(result)) // it's new
newPotions.add(result);
}
@Override