Skip to content

Commit

Permalink
Merge pull request #429 from OKTW-Network/rewrite-recipe
Browse files Browse the repository at this point in the history
Rewrite recipe
  • Loading branch information
mergify[bot] authored Jan 4, 2024
2 parents 5e5460e + 2954029 commit cf17e70
Show file tree
Hide file tree
Showing 35 changed files with 140 additions and 2,057 deletions.
2 changes: 1 addition & 1 deletion docker
Submodule docker updated 1 files
+2 −0 Dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* OKTW Galaxy Project
* Copyright (C) 2018-2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package one.oktw.galaxy.mixin.tweak;

import net.minecraft.resource.VanillaDataPackProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

import java.nio.file.Path;

@Mixin(VanillaDataPackProvider.class)
public class MixinGlobalDataPack_VanillaDataPackProvider {
@ModifyArg(method = "createManager(Lnet/minecraft/world/level/storage/LevelStorage$Session;)Lnet/minecraft/resource/ResourcePackManager;", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/VanillaDataPackProvider;createManager(Ljava/nio/file/Path;Lnet/minecraft/util/path/SymlinkFinder;)Lnet/minecraft/resource/ResourcePackManager;"), index = 0)
private static Path moveDataPackPath(Path dataPacksPath) {
return Path.of("datapacks");
}
}
22 changes: 0 additions & 22 deletions src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import one.oktw.galaxy.recipe.blocks.Elevator
import one.oktw.galaxy.recipe.blocks.HTCraftingTable
import one.oktw.galaxy.recipe.blocks.Harvest
import one.oktw.galaxy.recipe.blocks.Trashcan
import one.oktw.galaxy.recipe.easyRecipe.*
import one.oktw.galaxy.recipe.materials.CeramicPlate
import one.oktw.galaxy.recipe.tools.Crowbar
import one.oktw.galaxy.recipe.tools.Wrench
Expand All @@ -40,26 +39,5 @@ object RecipeRegistry {
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "block/harvest"), Harvest())
CustomRecipeManager.addRecipe(RecipeType.SMELTING, Identifier("galaxy", "material/ceramic_plate"), CeramicPlate())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "block/trashcan"), Trashcan())
// Easy Recipe
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/ladder"), Ladder())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/chest"), Chest())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/hopper"), Hopper())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/redstone_lamp"), RedStoneLamp())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/dispenser"), Dispenser())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/dispenser_with_bow"), DispenserWithBow())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/redstone_repeater"), RedStoneRepeater())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/trapped_chest"), TrappedChest())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/carrot_on_a_stick"), CarrotOnAStick())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/warped_fungus_on_a_stick"), WarpedFungusOnAStick())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/writable_book"), BookAndQuill())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/minecart"), Minecart())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stick"), Stick())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass"), Glass())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass_pane"), GlassPane())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass_pane_restore"), GlassPaneRestore())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stained_glass_restore"), StainedGlassRestore())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stained_glass_pane_restore"), StainedGlassPaneRestore())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/wood_slab"), WoodenSlab())
CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/slab_restore"), SlabRestore())
}
}
40 changes: 9 additions & 31 deletions src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,16 @@

package one.oktw.galaxy.recipe.blocks

import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.inventory.RecipeInputInventory
import net.minecraft.item.Items
import net.minecraft.recipe.CraftingRecipe
import net.minecraft.recipe.RecipeSerializer
import net.minecraft.recipe.Ingredient
import net.minecraft.recipe.ShapelessRecipe
import net.minecraft.recipe.book.CraftingRecipeCategory
import net.minecraft.registry.DynamicRegistryManager
import net.minecraft.world.World
import net.minecraft.util.collection.DefaultedList
import one.oktw.galaxy.item.CustomBlockItem
import one.oktw.galaxy.recipe.utils.Ingredient
import one.oktw.galaxy.recipe.utils.RecipeUtils

