Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
feat: added ice cream (#54)
Browse files Browse the repository at this point in the history
* feat: added ice cream

---------

Co-authored-by: Drew Edwards <github@drew.contact>
  • Loading branch information
wiggle1000 and Lemmmy authored Mar 11, 2024
1 parent f24d995 commit ced16e3
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 7 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/generated/resources/assets/sc-goodies/lang/en_us.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 19 additions & 3 deletions src/main/kotlin/io/sc3/goodies/Registration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,25 @@ object Registration {
val dragonScale = rItem("dragon_scale", BaseItem(itemSettings()
.maxCount(16)
.rarity(EPIC)))
val popcorn = rItem("popcorn", PopcornItem(itemSettings()
.food(PopcornItem.foodComponent)
.maxCount(1)))
val ancientTome = rItem("ancient_tome", AncientTomeItem(itemSettings()
.maxCount(1)
.rarity(UNCOMMON)))

val popcorn = rItem("popcorn", PopcornItem(itemSettings()
.food(PopcornItem.foodComponent)
.maxCount(1)))
val iceCreamVanilla = rIceCreamItem("icecream_vanilla")
val iceCreamChocolate = rIceCreamItem("icecream_chocolate")
val iceCreamSweetBerry = rIceCreamItem("icecream_sweetberry")
val iceCreamNeapolitan = rIceCreamItem("icecream_neapolitan")
val iceCreamSpruce = rIceCreamItem("icecream_spruce")
val iceCreamMelon = rIceCreamItem("icecream_melon")
val iceCreamBeetroot = rIceCreamItem("icecream_beetroot")
// This is a bit messy, but a much simpler way to have the sundae be worth more food
val iceCreamSundae = rItem("icecream_sundae", IceCreamItem(itemSettings()
.food(FoodComponent.Builder().hunger(7).saturationModifier(8.0f).alwaysEdible().build())
.maxCount(16)))

val dimmableLight = rItem(ModBlocks.dimmableLight, ::BlockItem, itemSettings())

// TODO: Clean up
Expand All @@ -414,6 +426,10 @@ object Registration {
fun <T : Item> rItem(name: String, value: T): T =
register(ITEM, ModId(name), value).also { items.add(it) }

private fun rIceCreamItem(name: String): Item = rItem(name, IceCreamItem(itemSettings()
.food(IceCreamItem.foodComponent)
.maxCount(16)))

fun <B : Block, I : Item> rItem(parent: B, supplier: (B, Item.Settings) -> I,
settings: Item.Settings = itemSettings()): I {
val item = register(ITEM, BLOCK.getId(parent), supplier(parent, settings))
Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/io/sc3/goodies/datagen/LanguageProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ class LanguageProvider(out: FabricDataOutput) : FabricLanguageProvider(out) {
builder.add(ModItems.popcorn, "Popcorn")
builder.sub(ModItems.popcorn, "A bottomless bag of popcorn.")


builder.add(ModItems.iceCreamVanilla, "Vanilla Ice Cream")
builder.sub(ModItems.iceCreamVanilla, "A delicious treat!")
builder.add(ModItems.iceCreamChocolate, "Chocolate Ice Cream")
builder.sub(ModItems.iceCreamChocolate, "A delicious treat!")
builder.add(ModItems.iceCreamSweetBerry, "Sweet Berry Ice Cream")
builder.sub(ModItems.iceCreamSweetBerry, "A delicious treat!")
builder.add(ModItems.iceCreamNeapolitan, "Neapolitan Ice Cream")
builder.sub(ModItems.iceCreamNeapolitan, "Vanilla, Chocolate, and Sweet Berry.")
builder.add(ModItems.iceCreamSpruce, "Spruce Ice Cream")
builder.sub(ModItems.iceCreamSpruce, "A refreshing treat!")
builder.add(ModItems.iceCreamMelon, "Melon Ice Cream")
builder.sub(ModItems.iceCreamMelon, "A delicious treat!")
builder.add(ModItems.iceCreamBeetroot, "Beetroot Ice Cream")
builder.sub(ModItems.iceCreamBeetroot, "An earthy treat!")
builder.add(ModItems.iceCreamSundae, "Triple Gooberberry Sunrise")
builder.sub(ModItems.iceCreamSundae, "A suspiciously familiar sundae.")

builder.add(ModItems.glassItemFrame, "Glass Item Frame")
builder.sub(ModItems.glassItemFrame, "An item frame with an invisible background when it contains an item.")
builder.add(ModItems.glowGlassItemFrame, "Glow Glass Item Frame")
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/io/sc3/goodies/datagen/ModelProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ class ModelProvider(out: FabricDataOutput) : FabricModelProvider(out) {
gen.register(ModItems.glassItemFrame, GENERATED)
gen.register(ModItems.glowGlassItemFrame, GENERATED)

gen.register(ModItems.iceCreamVanilla, GENERATED)
gen.register(ModItems.iceCreamChocolate, GENERATED)
gen.register(ModItems.iceCreamSweetBerry, GENERATED)
gen.register(ModItems.iceCreamNeapolitan, GENERATED)
gen.register(ModItems.iceCreamSpruce, GENERATED)
gen.register(ModItems.iceCreamMelon, GENERATED)
gen.register(ModItems.iceCreamBeetroot, GENERATED)
gen.register(ModItems.iceCreamSundae, GENERATED)

// Dyed + Special Elytra
DyedElytraItem.dyedElytraItems.values
.forEach { gen.register(it, GENERATED) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package io.sc3.goodies.datagen.recipes.handlers

import io.sc3.goodies.Registration.ModItems
import io.sc3.library.recipe.RecipeHandler
import net.minecraft.data.server.recipe.RecipeJsonProvider
import net.minecraft.data.server.recipe.RecipeProvider
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder
import net.minecraft.item.Item
import net.minecraft.item.Items.*
import net.minecraft.recipe.Ingredient
import net.minecraft.recipe.book.RecipeCategory
import net.minecraft.registry.Registries
import java.util.function.Consumer

object IceCreamRecipes : RecipeHandler {
fun iceCreamRecipe(ingredientA: Ingredient, ingredientB: Ingredient, makes: Item, exporter: Consumer<RecipeJsonProvider>) {
ShapedRecipeJsonBuilder
.create(RecipeCategory.FOOD, makes)
.pattern("ASB")
.pattern("SsS")
.pattern("mbe")
.input('S', SNOWBALL)
.input('s', SUGAR)
.input('m', MILK_BUCKET)
.input('b', BOWL)
.input('e', EGG)
.input('A', ingredientA)
.input('B', ingredientB)
.criterion("has_snowball", RecipeProvider.conditionsFromItem(SNOWBALL))
.offerTo(exporter)
ShapelessRecipeJsonBuilder
.create(RecipeCategory.FOOD, makes)
.input(ModItems.iceCreamVanilla)
.input(ingredientA)
.input(ingredientB)
.criterion("has_icecream_vanilla", RecipeProvider.conditionsFromItem(ModItems.iceCreamVanilla))
.offerTo(exporter, Registries.ITEM.getId(makes.asItem()).path + "_from_vanilla")
}

override fun generateRecipes(exporter: Consumer<RecipeJsonProvider>) {
// Ice Cream
ShapedRecipeJsonBuilder
.create(RecipeCategory.FOOD, ModItems.iceCreamVanilla)
.pattern(" S ")
.pattern("SsS")
.pattern("mbe")
.input('S', SNOWBALL)
.input('s', SUGAR)
.input('m', MILK_BUCKET)
.input('b', BOWL)
.input('e', EGG)
.criterion("has_snowball", RecipeProvider.conditionsFromItem(SNOWBALL))
.offerTo(exporter)

iceCreamRecipe(
Ingredient.ofItems(COCOA_BEANS),
Ingredient.ofItems(COCOA_BEANS),
ModItems.iceCreamChocolate, exporter
)
iceCreamRecipe(
Ingredient.ofItems(SWEET_BERRIES),
Ingredient.ofItems(SWEET_BERRIES),
ModItems.iceCreamSweetBerry, exporter
)
iceCreamRecipe(
Ingredient.ofItems(SPRUCE_SAPLING, SPRUCE_LEAVES),
Ingredient.ofItems(SPRUCE_SAPLING, SPRUCE_LEAVES),
ModItems.iceCreamSpruce, exporter
)
iceCreamRecipe(
Ingredient.ofItems(MELON_SLICE),
Ingredient.ofItems(MELON_SLICE),
ModItems.iceCreamMelon, exporter
)
iceCreamRecipe(
Ingredient.ofItems(BEETROOT),
Ingredient.ofItems(BEETROOT),
ModItems.iceCreamBeetroot, exporter
)

//Sundae Recipe
ShapedRecipeJsonBuilder
.create(RecipeCategory.FOOD, ModItems.iceCreamSundae)
.pattern(" b ")
.pattern("bSb")
.pattern("SvS")
.input('v', ModItems.iceCreamVanilla)
.input('S', GOLDEN_CARROT)
.input('b', SWEET_BERRIES)
.criterion("has_icecream_vanilla", RecipeProvider.conditionsFromItem(ModItems.iceCreamVanilla))
.offerTo(exporter)
//Neapolitan Recipe
ShapelessRecipeJsonBuilder
.create(RecipeCategory.FOOD, ModItems.iceCreamNeapolitan, 3)
.input(ModItems.iceCreamVanilla)
.input(ModItems.iceCreamChocolate)
.input(ModItems.iceCreamSweetBerry)
.criterion("has_icecream_vanilla", RecipeProvider.conditionsFromItem(ModItems.iceCreamVanilla))
.criterion("has_icecream_chocolate", RecipeProvider.conditionsFromItem(ModItems.iceCreamChocolate))
.criterion("has_icecream_sweetberry", RecipeProvider.conditionsFromItem(ModItems.iceCreamSweetBerry))
.offerTo(exporter)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ val RECIPE_HANDLERS by lazy { listOf(
ItemFrameRecipes,
AmethystRecipes,
DimmableLightRecipe,
ColorfulGrassRecipes
ColorfulGrassRecipes,
IceCreamRecipes
)}
35 changes: 35 additions & 0 deletions src/main/kotlin/io/sc3/goodies/misc/IceCreamItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.sc3.goodies.misc

import net.minecraft.entity.LivingEntity
import net.minecraft.item.FoodComponent
import net.minecraft.item.ItemStack
import net.minecraft.world.World
import io.sc3.goodies.util.BaseItem
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.Items

class IceCreamItem(settings: Settings) : BaseItem(settings) {
override fun finishUsing(stack: ItemStack, world: World, user: LivingEntity): ItemStack {
// Return Bowl
if (user is PlayerEntity && !user.isCreative) {
user.inventory.offerOrDrop(ItemStack(Items.BOWL))
}
return super.finishUsing(stack, world, user)
}

override fun usageTick(world: World?, user: LivingEntity?, stack: ItemStack?, remainingUseTicks: Int) {
// if player is eating while full hunger, start doing brainfreeze!
if (user is PlayerEntity && !user.isCreative && !user.hungerManager.isNotFull) {
user.frozenTicks += 3
}
super.usageTick(world, user, stack, remainingUseTicks)
}

companion object {
val foodComponent: FoodComponent = FoodComponent.Builder()
.hunger(4)
.saturationModifier(5.0f)
.alwaysEdible()
.build()
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ced16e3

Please sign in to comment.