mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fix IllegalArgumentException when trying to brew invalid potions
Resolves #3093
This commit is contained in:
parent
cccf6a1bb7
commit
87b0812c2e
@ -4,6 +4,8 @@ import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -52,10 +54,12 @@ public class AutoBrewer extends AContainer implements NotHopperable {
|
||||
fermentations.put(PotionType.NIGHT_VISION, PotionType.INVISIBILITY);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public AutoBrewer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected MachineRecipe findNextRecipe(BlockMenu menu) {
|
||||
ItemStack input1 = menu.getItemInSlot(getInputSlots()[0]);
|
||||
@ -98,10 +102,13 @@ public class AutoBrewer extends AContainer implements NotHopperable {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ParametersAreNonnullByDefault
|
||||
private ItemStack brew(Material input, Material potionType, PotionMeta potion) {
|
||||
PotionData data = potion.getBasePotionData();
|
||||
|
||||
if (data.getType() == PotionType.WATER) {
|
||||
PotionType type = data.getType();
|
||||
if (type == PotionType.WATER) {
|
||||
if (input == Material.FERMENTED_SPIDER_EYE) {
|
||||
potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false));
|
||||
return new ItemStack(potionType);
|
||||
@ -114,19 +121,19 @@ public class AutoBrewer extends AContainer implements NotHopperable {
|
||||
return new ItemStack(Material.LINGERING_POTION);
|
||||
}
|
||||
} else if (input == Material.FERMENTED_SPIDER_EYE) {
|
||||
PotionType fermented = fermentations.get(data.getType());
|
||||
PotionType fermented = fermentations.get(type);
|
||||
|
||||
if (fermented != null) {
|
||||
potion.setBasePotionData(new PotionData(fermented, false, false));
|
||||
return new ItemStack(potionType);
|
||||
}
|
||||
} else if (input == Material.REDSTONE) {
|
||||
potion.setBasePotionData(new PotionData(data.getType(), true, data.isUpgraded()));
|
||||
} else if (input == Material.REDSTONE && type.isExtendable()) {
|
||||
potion.setBasePotionData(new PotionData(type, true, data.isUpgraded()));
|
||||
return new ItemStack(potionType);
|
||||
} else if (input == Material.GLOWSTONE_DUST) {
|
||||
potion.setBasePotionData(new PotionData(data.getType(), data.isExtended(), true));
|
||||
} else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable()) {
|
||||
potion.setBasePotionData(new PotionData(type, data.isExtended(), true));
|
||||
return new ItemStack(potionType);
|
||||
} else if (data.getType() == PotionType.AWKWARD) {
|
||||
} else if (type == PotionType.AWKWARD) {
|
||||
PotionType potionRecipe = potionRecipes.get(input);
|
||||
|
||||
if (potionRecipe != null) {
|
||||
@ -150,11 +157,13 @@ public class AutoBrewer extends AContainer implements NotHopperable {
|
||||
return mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getProgressBar() {
|
||||
return new ItemStack(Material.FISHING_ROD);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getMachineIdentifier() {
|
||||
return "AUTO_BREWER";
|
||||
|
Loading…
Reference in New Issue
Block a user