Skip to content

Commit

Permalink
working on brewing
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Sep 4, 2023
1 parent 72159ce commit d221e73
Show file tree
Hide file tree
Showing 34 changed files with 386 additions and 53 deletions.
Binary file added assets/curseforge-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
val mc_version: String by extra
val registrate_fabric_version: String by extra
val jei_version: String by extra

plugins {
id("dev.architectury.loom") version ("1.2-SNAPSHOT")
Expand All @@ -14,6 +15,7 @@ dependencies {
"mappings"(loom.officialMojangMappings())

modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_fabric_version}")
modCompileOnly("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
}

tasks.register("prepareWorkspace") {
Expand Down
22 changes: 22 additions & 0 deletions common/src/generated/resources/assets/blissful/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
"item.blissful.hemp": "dɯǝH",
"item.blissful.hemp_seeds": "spǝǝS dɯǝH",
"item.blissful.joint": "ʇuıoſ",
"item.blissful.potion_bong": "buoᗺ uoıʇoԀ",
"item.blissful.potion_bong.effect.awkward": "buoᗺ pɹɐʍʞʍⱯ",
"item.blissful.potion_bong.effect.empty": "buoᗺ ʎʇdɯƎ",
"item.blissful.potion_bong.effect.fire_resistance": "ǝɔuɐʇsısǝᴚ ǝɹıℲ ɟo buoᗺ",
"item.blissful.potion_bong.effect.harming": "buıɯɹɐH ɟo buoᗺ",
"item.blissful.potion_bong.effect.healing": "buıןɐǝH ɟo buoᗺ",
"item.blissful.potion_bong.effect.invisibility": "ʎʇıןıqısıʌuI ɟo buoᗺ",
"item.blissful.potion_bong.effect.leaping": "buıdɐǝꞀ ɟo buoᗺ",
"item.blissful.potion_bong.effect.luck": "ʞɔnꞀ ɟo buoᗺ",
"item.blissful.potion_bong.effect.mundane": "buoᗺ ǝuɐpunW",
"item.blissful.potion_bong.effect.night_vision": "uoısıΛ ʇɥbıN ɟo buoᗺ",
"item.blissful.potion_bong.effect.poison": "uosıoԀ ɟo buoᗺ",
"item.blissful.potion_bong.effect.regeneration": "uoıʇɐɹǝuǝbǝᴚ ɟo buoᗺ",
"item.blissful.potion_bong.effect.slow_falling": "buıןןɐℲ ʍoןS ɟo buoᗺ",
"item.blissful.potion_bong.effect.slowness": "ssǝuʍoןS ɟo buoᗺ",
"item.blissful.potion_bong.effect.strength": "ɥʇbuǝɹʇS ɟo buoᗺ",
"item.blissful.potion_bong.effect.swiftness": "ssǝuʇɟıʍS ɟo buoᗺ",
"item.blissful.potion_bong.effect.thick": "buoᗺ ʞɔıɥ⟘",
"item.blissful.potion_bong.effect.turtle_master": "ɹǝʇsɐW ǝןʇɹn⟘ ɟo buoᗺ",
"item.blissful.potion_bong.effect.water": "buoᗺ ɹǝʇɐM",
"item.blissful.potion_bong.effect.water_breathing": "buıɥʇɐǝɹᗺ ɹǝʇɐM ɟo buoᗺ",
"item.blissful.potion_bong.effect.weakness": "ssǝuʞɐǝM ɟo buoᗺ",
"item.blissful.weed": "pǝǝM",
"item.blissful.weed_brownies": "sǝıuʍoɹᗺ pǝǝM"
}
22 changes: 22 additions & 0 deletions common/src/generated/resources/assets/blissful/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
"item.blissful.hemp": "Hemp",
"item.blissful.hemp_seeds": "Hemp Seeds",
"item.blissful.joint": "Joint",
"item.blissful.potion_bong": "Potion Bong",
"item.blissful.potion_bong.effect.awkward": "Awkward Bong",
"item.blissful.potion_bong.effect.empty": "Empty Bong",
"item.blissful.potion_bong.effect.fire_resistance": "Bong of Fire Resistance",
"item.blissful.potion_bong.effect.harming": "Bong of Harming",
"item.blissful.potion_bong.effect.healing": "Bong of Healing",
"item.blissful.potion_bong.effect.invisibility": "Bong of Invisibility",
"item.blissful.potion_bong.effect.leaping": "Bong of Leaping",
"item.blissful.potion_bong.effect.luck": "Bong of Luck",
"item.blissful.potion_bong.effect.mundane": "Mundane Bong",
"item.blissful.potion_bong.effect.night_vision": "Bong of Night Vision",
"item.blissful.potion_bong.effect.poison": "Bong of Poison",
"item.blissful.potion_bong.effect.regeneration": "Bong of Regeneration",
"item.blissful.potion_bong.effect.slow_falling": "Bong of Slow Falling",
"item.blissful.potion_bong.effect.slowness": "Bong of Slowness",
"item.blissful.potion_bong.effect.strength": "Bong of Strength",
"item.blissful.potion_bong.effect.swiftness": "Bong of Swiftness",
"item.blissful.potion_bong.effect.thick": "Thick Bong",
"item.blissful.potion_bong.effect.turtle_master": "Bong of Turtle Master",
"item.blissful.potion_bong.effect.water": "Water Bong",
"item.blissful.potion_bong.effect.water_breathing": "Bong of Water Breathing",
"item.blissful.potion_bong.effect.weakness": "Bong of Weakness",
"item.blissful.weed": "Weed",
"item.blissful.weed_brownies": "Weed Brownies"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "blissful:item/bong_potion",
"layer1": "blissful:item/bong_potion_overlay"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_hemp": {
"conditions": {
"items": [
{
"items": [
"blissful:hemp"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "blissful:weed_from_hemp_smelting"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_hemp",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"blissful:weed_from_hemp_smelting"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"ingredients": [
{
"item": "blissful:hemp_seeds"
},
{
"item": "minecraft:wheat"
},
{
"item": "minecraft:cocoa_beans"
}
],
"result": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "minecraft:smelting",
"category": "misc",
"cookingtime": 200,
"experience": 0.25,
"ingredient": {
"item": "blissful:hemp"
},
"result": "blissful:weed"
}
21 changes: 21 additions & 0 deletions common/src/main/java/galena/blissful/BlissfulClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package galena.blissful;

import galena.blissful.index.BlissfuItems;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.ItemLike;

import java.util.function.BiConsumer;

public class BlissfulClient {

private static final ItemColor POTION_COLORS = (stack, i) -> {
if(i != 1) return -1;
return PotionUtils.getColor(stack);
};

public static void registerItemColors(BiConsumer<ItemColor, ItemLike> consumer) {
consumer.accept(POTION_COLORS, BlissfuItems.POTION_BONG.get());
}

}
5 changes: 5 additions & 0 deletions common/src/main/java/galena/blissful/BlissfulCommon.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package galena.blissful;

import galena.blissful.index.BlissfulBrewing;
import galena.blissful.index.BlissfulEffects;
import galena.blissful.index.BlissfulBlocks;
import galena.blissful.index.BlissfuItems;
import galena.blissful.platform.Services;
import net.minecraft.core.registries.Registries;

public class BlissfulCommon {

public static void init() {
BlissfulEffects.register();
BlissfulBlocks.register();
BlissfuItems.register();

Services.PLATFORM.getRegistrate().addRegisterCallback(Registries.POTION, BlissfulBrewing::register);
}

}
35 changes: 35 additions & 0 deletions common/src/main/java/galena/blissful/compat/BlissfulJeiPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package galena.blissful.compat;

import galena.blissful.BlissfulConstants;
import galena.blissful.index.BlissfuItems;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
import mezz.jei.api.registration.ISubtypeRegistration;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.PotionUtils;

@JeiPlugin
public class BlissfulJeiPlugin implements IModPlugin {

private static final ResourceLocation ID = new ResourceLocation(BlissfulConstants.MOD_ID, "jei");

private static final IIngredientSubtypeInterpreter<ItemStack> POTION_INTERPRETER = (ingredient, context) -> {
var potion = PotionUtils.getPotion(ingredient);
var effects = PotionUtils.getMobEffects(ingredient);
var builder = new StringBuilder(potion.getName(""));
effects.forEach(it -> builder.append(";").append(it));
return builder.toString();
};

@Override
public ResourceLocation getPluginUid() {
return ID;
}

@Override
public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.registerSubtypeInterpreter(BlissfuItems.POTION_BONG.get(), POTION_INTERPRETER);
}
}
13 changes: 13 additions & 0 deletions common/src/main/java/galena/blissful/index/BlissfuItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import galena.blissful.world.item.BongItem;
import galena.blissful.world.item.JointItem;
import galena.blissful.world.item.LazyFoodItem;
import galena.blissful.world.item.PotionBongItem;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemNameBlockItem;
import net.minecraft.world.item.Items;

public class BlissfuItems {

Expand All @@ -36,6 +38,7 @@ public class BlissfuItems {
.item("weed", Item::new)
.tab(CreativeModeTabs.FOOD_AND_DRINKS)
.recipe((c, p) -> {
p.smelting(DataIngredient.items(HEMP.get()), RecipeCategory.MISC, c, 0.25F);
p.smoking(DataIngredient.items(HEMP.get()), RecipeCategory.MISC, c, 0.25F);
p.campfire(DataIngredient.items(HEMP.get()), RecipeCategory.MISC, c, 0.25F);
})
Expand All @@ -54,6 +57,8 @@ public class BlissfuItems {
.recipe((c, p) -> ShapelessRecipeBuilder
.shapeless(RecipeCategory.FOOD, c.get())
.requires(HEMP_SEEDS)
.requires(Items.WHEAT)
.requires(Items.COCOA_BEANS)
.unlockedBy("has_hemp_seed", RegistrateRecipeProvider.has(HEMP_SEEDS))
.save(p)
)
Expand All @@ -62,6 +67,14 @@ public class BlissfuItems {
public static final ItemEntry<BongItem> BONG = REGISTRATE
.item("bong", BongItem::new)
.tab(CreativeModeTabs.FOOD_AND_DRINKS)
.properties(it -> it.stacksTo(1))
.register();

public static final ItemEntry<PotionBongItem> POTION_BONG = REGISTRATE
.item("potion_bong", PotionBongItem::new)
.tab(CreativeModeTabs.FOOD_AND_DRINKS)
.properties(it -> it.stacksTo(1))
.model((c, p) -> p.generated(c, p.modLoc("item/bong_potion"), p.modLoc("item/bong_potion_overlay")))
.register();

private static final NonNullSupplier<FoodProperties> JOINT_FOOD = NonNullSupplier.lazy(() -> new FoodProperties.Builder()
Expand Down
53 changes: 53 additions & 0 deletions common/src/main/java/galena/blissful/index/BlissfulBrewing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package galena.blissful.index;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionBrewing;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.ItemLike;

import static galena.blissful.platform.Services.BREWING;

public class BlissfulBrewing {

private static ItemStack withPotion(ItemLike item, Potion potion) {
var stack = new ItemStack(item);
PotionUtils.setPotion(stack, potion);
return stack;
}

private static void registerMix(ItemStack ingredient, ItemStack from) {
var input = PotionUtils.getPotion(from) == Potions.WATER ? BlissfuItems.BONG.asStack() : from;
var output = PotionBrewing.mix(ingredient, from);
if (output == from) return;
BREWING.addRecipe(Ingredient.of(input), Ingredient.of(ingredient), output);
}

private static void registerBongRecipes() {
var waterBottle = withPotion(Items.POTION, Potions.WATER);

BREWING.addRecipe(Ingredient.of(waterBottle), Ingredient.of(BlissfuItems.WEED), BlissfuItems.BONG.asStack());

var catalysts = BuiltInRegistries.ITEM.stream()
.map(ItemStack::new)
.filter(PotionBrewing::isIngredient)
.toList();

BuiltInRegistries.POTION.stream().forEach(potion -> {
var from = withPotion(BlissfuItems.POTION_BONG, potion);
var potionStack = withPotion(Items.POTION, potion);
catalysts.stream()
.filter(it -> PotionBrewing.hasMix(potionStack, it))
.forEach(catalyst -> registerMix(catalyst, from));
});
}

public static void register() {
registerBongRecipes();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public class BlissfulEffects {
.generic("peace", Registries.MOB_EFFECT, PeaceMobEffect::new)
.register();

//public static final RegistryEntry<Potion> PEACE_POTION = REGISTRATE
// .generic("peace", Registries.POTION, () -> new Potion(new MobEffectInstance(PEACE.get())))
// .register();

public static void register() {
// loads this class
}
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/java/galena/blissful/platform/Services.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package galena.blissful.platform;

import galena.blissful.platform.services.IBrewingRegistry;
import galena.blissful.platform.services.IDataGenHelper;
import galena.blissful.platform.services.IPlatformHelper;

Expand All @@ -9,6 +10,7 @@ public class Services {

public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
public static final IDataGenHelper DATAGEN = load(IDataGenHelper.class);
public static final IBrewingRegistry BREWING = load(IBrewingRegistry.class);

private static <T> T load(Class<T> clazz) {
return ServiceLoader.load(clazz)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package galena.blissful.platform.services;

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;

public interface IBrewingRegistry {

void addRecipe(Ingredient input, Ingredient ingredient, ItemStack output);

}
14 changes: 11 additions & 3 deletions common/src/main/java/galena/blissful/world/item/BongItem.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package galena.blissful.world.item;

import galena.blissful.index.BlissfulEffects;
import net.minecraft.network.chat.Component;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.stream.Stream;

public class BongItem extends SmokingItem {
Expand All @@ -16,7 +20,11 @@ public BongItem(Properties properties) {
}

@Override
Stream<MobEffectInstance> getEffects(ItemStack stack, Level level, LivingEntity entity) {
return PotionUtils.getMobEffects(stack).stream();
Stream<MobEffectInstance> getEffects(ItemStack stack, @Nullable Level level, @Nullable LivingEntity entity) {
return Stream.of(new MobEffectInstance(BlissfulEffects.PEACE.get(), 100, 0));
}

public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag) {
PotionUtils.addPotionTooltip(getEffects(stack, level, null).toList(), tooltip, 1.0F);
}
}
Loading

0 comments on commit d221e73

Please sign in to comment.