Compare commits
2 Commits
12f7157dc7
...
d84c71f279
Author | SHA1 | Date | |
---|---|---|---|
d84c71f279 | |||
be32774d4c |
@ -9,56 +9,104 @@ import java.util.HashMap;
|
||||
|
||||
public class SpriteLoader {
|
||||
public enum SPRITES {
|
||||
// BLOCKS
|
||||
|
||||
// Blocks
|
||||
AIR,
|
||||
DIRT,
|
||||
GRASS,
|
||||
STEVE,
|
||||
STONE,
|
||||
BEDROCK,
|
||||
BREAKING,
|
||||
COBBLESTONE,
|
||||
FURNACE,
|
||||
WOOL,
|
||||
|
||||
CHEST,
|
||||
CRAFTING_TABLE,
|
||||
COAL_ORE,
|
||||
|
||||
OAK_LOG,
|
||||
OAK_LEAF,
|
||||
OAK_PLANKS,
|
||||
OAK_DOOR,
|
||||
|
||||
WOODEN_PICKAXE,
|
||||
STONE_PICKAXE,
|
||||
WOODEN_AXE,
|
||||
STONE_AXE,
|
||||
WOODEN_SHOVEL,
|
||||
STONE_SHOVEL,
|
||||
// Ores
|
||||
COAL_ORE,
|
||||
IRON_ORE, // NEWW
|
||||
GOLD_ORE, //NEWW
|
||||
// Add Coal Block
|
||||
IRON_BLOCK, // NEWW
|
||||
GOLD_BLOCK, // NEWW
|
||||
|
||||
// Items
|
||||
ITEM_DIRT,
|
||||
ITEM_OAK_LOG,
|
||||
ITEM_OAK_PLANKS,
|
||||
ITEM_STICK,
|
||||
ITEM_COBBLESTONE,
|
||||
ITEM_STONE,
|
||||
ITEM_FURNACE,
|
||||
ITEM_OAK_DOOR,
|
||||
ITEM_WOOL,
|
||||
|
||||
ITEM_CRAFTING_TABLE,
|
||||
ITEM_CHEST,
|
||||
|
||||
HEART,
|
||||
HUNGER,
|
||||
// Work
|
||||
FURNACE,
|
||||
CHEST,
|
||||
CRAFTING_TABLE,
|
||||
|
||||
// ENTITIES
|
||||
STEVE,
|
||||
PIG,
|
||||
SHEEP,
|
||||
|
||||
// UI
|
||||
BREAKING,
|
||||
HEART,
|
||||
HUNGER,
|
||||
|
||||
// ITEMS
|
||||
|
||||
// Items
|
||||
ITEM_STICK,
|
||||
|
||||
// Block Items
|
||||
ITEM_DIRT,
|
||||
ITEM_OAK_LOG,
|
||||
ITEM_OAK_PLANKS,
|
||||
ITEM_COBBLESTONE,
|
||||
ITEM_STONE,
|
||||
ITEM_OAK_DOOR,
|
||||
ITEM_WOOL,
|
||||
|
||||
// Ore Items
|
||||
ITEM_COAL_ORE,//NEWWW
|
||||
ITEM_IRON_ORE, //NEWWW
|
||||
ITEM_GOLD_ORE, // NEWW
|
||||
|
||||
// Add Item Coal Block
|
||||
ITEM_IRON_BLOCK, //NEWWW
|
||||
ITEM_GOLD_BLOCK, // NEWW
|
||||
|
||||
COAL, // NEWW
|
||||
ITEM_IRON_INGOT, //NEWW
|
||||
ITEM_GOLD_INGOT, // NEWW
|
||||
|
||||
// Work Items
|
||||
ITEM_CRAFTING_TABLE,
|
||||
ITEM_CHEST,
|
||||
ITEM_FURNACE,
|
||||
|
||||
// Weapons
|
||||
WOODEN_SWORD, //NEWWW
|
||||
WOODEN_PICKAXE,
|
||||
WOODEN_AXE,
|
||||
WOODEN_SHOVEL,
|
||||
WOODEN_HOE, //NEWW
|
||||
|
||||
STONE_SWORD,//NEWWW
|
||||
STONE_PICKAXE,
|
||||
STONE_AXE,
|
||||
STONE_SHOVEL,
|
||||
STONE_HOE, //NEWW
|
||||
|
||||
IRON_SWORD, //NEWWW
|
||||
IRON_PICKAXE, //NEWWW
|
||||
IRON_AXE, // NEWW
|
||||
IRON_SHOVEL, //NEWWW
|
||||
IRON_HOE, // NEWWW
|
||||
|
||||
GOLDEN_SWORD, // NEWW
|
||||
GOLDEN_PICKAXE, // NEWWW
|
||||
GOLDEN_AXE, //NEWWW
|
||||
GOLDEN_SHOVEL, //NEWWW
|
||||
GOLDEN_HOE, // NEWW
|
||||
|
||||
// Food
|
||||
ITEM_PORKCHOP,
|
||||
ITEM_COOKED_PORKCHOP,
|
||||
|
||||
ITEM_MUTTON,
|
||||
ITEM_COOKED_MUTTON,
|
||||
}
|
||||
@ -66,52 +114,114 @@ public class SpriteLoader {
|
||||
public static final HashMap<SPRITES, Sprite> SPRITES_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
// BLOCKS
|
||||
|
||||
// Block
|
||||
SPRITES_MAP.put(SPRITES.AIR, new Air());
|
||||
SPRITES_MAP.put(SPRITES.DIRT, new SimpleSprite("dirt.ans"));
|
||||
SPRITES_MAP.put(SPRITES.GRASS, new SimpleSprite("grass.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE, new SimpleSprite("stone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STEVE, new Steve());
|
||||
SPRITES_MAP.put(SPRITES.BEDROCK, new SimpleSprite("bedrock.ans"));
|
||||
SPRITES_MAP.put(SPRITES.BREAKING, new Breaking());
|
||||
SPRITES_MAP.put(SPRITES.OAK_LOG, new SimpleSprite("oak_log.ans"));
|
||||
SPRITES_MAP.put(SPRITES.OAK_LEAF, new SimpleSprite("oak_leaf.ans"));
|
||||
SPRITES_MAP.put(SPRITES.OAK_PLANKS, new SimpleSprite("oak_planks.ans"));
|
||||
SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans"));
|
||||
SPRITES_MAP.put(SPRITES.CHEST, new SimpleSprite("chest.ans"));
|
||||
SPRITES_MAP.put(SPRITES.COBBLESTONE, new SimpleSprite("cobblestone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.FURNACE, new Furnace());
|
||||
SPRITES_MAP.put(SPRITES.COAL_ORE, new SimpleSprite("coal_ore.ans"));
|
||||
SPRITES_MAP.put(SPRITES.OAK_DOOR, new OakDoor());
|
||||
SPRITES_MAP.put(SPRITES.WOOL, new Wool());
|
||||
SPRITES_MAP.put(SPRITES.COBBLESTONE, new SimpleSprite("cobblestone.ans"));
|
||||
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_PICKAXE, new SimpleSprite("items/wooden_pickaxe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_PICKAXE, new SimpleSprite("items/stone_pickaxe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_AXE, new SimpleSprite("items/wooden_axe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_AXE, new SimpleSprite("items/stone_axe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_SHOVEL, new SimpleSprite("items/wooden_shovel.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_SHOVEL, new SimpleSprite("items/stone_shovel.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_DIRT, new SimpleSprite("items/dirt.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_LOG, new SimpleSprite("items/oak_log.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_PLANKS, new SimpleSprite("items/oak_planks.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_STICK, new SimpleSprite("items/stick.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_CRAFTING_TABLE, new SimpleSprite("items/crafting_table.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COBBLESTONE, new SimpleSprite("items/cobblestone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_STONE, new SimpleSprite("items/stone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_CHEST, new SimpleSprite("items/chest.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_FURNACE, new SimpleSprite("items/furnace.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_DOOR, new SimpleSprite("oak_door/items/oak_door.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_PORKCHOP, new SimpleSprite("items/porkchop.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_PORKCHOP, new SimpleSprite("items/cooked_porkchop.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_WOOL, new WoolItem());
|
||||
// Ores
|
||||
SPRITES_MAP.put(SPRITES.COAL_ORE, new SimpleSprite("coal_ore.ans"));
|
||||
SPRITES_MAP.put(SPRITES.IRON_ORE, new SimpleSprite("iron_ore.ans")); //NEWW
|
||||
SPRITES_MAP.put(SPRITES.GOLD_ORE, new SimpleSprite("gold_ore.ans")); //NEWW
|
||||
|
||||
SPRITES_MAP.put(SPRITES.ITEM_MUTTON, new SimpleSprite("items/mutton.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_MUTTON, new SimpleSprite("items/cooked_mutton.ans"));
|
||||
// Add Coal block
|
||||
SPRITES_MAP.put(SPRITES.IRON_BLOCK, new SimpleSprite("iron_block.ans")); //NEWW
|
||||
SPRITES_MAP.put(SPRITES.GOLD_BLOCK, new SimpleSprite("gold_block.ans")); //NEWW
|
||||
|
||||
// Work
|
||||
SPRITES_MAP.put(SPRITES.CRAFTING_TABLE, new SimpleSprite("crafting_table.ans"));
|
||||
SPRITES_MAP.put(SPRITES.FURNACE, new Furnace());
|
||||
SPRITES_MAP.put(SPRITES.CHEST, new SimpleSprite("chest.ans"));
|
||||
|
||||
// ENTITIES
|
||||
SPRITES_MAP.put(SPRITES.STEVE, new Steve());
|
||||
SPRITES_MAP.put(SPRITES.PIG, new Pig());
|
||||
SPRITES_MAP.put(SPRITES.SHEEP, new Sheep());
|
||||
|
||||
// UI
|
||||
SPRITES_MAP.put(SPRITES.BREAKING, new Breaking());
|
||||
SPRITES_MAP.put(SPRITES.HEART, new Heart());
|
||||
SPRITES_MAP.put(SPRITES.HUNGER, new Hunger());
|
||||
|
||||
SPRITES_MAP.put(SPRITES.PIG, new Pig());
|
||||
SPRITES_MAP.put(SPRITES.SHEEP, new Sheep());
|
||||
// ITEMS
|
||||
|
||||
// Items
|
||||
SPRITES_MAP.put(SPRITES.ITEM_STICK, new SimpleSprite("items/stick.ans"));
|
||||
|
||||
// Block Items
|
||||
SPRITES_MAP.put(SPRITES.ITEM_DIRT, new SimpleSprite("items/dirt.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_LOG, new SimpleSprite("items/oak_log.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_PLANKS, new SimpleSprite("items/oak_planks.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COBBLESTONE, new SimpleSprite("items/cobblestone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_STONE, new SimpleSprite("items/stone.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_OAK_DOOR, new SimpleSprite("oak_door/items/oak_door.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_WOOL, new WoolItem());
|
||||
|
||||
// Ore Items
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COAL_ORE, new SimpleSprite("items/coal_ore.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.ITEM_IRON_ORE, new SimpleSprite("items/iron_ore.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.ITEM_GOLD_ORE, new SimpleSprite("items/gold_ore.ans")); //NEWWW
|
||||
|
||||
// Add Item Coal Block
|
||||
SPRITES_MAP.put(SPRITES.ITEM_IRON_BLOCK, new SimpleSprite("items/iron_block.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.ITEM_GOLD_BLOCK, new SimpleSprite("items/gold_block.ans")); //NEWWW
|
||||
|
||||
SPRITES_MAP.put(SPRITES.COAL, new SimpleSprite("items/coal.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.ITEM_IRON_INGOT, new SimpleSprite("items/iron_ingot.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.ITEM_GOLD_INGOT, new SimpleSprite("items/gold_ingot.ans")); //NEWWW
|
||||
|
||||
// Work Items
|
||||
SPRITES_MAP.put(SPRITES.ITEM_CRAFTING_TABLE, new SimpleSprite("items/crafting_table.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_CHEST, new SimpleSprite("items/chest.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_FURNACE, new SimpleSprite("items/furnace.ans"));
|
||||
|
||||
// Weapons
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_SWORD, new SimpleSprite("items/wooden_sword.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_PICKAXE, new SimpleSprite("items/wooden_pickaxe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_AXE, new SimpleSprite("items/wooden_axe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_SHOVEL, new SimpleSprite("items/wooden_shovel.ans"));
|
||||
SPRITES_MAP.put(SPRITES.WOODEN_HOE, new SimpleSprite("items/wooden_hoe.ans")); //NEWWW
|
||||
|
||||
SPRITES_MAP.put(SPRITES.STONE_SWORD, new SimpleSprite("items/wooden_sword.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.STONE_PICKAXE, new SimpleSprite("items/stone_pickaxe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_AXE, new SimpleSprite("items/stone_axe.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_SHOVEL, new SimpleSprite("items/stone_shovel.ans"));
|
||||
SPRITES_MAP.put(SPRITES.STONE_HOE, new SimpleSprite("items/stone_hoe.ans")); //NEWWW
|
||||
|
||||
SPRITES_MAP.put(SPRITES.IRON_SWORD, new SimpleSprite("items/iron_sword.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.IRON_PICKAXE, new SimpleSprite("items/iron_pickaxe.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.IRON_AXE, new SimpleSprite("items/iron_axe.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.IRON_SHOVEL, new SimpleSprite("items/iron_shovel.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.IRON_HOE, new SimpleSprite("items/iron_hoe.ans")); //NEWWW
|
||||
|
||||
SPRITES_MAP.put(SPRITES.GOLDEN_SWORD, new SimpleSprite("items/golden_sword.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.GOLDEN_PICKAXE, new SimpleSprite("items/golden_pickaxe.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.GOLDEN_AXE, new SimpleSprite("items/golden_axe.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.GOLDEN_SHOVEL, new SimpleSprite("items/golden_shovel.ans")); //NEWWW
|
||||
SPRITES_MAP.put(SPRITES.GOLDEN_HOE, new SimpleSprite("items/golden_hoe.ans")); //NEWWW
|
||||
|
||||
// Food
|
||||
SPRITES_MAP.put(SPRITES.ITEM_PORKCHOP, new SimpleSprite("items/porkchop.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_PORKCHOP, new SimpleSprite("items/cooked_porkchop.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_MUTTON, new SimpleSprite("items/mutton.ans"));
|
||||
SPRITES_MAP.put(SPRITES.ITEM_COOKED_MUTTON, new SimpleSprite("items/cooked_mutton.ans"));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static SpriteList<SPRITES> load() {
|
||||
|
@ -0,0 +1,11 @@
|
||||
package cz.jzitnik.game.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CraftingRecipeRegistry {
|
||||
String[] recipe();
|
||||
String result();
|
||||
int amount();
|
||||
}
|
@ -2,6 +2,8 @@ package cz.jzitnik.game.crafting;
|
||||
|
||||
import cz.jzitnik.game.entities.items.InventoryItem;
|
||||
import cz.jzitnik.game.entities.items.ItemBlockSupplier;
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -9,97 +11,44 @@ public class CraftingRecipeList {
|
||||
private static final List<CraftingRecipe> recipes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
// Oak planks
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_log", null, null},
|
||||
{null, null, null},
|
||||
{null, null, null}
|
||||
}, () -> new InventoryItem(4, ItemBlockSupplier.getItem("oak_planks"))));
|
||||
registerRecipes();
|
||||
}
|
||||
|
||||
// Crafting table
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", "oak_planks", null},
|
||||
{"oak_planks", "oak_planks", null},
|
||||
{null, null, null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("crafting_table"))));
|
||||
private static void registerRecipes() {
|
||||
Reflections reflections = new Reflections("cz.jzitnik.game.crafting.recipes");
|
||||
Set<Class<?>> recipeClasses = reflections.getTypesAnnotatedWith(CraftingRecipeRegistry.class);
|
||||
|
||||
// Stick
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", null, null},
|
||||
{"oak_planks", null, null},
|
||||
{null, null, null}
|
||||
}, () -> new InventoryItem(4, ItemBlockSupplier.getItem("stick"))));
|
||||
for (Class<?> clazz : recipeClasses) {
|
||||
try {
|
||||
CraftingRecipeRegistry annotation = clazz.getAnnotation(CraftingRecipeRegistry.class);
|
||||
String[][] recipeGrid = convertTo2DGrid(annotation.recipe());
|
||||
|
||||
// Wooden pickaxe
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", "oak_planks", "oak_planks"},
|
||||
{null, "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_pickaxe"))));
|
||||
recipes.add(new CraftingRecipe(recipeGrid,
|
||||
() -> new InventoryItem(annotation.amount(), ItemBlockSupplier.getItem(annotation.result()))));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wooden axe
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", "oak_planks", null},
|
||||
{"oak_planks", "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_axe"))));
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{null, "oak_planks", "oak_planks"},
|
||||
{null, "stick", "oak_planks"},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_axe"))));
|
||||
private static String[][] convertTo2DGrid(String[] flatGrid) {
|
||||
int size = (int) Math.sqrt(flatGrid.length); // Assumes 3x3
|
||||
String[][] grid = new String[size][size];
|
||||
|
||||
// Stone pickaxe
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"cobblestone", "cobblestone", "cobblestone"},
|
||||
{null, "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_axe"))));
|
||||
for (int i = 0; i < size; i++) {
|
||||
System.arraycopy(flatGrid, i * size, grid[i], 0, size);
|
||||
}
|
||||
|
||||
// Stone axe
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"cobblestone", "cobblestone", null},
|
||||
{"cobblestone", "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_axe"))));
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{null, "cobblestone", "cobblestone"},
|
||||
{null, "stick", "cobblestone"},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_axe"))));
|
||||
// Convert "_" placeholders back to null
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int j = 0; j < size; j++) {
|
||||
if (grid[i][j].equals("_")) {
|
||||
grid[i][j] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Chest
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", "oak_planks", "oak_planks"},
|
||||
{"oak_planks", null, "oak_planks"},
|
||||
{"oak_planks", "oak_planks", "oak_planks"}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("chest"))));
|
||||
|
||||
// Wooden shovel
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{null, "oak_planks", null},
|
||||
{null, "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("wooden_shovel"))));
|
||||
|
||||
// Stone shovel
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{null, "cobblestone", null},
|
||||
{null, "stick", null},
|
||||
{null, "stick", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("stone_shovel"))));
|
||||
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"cobblestone", "cobblestone", "cobblestone"},
|
||||
{"cobblestone", null, "cobblestone"},
|
||||
{"cobblestone", "cobblestone", "cobblestone"}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("furnace"))));
|
||||
|
||||
recipes.add(new CraftingRecipe(new String[][]{
|
||||
{"oak_planks", "oak_planks", null},
|
||||
{"oak_planks", "oak_planks", null},
|
||||
{"oak_planks", "oak_planks", null}
|
||||
}, () -> new InventoryItem(1, ItemBlockSupplier.getItem("oak_door"))));
|
||||
return grid;
|
||||
}
|
||||
|
||||
public static Optional<CraftingRecipe> getRecipe(String[] r) {
|
||||
@ -115,7 +64,6 @@ public class CraftingRecipeList {
|
||||
int n = array.length;
|
||||
int minRow = n, maxRow = -1, minCol = n, maxCol = -1;
|
||||
|
||||
// Find the bounding box of non-null values
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (array[i][j] != null) {
|
||||
@ -127,7 +75,6 @@ public class CraftingRecipeList {
|
||||
}
|
||||
}
|
||||
|
||||
// If all elements are null, return an empty array
|
||||
if (maxRow == -1) {
|
||||
return new String[0][0];
|
||||
}
|
||||
@ -136,7 +83,6 @@ public class CraftingRecipeList {
|
||||
int newSizeCol = maxCol - minCol + 1;
|
||||
String[][] trimmedArray = new String[newSizeRow][newSizeCol];
|
||||
|
||||
// Copy the relevant portion of the array
|
||||
for (int i = 0; i < newSizeRow; i++) {
|
||||
System.arraycopy(array[minRow + i], minCol, trimmedArray[i], 0, newSizeCol);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "oak_planks", "oak_planks",
|
||||
"oak_planks", "_", "oak_planks",
|
||||
"oak_planks", "oak_planks", "oak_planks"
|
||||
},
|
||||
result = "chest",
|
||||
amount = 1
|
||||
)
|
||||
public class ChestRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "oak_planks", "_",
|
||||
"oak_planks", "oak_planks", "_",
|
||||
"_", "_", "_"
|
||||
},
|
||||
result = "crafting_table",
|
||||
amount = 1
|
||||
)
|
||||
public class CraftingTableRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"cobblestone", "cobblestone", "cobblestone",
|
||||
"cobblestone", "_", "cobblestone",
|
||||
"cobblestone", "cobblestone", "cobblestone"
|
||||
},
|
||||
result = "furnace",
|
||||
amount = 1
|
||||
)
|
||||
public class FurnaceRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "oak_planks", "_",
|
||||
"oak_planks", "oak_planks", "_",
|
||||
"oak_planks", "oak_planks", "_"
|
||||
},
|
||||
result = "oak_door",
|
||||
amount = 3
|
||||
)
|
||||
public class OakDoorRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_log", "_", "_",
|
||||
"_", "_", "_",
|
||||
"_", "_", "_"
|
||||
},
|
||||
result = "oak_planks",
|
||||
amount = 4
|
||||
)
|
||||
public class OakPlanksRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "_", "_",
|
||||
"oak_planks", "_", "_",
|
||||
"_", "_", "_"
|
||||
},
|
||||
result = "stick",
|
||||
amount = 4
|
||||
)
|
||||
public class StickRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"_", "cobblestone", "cobblestone",
|
||||
"_", "stick", "cobblestone",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "stone_pickaxe",
|
||||
amount = 1
|
||||
)
|
||||
public class StoneAxe2Recipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"cobblestone", "cobblestone", "_",
|
||||
"cobblestone", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "stone_pickaxe",
|
||||
amount = 1
|
||||
)
|
||||
public class StoneAxeRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"cobblestone", "cobblestone", "cobblestone",
|
||||
"_", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "stone_pickaxe",
|
||||
amount = 1
|
||||
)
|
||||
public class StonePickaxeRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"_", "cobblestone", "_",
|
||||
"_", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "stone_shovel",
|
||||
amount = 1
|
||||
)
|
||||
public class StoneShovelRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"_", "oak_planks", "oak_planks",
|
||||
"_", "stick", "oak_planks",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "wooden_axe",
|
||||
amount = 1
|
||||
)
|
||||
public class WoodenAxe2Recipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "oak_planks", "_",
|
||||
"oak_planks", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "oak_planks",
|
||||
amount = 1
|
||||
)
|
||||
public class WoodenAxeRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"oak_planks", "oak_planks", "oak_planks",
|
||||
"_", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "wooden_pickaxe",
|
||||
amount = 1
|
||||
)
|
||||
public class WoodenPickaxeRecipe {}
|
@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.game.crafting.recipes;
|
||||
|
||||
import cz.jzitnik.game.annotations.CraftingRecipeRegistry;
|
||||
|
||||
@CraftingRecipeRegistry(
|
||||
recipe = {
|
||||
"_", "oak_planks", "_",
|
||||
"_", "stick", "_",
|
||||
"_", "stick", "_"
|
||||
},
|
||||
result = "wooden_shovel",
|
||||
amount = 1
|
||||
)
|
||||
public class WoodenShovelRecipe {}
|
Loading…
x
Reference in New Issue
Block a user