[ci skip] spotlessApply with the new settings

This commit is contained in:
Jason Mitchell committed 2023-01-28 17:55:51 -08:00
1 parent f1dea5460a
commit f106b5e766
172 files changed
+2552 -2088

No files matched your search

@@ -2,17 +2,13 @@ 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;
@@ -21,8 +17,16 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionHelper;
import codechicken.nei.ItemStackSet;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.API;
public class BrewingRecipeHandler extends TemplateRecipeHandler {
public static class BrewingRecipe {
public PositionedStack precursorPotion;
public PositionedStack result;
public PositionedStack ingredient;
@@ -35,6 +39,7 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
}
public class CachedBrewingRecipe extends CachedRecipe {
public final BrewingRecipe recipe;
public CachedBrewingRecipe(BrewingRecipe recipe) {
@@ -77,9 +82,9 @@ 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));
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);
}
@@ -89,9 +94,7 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
int damage = result.getItemDamage();
// Note: Not safe as written for parallelStream
apotions.stream()
.filter(recipe -> recipe.result.item.getItemDamage() == damage)
.map(CachedBrewingRecipe::new)
apotions.stream().filter(recipe -> recipe.result.item.getItemDamage() == damage).map(CachedBrewingRecipe::new)
.collect(Collectors.toCollection(() -> arecipes));
}
@@ -101,10 +104,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
@@ -129,8 +132,7 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
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
addPotion(ingred, basePotion, result, allPotions, newPotions);
@@ -139,14 +141,13 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
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
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;
continue;
addPotion(ingred, basePotion, result, allPotions, newPotions);
}
@@ -157,12 +158,12 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
API.setItemListEntries(
potionitem,
allPotions.stream()
.map(potionID -> new ItemStack(potionitem, 1, potionID))
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);
"Items.Potions.Splash",
item -> item.getItem() == potionitem && (item.getItemDamage() & 0x4000) != 0);
ItemStackSet positivepots = new ItemStackSet();
ItemStackSet negativepots = new ItemStackSet();
@@ -171,10 +172,9 @@ public class BrewingRecipeHandler extends TemplateRecipeHandler {
for (int potionID : allPotions) {
List<PotionEffect> effectlist = potionitem.getEffects(potionID);
int type = 0;
if (effectlist != null && !effectlist.isEmpty())
for (PotionEffect potioneffect : effectlist)
if (Potion.potionTypes[potioneffect.getPotionID()].isBadEffect()) type--;
else type++;
if (effectlist != null && !effectlist.isEmpty()) for (PotionEffect potioneffect : effectlist)
if (Potion.potionTypes[potioneffect.getPotionID()].isBadEffect()) type--;
else type++;
(type == 0 ? neutralpots : type > 0 ? positivepots : negativepots)
.add(new ItemStack(potionitem, 1, potionID));
@@ -192,11 +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);
newPotions.add(result);
}
@Override