Added more default recipes + small fixes

BStats shows that >75% of users don't add any recipes themselves. So even if I would have preferred not to, i've added more default recipes to make it easier for everyone
+Fixed Brew Create with space in name
+Changed look of Quality Stars (now with half-stars)
+Fixed Cauldron Recipe with Multiple Ingredients
This commit is contained in:
Sn0wStorm
2019-12-06 18:57:41 +01:00
parent bc79248db5
commit 214bb52939
16 changed files with 2018 additions and 119 deletions
@@ -138,8 +138,20 @@ public class BCauldronRecipe {
/**
* Find how much these ingredients match the given ones from 0-10.
* <p>If any ingredient is missing, returns 0
* <br>If all Ingredients and their amounts are equal, returns 10
* <br>Returns something between 0 and 10 if all ingredients present, but differing amounts, depending on how much the amount differs.
* <br>Any included item that is not in the recipe, will drive the number down most heavily.
* <br>More Amount of any item, will logarithmically raise the number
* <br>Difference in Amount to what the recipe expects will make a tiny difference on the number
* <p>So apart from unexpected items, more amount of the correct item will make the number go up,
* with a little dip for difference in expected amount.
*
* <p>The thought behind this is, that a given list of ingredients matches this recipe most, when:
* <br>1. It is not missing ingredients,
* <br>2. It has no unexpected ingredients
* <br>3. It has a lot of the matching ingredients, so that for two recipes, both having the same
* amount of unexpected ingredients, the one matching the item with the highest amounts wins.
* <br> For Example | Recipe_1: (Wheat*1), Recipe_2: (Sugar*1) | Ingredients: (Wheat*10, Sugar*5), Recipe_1 should win,
* even though the difference in expected amount (1) is lower for Recipe_2
* <br>4. It has the least difference in expected ingredient amount.
*/
public float getIngredientMatch(List<Ingredient> items) {
if (items.size() < ingredients.size()) {
@@ -162,9 +174,6 @@ public class BCauldronRecipe {
P.p.debugLog("Mod for " + recipeIng + ": " + mod);
match *= mod;
continue search;
}
@@ -173,8 +182,9 @@ public class BCauldronRecipe {
}
if (items.size() > ingredients.size()) {
// If there are too many items in the List, multiply the match by 0.1 per Item thats too much
// So that even if every other ingredient is perfect, a recipe that expects all these items will fare better
float tooMuch = items.size() - ingredients.size();
float mod = 0.1f / tooMuch;
double mod = Math.pow(0.1, tooMuch);
match *= mod;
}
P.p.debugLog("Match for Cauldron Recipe " + name + ": " + match);
+6
View File
@@ -196,6 +196,12 @@ public class BRecipe {
matParts = ingredParts[0].split("\\.");
}
if (!P.use1_14 && matParts[0].equalsIgnoreCase("sweet_berries")) {
// Using this in default recipes, but will error on < 1.14
ingredients.add(new SimpleItem(Material.BEDROCK));
continue;
}
// Check if this is a Plugin Item
String[] pluginItem = matParts[0].split(":");
if (pluginItem.length > 1) {
+13 -1
View File
@@ -21,6 +21,12 @@ public class PotionColor {
public static final PotionColor WATER = new PotionColor(11, P.use1_9 ? PotionType.WATER_BREATHING : null, Color.BLUE);
public static final PotionColor DARK_RED = new PotionColor(12, PotionType.INSTANT_DAMAGE, Color.fromRGB(128,0,0));
public static final PotionColor BRIGHT_GREY = new PotionColor(14, PotionType.INVISIBILITY, Color.SILVER);
public static final PotionColor WHITE = new PotionColor(Color.WHITE);
public static final PotionColor LIME = new PotionColor(Color.LIME);
public static final PotionColor OLIVE = new PotionColor(Color.OLIVE);
public static final PotionColor PURPLE = new PotionColor(Color.PURPLE);
public static final PotionColor TEAL = new PotionColor(Color.TEAL);
public static final PotionColor YELLOW = new PotionColor(Color.YELLOW);
private final int colorId;
private final PotionType type;
@@ -33,7 +39,7 @@ public class PotionColor {
}
public PotionColor(Color color) {
colorId = -1;
colorId = WATER.colorId;
type = WATER.getType();
this.color = color;
}
@@ -86,6 +92,12 @@ public class PotionColor {
case "WATER": return WATER;
case "DARK_RED": return DARK_RED;
case "BRIGHT_GREY": return BRIGHT_GREY;
case "WHITE": return WHITE;
case "LIME": return LIME;
case "OLIVE": return OLIVE;
case "PURPLE": return PURPLE;
case "TEAL": return TEAL;
case "YELLOW": return YELLOW;
default:
try{
if (string.length() >= 7) {
@@ -251,6 +251,12 @@ public abstract class RecipeItem implements Cloneable {
}
Material mat = Material.matchMaterial(ingredParts[0]);
if (mat == null && !P.use1_14 && ingredParts[0].equalsIgnoreCase("cornflower")) {
// Using this in default custom-items, but will error on < 1.14
materials.add(Material.BEDROCK);
continue;
}
if (mat == null && BConfig.hasVault) {
try {
net.milkbowl.vault.item.ItemInfo vaultItem = net.milkbowl.vault.item.Items.itemByString(ingredParts[0]);