Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update instamine_deepslate.sc for 1.21 data components #400

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 30 additions & 33 deletions programs/survival/instamine_deepslate.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,54 @@
// works even if the player doesn't have carpet mod on their client

__config() -> {
'stay_loaded' -> true,
'stay_loaded' -> true,
};

// list of blocks that can be instamined
// remove the comment below to allow cobbled deepslate, or add other blocks
global_instamine_blocks = [
//'cobbled_deepslate',
'deepslate'
//'cobbled_deepslate',
'deepslate'
];

// tools that can be use to instamine the list of blocks above
// remove the comment below to allow diamond pickaxes, or add other pickaxes
global_required_pickaxes = [
//'diamond_pickaxe',
'netherite_pickaxe'
//'diamond_pickaxe',
'netherite_pickaxe'
];

__on_player_clicks_block(player, block, face) -> (
held_item = player ~ 'holds';
// check if player is holding item
if(held_item != null,
// check if block can be instamined and correct tool is being used
if(global_instamine_blocks ~ str(block) != null && global_required_pickaxes ~ (held_item:0) != null,
// check if player has haste 2 and efficiency 5
if(__has_haste_2(player) && __has_efficiency_5(held_item:2),
harvest(player, block);
);
held_item = player~'holds';
// check if player is holding item
if (held_item != null,
// check if block can be instamined and correct tool is being used
if (global_instamine_blocks~str(block) != null && global_required_pickaxes~(held_item: 0) != null,
// check if player has haste 2 and efficiency 5
if (__has_haste_2(player) && __has_efficiency_5(held_item: 2),
harvest(player, block);
);
);
);
);
);

__has_haste_2(player) -> (
// get player haste effect
haste_effect = query(player, 'effect', 'haste');
// get player haste effect
haste_effect = query(player, 'effect', 'haste');

// check if effect is not null and is level 2 or more
haste_effect != null && haste_effect:0 >= 1;
// check if effect is not null and is level 2 or more
haste_effect != null && haste_effect: 0 >= 1;
);

__has_efficiency_5(nbt) -> (
// get enchantments list
enchants_list = parse_nbt(nbt):'Enchantments';

// check if enchants exist
if(enchants_list != null,
// find enchant that matches and check if not null
first(enchants_list,
// check if enchant is efficiency and is level 5 or more
_:'id' == 'minecraft:efficiency' && _:'lvl' >= 5;
) != null,
//else
false
);
);
// get enchantments list
enchants_list = nbt: 'components': 'minecraft:enchantments': 'levels';

// check if enchants exist
if (enchants_list != null,
// find enchant that is efficiency and check is level 5 or more
enchants_list: 'minecraft:efficiency' >= 5,
//else
false
);
);