class Elevator : CraftingRecipe {
private val item = CustomBlockItem.ELEVATOR.createItemStack()
private val list =
listOf(Ingredient(items = listOf(Items.ENDER_PEARL)), Ingredient(items = listOf(Items.IRON_BLOCK)))

override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapelessMatches(inv, list)

override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy()

@Environment(EnvType.CLIENT)
override fun fits(width: Int, height: Int): Boolean {
throw NotImplementedError()
}

override fun getResult(registryManager: DynamicRegistryManager) = item

override fun getSerializer(): RecipeSerializer<*> {
TODO("Not yet implemented, support client mod.")
}

override fun getCategory() = CraftingRecipeCategory.BUILDING
}
class Elevator : ShapelessRecipe(
"",
CraftingRecipeCategory.EQUIPMENT,
CustomBlockItem.ELEVATOR.createItemStack(),
DefaultedList.copyOf(Ingredient.EMPTY, Ingredient.ofItems(Items.ENDER_PEARL), Ingredient.ofItems(Items.IRON_BLOCK))
)
62 changes: 21 additions & 41 deletions src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,28 @@

package one.oktw.galaxy.recipe.blocks

import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.inventory.RecipeInputInventory
import net.minecraft.item.Items
import net.minecraft.recipe.CraftingRecipe
import net.minecraft.recipe.RecipeSerializer
import net.minecraft.recipe.Ingredient
import net.minecraft.recipe.RawShapedRecipe
import net.minecraft.recipe.ShapedRecipe
import net.minecraft.recipe.book.CraftingRecipeCategory
import net.minecraft.registry.DynamicRegistryManager
import net.minecraft.world.World
import one.oktw.galaxy.item.CustomBlockItem
import one.oktw.galaxy.recipe.utils.Ingredient
import one.oktw.galaxy.recipe.utils.RecipeUtils

class HTCraftingTable : CraftingRecipe {
private val item = CustomBlockItem.HT_CRAFTING_TABLE.createItemStack()

private val redStone = Ingredient(items = listOf(Items.REDSTONE))
private val diamond = Ingredient(items = listOf(Items.DIAMOND))
private val lapisLazuli = Ingredient(items = listOf(Items.LAPIS_LAZULI))
private val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT))
private val obsidian = Ingredient(items = listOf(Items.OBSIDIAN))
private val craftingTable = Ingredient(items = listOf(Items.CRAFTING_TABLE))
private val list = listOf(
redStone, diamond, lapisLazuli,
ironIngot, craftingTable, ironIngot,
lapisLazuli, obsidian, redStone
)

override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list)

override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy()

@Environment(EnvType.CLIENT)
override fun fits(width: Int, height: Int): Boolean {
throw NotImplementedError()
}

override fun getResult(registryManager: DynamicRegistryManager) = item

override fun getSerializer(): RecipeSerializer<*> {
TODO("Not yet implemented, support client mod.")
}

override fun getCategory() = CraftingRecipeCategory.BUILDING
}
class HTCraftingTable : ShapedRecipe(
"",
CraftingRecipeCategory.BUILDING,
RawShapedRecipe.create(
mapOf(
Character.valueOf('r') to Ingredient.ofItems(Items.REDSTONE),
Character.valueOf('d') to Ingredient.ofItems(Items.DIAMOND),
Character.valueOf('l') to Ingredient.ofItems(Items.LAPIS_LAZULI),
Character.valueOf('i') to Ingredient.ofItems(Items.IRON_INGOT),
Character.valueOf('c') to Ingredient.ofItems(Items.CRAFTING_TABLE),
Character.valueOf('o') to Ingredient.ofItems(Items.OBSIDIAN),
),
"rdl",
"ici",
"lor"
),
CustomBlockItem.HT_CRAFTING_TABLE.createItemStack()
)
57 changes: 18 additions & 39 deletions src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,25 @@

package one.oktw.galaxy.recipe.blocks

