mirror of
https://github.com/p2r3/bareiron.git
synced 2025-10-02 07:35:08 +02:00
update ore mining behavior
This commit is contained in:
@@ -4,7 +4,12 @@ const path = require("path");
|
|||||||
// Overrides for block-to-item conversion
|
// Overrides for block-to-item conversion
|
||||||
const blockToItemOverrides = {
|
const blockToItemOverrides = {
|
||||||
"grass_block": "dirt",
|
"grass_block": "dirt",
|
||||||
"stone": "cobblestone"
|
"stone": "cobblestone",
|
||||||
|
"diamond_ore": "diamond",
|
||||||
|
"gold_ore": "raw_gold",
|
||||||
|
"redstone_ore": "redstone",
|
||||||
|
"iron_ore": "raw_iron",
|
||||||
|
"coal_ore": "coal"
|
||||||
};
|
};
|
||||||
|
|
||||||
const biomes = [
|
const biomes = [
|
||||||
@@ -261,7 +266,12 @@ async function convert () {
|
|||||||
"block": {
|
"block": {
|
||||||
"mineable/pickaxe": [
|
"mineable/pickaxe": [
|
||||||
itemsAndBlocks.blockRegistry["stone"],
|
itemsAndBlocks.blockRegistry["stone"],
|
||||||
itemsAndBlocks.blockRegistry["cobblestone"]
|
itemsAndBlocks.blockRegistry["cobblestone"],
|
||||||
|
itemsAndBlocks.blockRegistry["diamond_ore"],
|
||||||
|
itemsAndBlocks.blockRegistry["gold_ore"],
|
||||||
|
itemsAndBlocks.blockRegistry["redstone_ore"],
|
||||||
|
itemsAndBlocks.blockRegistry["iron_ore"],
|
||||||
|
itemsAndBlocks.blockRegistry["coal_ore"]
|
||||||
],
|
],
|
||||||
"mineable/axe": [
|
"mineable/axe": [
|
||||||
itemsAndBlocks.blockRegistry["oak_log"],
|
itemsAndBlocks.blockRegistry["oak_log"],
|
||||||
|
23
src/tools.c
23
src/tools.c
@@ -299,6 +299,10 @@ void makeBlockChange (short x, short y, short z, uint8_t block) {
|
|||||||
// Probability numbers obtained with this formula: N = floor(P * 32 ^ 2)
|
// Probability numbers obtained with this formula: N = floor(P * 32 ^ 2)
|
||||||
uint16_t getMiningResult (int client_fd, uint8_t block) {
|
uint16_t getMiningResult (int client_fd, uint8_t block) {
|
||||||
|
|
||||||
|
PlayerData *player;
|
||||||
|
if (getPlayerData(client_fd, &player)) return 0;
|
||||||
|
uint16_t held_item = player->inventory_items[player->hotbar];
|
||||||
|
|
||||||
switch (block) {
|
switch (block) {
|
||||||
|
|
||||||
case B_oak_leaves:
|
case B_oak_leaves:
|
||||||
@@ -311,10 +315,9 @@ uint16_t getMiningResult (int client_fd, uint8_t block) {
|
|||||||
|
|
||||||
case B_stone:
|
case B_stone:
|
||||||
case B_cobblestone:
|
case B_cobblestone:
|
||||||
// Check if player is holding a pickaxe
|
case B_coal_ore:
|
||||||
PlayerData *player;
|
case B_iron_ore:
|
||||||
if (getPlayerData(client_fd, &player)) return 0;
|
// Check if player is holding (any) pickaxe
|
||||||
uint16_t held_item = player->inventory_items[player->hotbar];
|
|
||||||
if (
|
if (
|
||||||
held_item != I_wooden_pickaxe &&
|
held_item != I_wooden_pickaxe &&
|
||||||
held_item != I_stone_pickaxe &&
|
held_item != I_stone_pickaxe &&
|
||||||
@@ -325,6 +328,18 @@ uint16_t getMiningResult (int client_fd, uint8_t block) {
|
|||||||
) return 0;
|
) return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case B_gold_ore:
|
||||||
|
case B_redstone_ore:
|
||||||
|
case B_diamond_ore:
|
||||||
|
// Check if player is holding an iron (or better) pickaxe
|
||||||
|
if (
|
||||||
|
held_item != I_iron_pickaxe &&
|
||||||
|
held_item != I_golden_pickaxe &&
|
||||||
|
held_item != I_diamond_pickaxe &&
|
||||||
|
held_item != I_netherite_pickaxe
|
||||||
|
) return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user