expand crafting recipes

This commit is contained in:
p2r3
2025-08-22 19:18:25 +03:00
parent b3654fea6f
commit 18902e7504
3 changed files with 75 additions and 12 deletions

View File

@@ -42,7 +42,10 @@ const blockWhitelist = [
"lava", "lava",
"snowy_grass_block", "snowy_grass_block",
"mud", "mud",
"moss_carpet" "moss_carpet",
"oak_slab",
"stone_slab",
"cobblestone_slab"
]; ];
// Currently, only 4 biome types are supported, excluding "beach" // Currently, only 4 biome types are supported, excluding "beach"
@@ -332,8 +335,11 @@ async function convert () {
"block": { "block": {
"mineable/pickaxe": [ "mineable/pickaxe": [
itemsAndBlocks.blockRegistry["stone"], itemsAndBlocks.blockRegistry["stone"],
itemsAndBlocks.blockRegistry["stone_slab"],
itemsAndBlocks.blockRegistry["cobblestone"], itemsAndBlocks.blockRegistry["cobblestone"],
itemsAndBlocks.blockRegistry["cobblestone_slab"],
itemsAndBlocks.blockRegistry["sandstone"], itemsAndBlocks.blockRegistry["sandstone"],
itemsAndBlocks.blockRegistry["sandstone_slab"],
itemsAndBlocks.blockRegistry["ice"], itemsAndBlocks.blockRegistry["ice"],
itemsAndBlocks.blockRegistry["diamond_ore"], itemsAndBlocks.blockRegistry["diamond_ore"],
itemsAndBlocks.blockRegistry["gold_ore"], itemsAndBlocks.blockRegistry["gold_ore"],
@@ -345,6 +351,8 @@ async function convert () {
"mineable/axe": [ "mineable/axe": [
itemsAndBlocks.blockRegistry["oak_log"], itemsAndBlocks.blockRegistry["oak_log"],
itemsAndBlocks.blockRegistry["oak_planks"], itemsAndBlocks.blockRegistry["oak_planks"],
itemsAndBlocks.blockRegistry["oak_wood"],
itemsAndBlocks.blockRegistry["oak_slab"],
itemsAndBlocks.blockRegistry["crafting_table"] itemsAndBlocks.blockRegistry["crafting_table"]
], ],
"mineable/shovel": [ "mineable/shovel": [
@@ -352,6 +360,7 @@ async function convert () {
itemsAndBlocks.blockRegistry["dirt"], itemsAndBlocks.blockRegistry["dirt"],
itemsAndBlocks.blockRegistry["sand"], itemsAndBlocks.blockRegistry["sand"],
itemsAndBlocks.blockRegistry["snow"], itemsAndBlocks.blockRegistry["snow"],
itemsAndBlocks.blockRegistry["snow_block"],
itemsAndBlocks.blockRegistry["mud"] itemsAndBlocks.blockRegistry["mud"]
], ],
}, },

View File

@@ -9,11 +9,14 @@
void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) { void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
uint8_t i, filled = 0, first = 10; uint8_t i, filled = 0, first = 10, identical = true;
for (i = 0; i < 9; i ++) { for (i = 0; i < 9; i ++) {
if (player->craft_items[i]) { if (player->craft_items[i]) {
filled ++; filled ++;
if (first == 10) first = i; if (first == 10) first = i;
else if (player->craft_items[i] != player->craft_items[first]) {
identical = false;
}
} }
} }
@@ -72,10 +75,26 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
switch (first_item) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
case I_cobblestone: case I_cobblestone:
case I_stone:
case I_snow_block:
// Slab recipes
if (
first_col == 0 &&
player->craft_items[first + 1] == first_item &&
player->craft_items[first + 2] == first_item
) {
if (first_item == I_oak_planks) *item = I_oak_slab;
else if (first_item == I_cobblestone) *item = I_cobblestone_slab;
else if (first_item == I_stone) *item = I_stone_slab;
else if (first_item == I_snow_block) *item = I_snow;
*count = 6;
return;
}
case I_iron_ingot: case I_iron_ingot:
case I_gold_ingot: case I_gold_ingot:
case I_diamond: case I_diamond:
case I_netherite_ingot: case I_netherite_ingot:
// Shovel recipes
if ( if (
first_row == 0 && first_row == 0 &&
player->craft_items[first + 3] == I_stick && player->craft_items[first + 3] == I_stick &&
@@ -90,6 +109,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
*count = 1; *count = 1;
return; return;
} }
// Sword recipes
if ( if (
first_row == 0 && first_row == 0 &&
player->craft_items[first + 3] == first_item && player->craft_items[first + 3] == first_item &&
@@ -113,14 +133,18 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
case 4: case 4:
switch (first_item) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
case I_oak_log:
case I_snowball:
// Uniform 2x2 shaped recipes
if ( if (
first_col != 2 && first_row != 2 && first_col != 2 && first_row != 2 &&
player->craft_items[first + 1] == I_oak_planks && player->craft_items[first + 1] == first_item &&
player->craft_items[first + 3] == I_oak_planks && player->craft_items[first + 3] == first_item &&
player->craft_items[first + 4] == I_oak_planks player->craft_items[first + 4] == first_item
) { ) {
*item = I_crafting_table; if (first_item == I_oak_planks) { *item = I_crafting_table; *count = 1; }
*count = 1; else if (first_item == I_oak_log) { *item = I_oak_wood; *count = 3; }
else if (first_item == I_snowball) { *item = I_snow_block; *count = 3; }
return; return;
} }
break; break;
@@ -130,13 +154,14 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
break; break;
case 5: case 5:
switch (first_item) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
case I_cobblestone: case I_cobblestone:
case I_iron_ingot: case I_iron_ingot:
case I_gold_ingot: case I_gold_ingot:
case I_diamond: case I_diamond:
case I_netherite_ingot: case I_netherite_ingot:
// Pickaxe recipes
if ( if (
first == 0 && first == 0 &&
player->craft_items[first + 1] == first_item && player->craft_items[first + 1] == first_item &&
@@ -153,6 +178,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
*count = 1; *count = 1;
return; return;
} }
// Axe recipes
if ( if (
first < 2 && first < 2 &&
player->craft_items[first + 1] == first_item && player->craft_items[first + 1] == first_item &&
@@ -184,7 +210,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
case 8: case 8:
switch (first_item) { switch (first_item) {
case I_cobblestone: case I_cobblestone:
if (player->craft_items[first + 4] == 0) { if (identical && player->craft_items[first + 4] == 0) {
*item = I_furnace; *item = I_furnace;
*count = 1; *count = 1;
return; return;
@@ -193,6 +219,19 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
default: break; default: break;
} }
break;
case 9:
// Uniform 3x3 shaped recipes
if (identical) switch (first_item) {
case I_iron_ingot: *item = I_iron_block; *count = 1; break;
case I_gold_ingot: *item = I_gold_block; *count = 1; break;
case I_diamond: *item = I_diamond_block; *count = 1; break;
case I_redstone: *item = I_redstone_block; *count = 1; break;
case I_coal: *item = I_coal_block; *count = 1; break;
default: break;
}
break;
default: break; default: break;
@@ -219,19 +258,31 @@ void getSmeltingOutput (PlayerData *player) {
uint8_t *output_count = &player->craft_count[2]; uint8_t *output_count = &player->craft_count[2];
uint16_t *output_item = &player->craft_items[2]; uint16_t *output_item = &player->craft_items[2];
uint8_t fuel_value; uint8_t fuel_value = 0;
if (*fuel == I_coal) fuel_value = 8; if (*fuel == I_coal) fuel_value = 8;
else if (*fuel == I_charcoal) fuel_value = 8; else if (*fuel == I_charcoal) fuel_value = 8;
else if (*fuel == I_coal_block) fuel_value = 80;
else if (*fuel == I_oak_planks) fuel_value = 1 + (fast_rand() & 1); else if (*fuel == I_oak_planks) fuel_value = 1 + (fast_rand() & 1);
else if (*fuel == I_oak_log) fuel_value = 1 + (fast_rand() & 1); else if (*fuel == I_oak_log) fuel_value = 1 + (fast_rand() & 1);
else return; else if (*fuel == I_crafting_table) fuel_value = 1 + (fast_rand() & 1);
else if (*fuel == I_stick) fuel_value = (fast_rand() & 1);
else if (*fuel == I_oak_sapling) fuel_value = (fast_rand() & 1);
else if (*fuel == I_wooden_axe) fuel_value = 1;
else if (*fuel == I_wooden_pickaxe) fuel_value = 1;
else if (*fuel == I_wooden_shovel) fuel_value = 1;
else if (*fuel == I_wooden_sword) fuel_value = 1;
else if (*fuel == I_wooden_hoe) fuel_value = 1;
if (fuel_value == 0) return;
uint8_t exchange = *material_count > fuel_value ? fuel_value : *material_count; uint8_t exchange = *material_count > fuel_value ? fuel_value : *material_count;
registerSmeltingRecipe(I_cobblestone, I_stone); registerSmeltingRecipe(I_cobblestone, I_stone);
else registerSmeltingRecipe(I_oak_log, I_charcoal); else registerSmeltingRecipe(I_oak_log, I_charcoal);
else registerSmeltingRecipe(I_oak_wood, I_charcoal);
else registerSmeltingRecipe(I_raw_iron, I_iron_ingot); else registerSmeltingRecipe(I_raw_iron, I_iron_ingot);
else registerSmeltingRecipe(I_raw_gold, I_gold_ingot); else registerSmeltingRecipe(I_raw_gold, I_gold_ingot);
else registerSmeltingRecipe(I_sand, I_glass);
else return; else return;
*output_count += exchange; *output_count += exchange;

View File

@@ -413,7 +413,10 @@ uint8_t isInstantlyMined (PlayerData *player, uint8_t block) {
uint16_t held_item = player->inventory_items[player->hotbar]; uint16_t held_item = player->inventory_items[player->hotbar];
if (block == B_snow) return ( if (
block == B_snow ||
block == B_snow_block
) return (
held_item == I_stone_shovel || held_item == I_stone_shovel ||
held_item == I_iron_shovel || held_item == I_iron_shovel ||
held_item == I_diamond_shovel || held_item == I_diamond_shovel ||