import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.inventory.RecipeInputInventory
import net.minecraft.item.ItemStack
import net.minecraft.item.Items
import net.minecraft.recipe.CraftingRecipe
import net.minecraft.recipe.RecipeSerializer
import net.minecraft.recipe.Ingredient.ofItems
import net.minecraft.recipe.RawShapedRecipe
import net.minecraft.recipe.ShapedRecipe
import net.minecraft.recipe.book.CraftingRecipeCategory
import net.minecraft.registry.DynamicRegistryManager
import net.minecraft.world.World
import one.oktw.galaxy.item.CustomBlockItem
import one.oktw.galaxy.recipe.utils.Ingredient
import one.oktw.galaxy.recipe.utils.RecipeUtils

class Harvest : CraftingRecipe {
private val item = CustomBlockItem.HARVEST.createItemStack()

private val copper = Ingredient(items = listOf(Items.COPPER_INGOT))
private val observer = Ingredient(items = listOf(Items.OBSERVER))
private val dispenser = Ingredient(items = listOf(Items.DISPENSER))
private val list = listOf(
copper, copper, copper,
copper, dispenser, observer,
copper, copper, copper
)

override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list)

override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack = item.copy()

@Environment(EnvType.CLIENT)
override fun fits(width: Int, height: Int): Boolean {
throw NotImplementedError()
}

override fun getResult(registryManager: DynamicRegistryManager) = item

override fun getSerializer(): RecipeSerializer<*> {
TODO("Not implemented client mod")
}

override fun getCategory() = CraftingRecipeCategory.BUILDING
}
class Harvest : ShapedRecipe(
"",
CraftingRecipeCategory.BUILDING,
RawShapedRecipe.create(
mapOf(
Character.valueOf('c') to ofItems(Items.COPPER_INGOT),
Character.valueOf('o') to ofItems(Items.OBSERVER),
Character.valueOf('d') to ofItems(Items.DISPENSER),
),
"ccc",
"cdo",
"ccc"
),
CustomBlockItem.HARVEST.createItemStack()
)
58 changes: 19 additions & 39 deletions src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,26 @@

package one.oktw.galaxy.recipe.blocks

import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.minecraft.inventory.RecipeInputInventory
import net.minecraft.item.Items
import net.minecraft.recipe.CraftingRecipe
import net.minecraft.recipe.RecipeSerializer
import net.minecraft.recipe.Ingredient.ofItems
import net.minecraft.recipe.RawShapedRecipe
import net.minecraft.recipe.ShapedRecipe
import net.minecraft.recipe.book.CraftingRecipeCategory
import net.minecraft.registry.DynamicRegistryManager
import net.minecraft.world.World
import one.oktw.galaxy.item.CustomBlockItem
import one.oktw.galaxy.recipe.utils.Ingredient
import one.oktw.galaxy.recipe.utils.RecipeUtils

class Trashcan : CraftingRecipe {
private val item = CustomBlockItem.TRASHCAN.createItemStack()

private val glass = Ingredient(items = listOf(Items.GLASS))
private val cactus = Ingredient(items = listOf(Items.CACTUS))
private val terracotta = Ingredient(items = listOf(Items.TERRACOTTA))
private val sand = Ingredient(items = listOf(Items.SAND, Items.RED_SAND))
private val list = listOf(
glass, glass, glass,
glass, cactus, glass,
terracotta, sand, terracotta
)

override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list)

override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy()

@Environment(EnvType.CLIENT)
override fun fits(width: Int, height: Int): Boolean {
throw NotImplementedError()
}

override fun getResult(registryManager: DynamicRegistryManager) = item

override fun getSerializer(): RecipeSerializer<*> {
TODO("Not yet implemented, support client mod.")
}

override fun getCategory() = CraftingRecipeCategory.MISC
}
class Trashcan : ShapedRecipe(
"",
CraftingRecipeCategory.BUILDING,
RawShapedRecipe.create(
mapOf(
Character.valueOf('g') to ofItems(Items.GLASS),
Character.valueOf('c') to ofItems(Items.CACTUS),
Character.valueOf('t') to ofItems(Items.TERRACOTTA),
Character.valueOf('s') to ofItems(Items.SAND, Items.RED_SAND)
),
"ggg",
"gcg",
"tst"
),
CustomBlockItem.TRASHCAN.createItemStack()
)
Loading

0 comments on commit cf17e70

Please sign in to comment.