support crafting more tools

This commit is contained in:
p2r3
2025-08-16 20:16:17 +03:00
parent 7a3e2b5fa2
commit 4c73e99f29

View File

@@ -15,6 +15,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
} }
} }
uint16_t first_item = player->craft_items[first];
uint8_t first_col = first % 3, first_row = first / 3; uint8_t first_col = first % 3, first_row = first / 3;
switch (filled) { switch (filled) {
@@ -25,7 +26,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
return; return;
case 1: case 1:
switch (player->craft_items[first]) { switch (first_item) {
case I_oak_log: case I_oak_log:
*item = I_oak_planks; *item = I_oak_planks;
*count = 4; *count = 4;
@@ -40,7 +41,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
break; break;
case 2: case 2:
switch (player->craft_items[first]) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
if (first_col != 2 && player->craft_items[first + 1] == I_oak_planks) { if (first_col != 2 && player->craft_items[first + 1] == I_oak_planks) {
*item = I_oak_pressure_plate; *item = I_oak_pressure_plate;
@@ -55,9 +56,52 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
default: break; default: break;
} }
break;
case 3:
switch (first_item) {
case I_oak_planks:
case I_cobblestone:
case I_iron_ingot:
case I_gold_ingot:
case I_diamond:
case I_netherite_ingot:
if (
first_row == 0 &&
player->craft_items[first + 3] == I_stick &&
player->craft_items[first + 6] == I_stick
) {
if (first_item == I_oak_planks) *item = I_wooden_shovel;
else if (first_item == I_cobblestone) *item = I_stone_shovel;
else if (first_item == I_iron_ingot) *item = I_iron_shovel;
else if (first_item == I_gold_ingot) *item = I_golden_shovel;
else if (first_item == I_diamond) *item = I_diamond_shovel;
else if (first_item == I_netherite_ingot) *item = I_netherite_shovel;
*count = 1;
return;
}
if (
first_row == 0 &&
player->craft_items[first + 3] == first_item &&
player->craft_items[first + 6] == I_stick
) {
if (first_item == I_oak_planks) *item = I_wooden_sword;
else if (first_item == I_cobblestone) *item = I_stone_sword;
else if (first_item == I_iron_ingot) *item = I_iron_sword;
else if (first_item == I_gold_ingot) *item = I_golden_sword;
else if (first_item == I_diamond) *item = I_diamond_sword;
else if (first_item == I_netherite_ingot) *item = I_netherite_sword;
*count = 1;
return;
}
break;
default: break;
}
break;
case 4: case 4:
switch (player->craft_items[first]) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
if ( if (
first_col != 2 && first_row != 2 && first_col != 2 && first_row != 2 &&
@@ -73,76 +117,51 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
default: break; default: break;
} }
break;
case 5: case 5:
switch (player->craft_items[first]) { switch (first_item) {
case I_oak_planks: case I_oak_planks:
if (
first == 0 &&
player->craft_items[first + 1] == I_oak_planks &&
player->craft_items[first + 2] == I_oak_planks &&
player->craft_items[first + 4] == I_stick &&
player->craft_items[first + 7] == I_stick
) {
*item = I_wooden_pickaxe;
*count = 1;
return;
}
if (
first < 2 &&
player->craft_items[first + 1] == I_oak_planks &&
player->craft_items[first + 3] == I_oak_planks &&
player->craft_items[first + 4] == I_stick &&
player->craft_items[first + 7] == I_stick
) {
*item = I_wooden_axe;
*count = 1;
return;
}
if (
first < 2 &&
player->craft_items[first + 1] == I_oak_planks &&
player->craft_items[first + 4] == I_oak_planks &&
player->craft_items[first + 3] == I_stick &&
player->craft_items[first + 6] == I_stick
) {
*item = I_wooden_axe;
*count = 1;
return;
}
break;
case I_cobblestone: case I_cobblestone:
case I_iron_ingot:
case I_gold_ingot:
case I_diamond:
case I_netherite_ingot:
if ( if (
first == 0 && first == 0 &&
player->craft_items[first + 1] == I_cobblestone && player->craft_items[first + 1] == first_item &&
player->craft_items[first + 2] == I_cobblestone && player->craft_items[first + 2] == first_item &&
player->craft_items[first + 4] == I_stick && player->craft_items[first + 4] == I_stick &&
player->craft_items[first + 7] == I_stick player->craft_items[first + 7] == I_stick
) { ) {
*item = I_stone_pickaxe; if (first_item == I_oak_planks) *item = I_wooden_pickaxe;
else if (first_item == I_cobblestone) *item = I_stone_pickaxe;
else if (first_item == I_iron_ingot) *item = I_iron_pickaxe;
else if (first_item == I_gold_ingot) *item = I_golden_pickaxe;
else if (first_item == I_diamond) *item = I_diamond_pickaxe;
else if (first_item == I_netherite_ingot) *item = I_netherite_pickaxe;
*count = 1; *count = 1;
return; return;
} }
if ( if (
first < 2 && first < 2 &&
player->craft_items[first + 1] == I_cobblestone && player->craft_items[first + 1] == first_item &&
player->craft_items[first + 3] == I_cobblestone && ((
player->craft_items[first + 4] == I_stick && player->craft_items[first + 3] == first_item &&
player->craft_items[first + 7] == I_stick player->craft_items[first + 4] == I_stick &&
player->craft_items[first + 7] == I_stick
) || (
player->craft_items[first + 4] == first_item &&
player->craft_items[first + 3] == I_stick &&
player->craft_items[first + 6] == I_stick
))
) { ) {
*item = I_stone_axe; if (first_item == I_oak_planks) *item = I_wooden_axe;
*count = 1; else if (first_item == I_cobblestone) *item = I_stone_axe;
return; else if (first_item == I_iron_ingot) *item = I_iron_axe;
} else if (first_item == I_gold_ingot) *item = I_golden_axe;
if ( else if (first_item == I_diamond) *item = I_diamond_axe;
first < 2 && else if (first_item == I_netherite_ingot) *item = I_netherite_axe;
player->craft_items[first + 1] == I_cobblestone &&
player->craft_items[first + 4] == I_cobblestone &&
player->craft_items[first + 3] == I_stick &&
player->craft_items[first + 6] == I_stick
) {
*item = I_stone_axe;
*count = 1; *count = 1;
return; return;
} }
@@ -150,6 +169,7 @@ void getCraftingOutput (PlayerData *player, uint8_t *count, uint16_t *item) {
default: break; default: break;
} }
break;
default: break; default: break;