-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
144 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package breadmod.recipe | ||
|
||
import breadmod.item.DopedBreadItem | ||
import breadmod.registry.recipe.ModRecipeSerializers.DOPED_BREAD_CRAFTING | ||
import breadmod.util.applyColor | ||
import net.minecraft.core.RegistryAccess | ||
import net.minecraft.resources.ResourceLocation | ||
import net.minecraft.world.inventory.CraftingContainer | ||
import net.minecraft.world.item.ItemStack | ||
import net.minecraft.world.item.PotionItem | ||
import net.minecraft.world.item.alchemy.PotionUtils | ||
import net.minecraft.world.item.crafting.CraftingBookCategory | ||
import net.minecraft.world.item.crafting.CustomRecipe | ||
import net.minecraft.world.item.crafting.RecipeSerializer | ||
import net.minecraft.world.level.Level | ||
import java.awt.Color | ||
|
||
class DopedBreadRecipe(pId: ResourceLocation, pCategory: CraftingBookCategory) : CustomRecipe(pId, pCategory) { | ||
// override fun matches(pContainer: CraftingContainer, pLevel: Level): Boolean { | ||
// var hasItem = false; var hasEffect = false | ||
// for (slot in 0 until pContainer.containerSize ) { | ||
// pContainer.getItem(slot).also { stack -> | ||
// if(stack.isEmpty) { | ||
// return false | ||
// } | ||
// else if(stack.`is`(Items.BREAD.asItem())) { | ||
// hasItem = true | ||
// } | ||
// else if (stack.`is`(Items.POTION)) { | ||
// hasEffect = true | ||
// } | ||
// else return false | ||
// } | ||
// } | ||
// | ||
// return hasItem && hasEffect | ||
// } | ||
// | ||
// override fun assemble(pContainer: CraftingContainer, pRegistryAccess: RegistryAccess): ItemStack { | ||
// val itemStack = ItemStack(ModItems.DOPED_BREAD.get(), 1) | ||
// for (slot in 0 until pContainer.containerSize) { | ||
// pContainer.getItem(slot).also { stack -> | ||
// PotionUtils.setPotion(itemStack, PotionUtils.getPotion(stack)) | ||
// PotionUtils.setCustomEffects(itemStack, PotionUtils.getCustomEffects(stack)) | ||
// } | ||
// } | ||
// return itemStack | ||
// } | ||
|
||
override fun matches(pContainer: CraftingContainer, pLevel: Level): Boolean { | ||
var hasItem = false; var hasEffect = false | ||
for (slot in 0 until pContainer.containerSize) { | ||
pContainer.getItem(slot).also { stack -> | ||
if(!stack.isEmpty) when(stack.item) { | ||
is PotionItem -> { | ||
if(hasEffect) return false | ||
PotionUtils.getPotion(stack).effects.also { | ||
if(it.size != 1 || it.firstOrNull()?.effect?.isInstantenous == true) return false } | ||
hasEffect = true | ||
} | ||
is DopedBreadItem -> { | ||
if(hasItem ||stack.tag?.contains("Potion") == true) return false | ||
hasItem = true | ||
} | ||
else -> return false | ||
} | ||
} | ||
} | ||
|
||
return hasItem && hasEffect | ||
} | ||
|
||
override fun assemble(pContainer: CraftingContainer, pRegistryAccess: RegistryAccess): ItemStack { | ||
var itemStack: ItemStack = ItemStack.EMPTY | ||
val potions = buildList { | ||
for (slot in 0 until pContainer.containerSize) { | ||
val stack = pContainer.getItem(slot) | ||
when(stack.item) { | ||
is PotionItem -> addAll(PotionUtils.getPotion(stack).effects) | ||
is DopedBreadItem -> if(itemStack.isEmpty) itemStack = stack else return ItemStack.EMPTY | ||
} | ||
} | ||
} | ||
|
||
return if(!itemStack.isEmpty && potions.isNotEmpty()) | ||
itemStack.copy().also { stack -> | ||
// stack.applyColor(Color(PotionUtils.getColor(potions))) | ||
PotionUtils.setPotion(stack, PotionUtils.getPotion(stack)) | ||
PotionUtils.setCustomEffects(stack, potions) | ||
} | ||
else ItemStack.EMPTY | ||
} | ||
|
||
|
||
override fun canCraftInDimensions(pWidth: Int, pHeight: Int): Boolean = (pWidth * pHeight) >= 2 | ||
|
||
override fun getSerializer(): RecipeSerializer<*> = DOPED_BREAD_CRAFTING.get() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
BIN
+351 Bytes
src/main/resources/assets/breadmod/textures/item/doped_bread_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.