Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch in the logic we need for the brewing stand #877

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void registerRecipes(final IRecipeRegistration registration) {
final List<IJeiBrewingRecipe> brewingRecipes = new ArrayList<>();

DendroPotion.brewingRecipes.forEach(recipe ->
brewingRecipes.add(makeJeiBrewingRecipe(factory, recipe.getInput(), recipe.getIngredient(), recipe.getOutput())));
brewingRecipes.add(makeJeiBrewingRecipe(factory, recipe.input(), recipe.ingredient(), recipe.output())));

registration.addRecipes(RecipeTypes.BREWING, brewingRecipes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class DTConfigs {
public static final ForgeConfigSpec.BooleanValue PODZOL_GEN;

public static final ForgeConfigSpec.BooleanValue GENERATE_DIRT_BUCKET_RECIPES;
public static final ForgeConfigSpec.ConfigValue<String> BIOCHAR_BASE_BREWING_BASE;

public static final ForgeConfigSpec.BooleanValue WORLD_GEN;
public static final ForgeConfigSpec.ConfigValue<List<String>> DIMENSION_BLACKLIST;
Expand Down Expand Up @@ -180,6 +181,8 @@ public class DTConfigs {
COMMON_BUILDER.comment("Miscellaneous Settings").push("misc");
GENERATE_DIRT_BUCKET_RECIPES = COMMON_BUILDER.comment("If enabled, dirt bucket recipes will be automatically generated.")
.define("generateDirtBucketRecipes", true);
BIOCHAR_BASE_BREWING_BASE = COMMON_BUILDER.comment("The base potion the Biochar Base is brewed from. Minecraft potions use 'awkward'. If you change this, don't forget to update the patchouli manual page too.")
.define("biocharBrewingBase", "awkward");
COMMON_BUILDER.pop();

COMMON_BUILDER.comment("Mod Integration Settings").push("integration");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.ferreusveritas.dynamictrees.api.substance.Emptiable;
import com.ferreusveritas.dynamictrees.api.substance.SubstanceEffect;
import com.ferreusveritas.dynamictrees.api.substance.SubstanceEffectProvider;
import com.ferreusveritas.dynamictrees.init.DTConfigs;
import com.ferreusveritas.dynamictrees.init.DTRegistries;
import com.ferreusveritas.dynamictrees.systems.substance.DenudeSubstance;
import com.ferreusveritas.dynamictrees.systems.substance.DepleteSubstance;
Expand Down Expand Up @@ -130,27 +131,17 @@ public static DendroPotionType getPotionType(ItemStack stack) {
@Nullable
@Override
public SubstanceEffect getSubstanceEffect(ItemStack itemStack) {
switch (getPotionType(itemStack)) {
default:
case BIOCHAR:
return null;
case BURGEONING:
return new GrowthSubstance();
case GIGAS:
return new MegaSubstance();
case DEPLETION:
return new DepleteSubstance().setAmount(15);
case FERTILITY:
return new FertilizeSubstance().setAmount(15);
case PERSISTENCE:
return new FreezeSubstance();
case TRANSFORM:
return new TransformSubstance(this.getTargetSpecies(itemStack));
case HARVEST:
return new HarvestSubstance();
case DENUDING:
return new DenudeSubstance();
}
return switch (getPotionType(itemStack)) {
default -> null;
case BURGEONING -> new GrowthSubstance();
case GIGAS -> new MegaSubstance();
case DEPLETION -> new DepleteSubstance().setAmount(15);
case FERTILITY -> new FertilizeSubstance().setAmount(15);
case PERSISTENCE -> new FreezeSubstance();
case TRANSFORM -> new TransformSubstance(this.getTargetSpecies(itemStack));
case HARVEST -> new HarvestSubstance();
case DENUDING -> new DenudeSubstance();
};
}

public Species getTargetSpecies(ItemStack itemStack) {
Expand All @@ -167,20 +158,21 @@ public ItemStack setTargetSpecies(ItemStack itemStack, Species species) {
}

public void registerRecipes() {
final ItemStack awkwardStack = PotionUtils.setPotion(new ItemStack(Items.POTION), Potion.byName("awkward"));
final ItemStack baseStack = PotionUtils.setPotion(new ItemStack(Items.POTION), Potion.byName(DTConfigs.BIOCHAR_BASE_BREWING_BASE.get()));

brewingRecipes.add(this.getRecipe(awkwardStack, new ItemStack(Items.CHARCOAL), this.getPotionStack(DendroPotionType.BIOCHAR)));
//Biochar potion
brewingRecipes.add(this.getRecipe(baseStack, new ItemStack(Items.CHARCOAL), this.getPotionStack(DendroPotionType.BIOCHAR)));

//Regular potions
for (int i = 1; i < DendroPotionType.values().length; i++) {
final DendroPotionType type = DendroPotionType.values()[i];

if (!type.isActive()) {
continue;
}
if (!type.isActive()) continue;

brewingRecipes.add(this.getRecipe(type.getIngredient(), type));
}

//Transformation potions
for (Species species : TreeRegistry.getPotionTransformableSpecies()) {
brewingRecipes.add(new DendroBrewingRecipe(this.getPotionStack(DendroPotionType.TRANSFORM), species.getSeedStack(1),
this.setTargetSpecies(this.getPotionStack(DendroPotionType.TRANSFORM), species)));
Expand All @@ -189,22 +181,10 @@ public void registerRecipes() {
brewingRecipes.forEach(BrewingRecipeRegistry::addRecipe);
}

private DendroBrewingRecipe getRecipe(Item ingredient, DendroPotionType typeOut) {
return this.getRecipe(new ItemStack(ingredient), typeOut);
}

private DendroBrewingRecipe getRecipe(Block ingredient, DendroPotionType typeOut) {
return this.getRecipe(new ItemStack(ingredient), typeOut);
}

private DendroBrewingRecipe getRecipe(ItemStack ingredient, DendroPotionType typeOut) {
return this.getRecipe(this.getPotionStack(typeOut.getBasePotionType()), ingredient, this.getPotionStack(typeOut));
}

private DendroBrewingRecipe getRecipe(ItemStack ingredientStack, ItemStack stackOut) {
return this.getRecipe(this.getPotionStack(DendroPotionType.BIOCHAR), ingredientStack, stackOut);
}

private DendroBrewingRecipe getRecipe(ItemStack stackIn, ItemStack ingredientStack, ItemStack stackOut) {
return new DendroBrewingRecipe(stackIn, ingredientStack, stackOut);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,27 @@
*
* @author Harley O'Connor
*/
public final class DendroBrewingRecipe implements IBrewingRecipe {
public record DendroBrewingRecipe(ItemStack input, ItemStack ingredient, ItemStack output) implements IBrewingRecipe {

@Override
public boolean isInput(final ItemStack inputStack) {
return ItemStack.isSameItemSameTags(input, inputStack);
}

@Override
public boolean isIngredient(final ItemStack ingredientStack) {
return ItemStack.isSameItemSameTags(ingredient, ingredientStack);
}

@Override
public ItemStack getOutput(final ItemStack inputStack, final ItemStack ingredientStack) {
// We need to apply logic for the brewing or simply the ingredient defines the output and any input was allowed
// A smarter way would be nice, but it works
if (!inputStack.isEmpty() && !ingredientStack.isEmpty() && isIngredient(ingredientStack) && isInput(inputStack)) {
return this.output.copy();
}
return ItemStack.EMPTY;
}

private final ItemStack input;
private final ItemStack ingredient;
private final ItemStack output;

public DendroBrewingRecipe(final ItemStack input, final ItemStack ingredient, final ItemStack output) {
this.input = input;
this.ingredient = ingredient;
this.output = output;
}

@Override
public boolean isInput(final ItemStack inputStack) {
// For transformation potion, only allow input if it doesn't already have a tree tag.
return DendroPotion.getPotionType(inputStack) == DendroPotion.getPotionType(this.input) && !inputStack.getOrCreateTag().contains(DendroPotion.TREE_TAG_KEY);
}

@Override
public boolean isIngredient(final ItemStack ingredientStack) {
return this.ingredient.getItem().equals(ingredientStack.getItem());
}

@Override
public ItemStack getOutput(final ItemStack inputStack, final ItemStack ingredientStack) {
if (!inputStack.isEmpty() && !ingredientStack.isEmpty() && isIngredient(ingredientStack)) {
// For transformation potion, only brew if it doesn't already have a tree tag (must check here too, in case potion is left in after being brewed).
if (!inputStack.getOrCreateTag().contains(DendroPotion.TREE_TAG_KEY)) {
return this.output.copy();
}
}

return ItemStack.EMPTY;
}

public ItemStack getInput() {
return input;
}

public ItemStack getIngredient() {
return ingredient;
}

public ItemStack getOutput() {
return output;
}

}
Loading