1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- event.load("block_break");
- //radius = 1;
- msg("dev", "§bShears §rloaded.");
- @wait
- wait();
- if(cancel) {
- goto("wait");
- }
- if(!text.contains(block_type, "leaves")){
- goto("wait");
- }
- if(item.getType(living.getEquip(player, "hand")) != "minecraft:shears"){
- goto("wait");
- }
- if(block.property.getValue(block_loc, block.getProperty("persistent"))){
- goto("wait");
- }
- shears_X = loc.getX(block_loc);
- shears_Y = loc.getY(block_loc);
- shears_Z = loc.getZ(block_loc);
- unbreaking_level = enchantment.getLevel(enchantment.get("unbreaking"), living.getEquip(player, "hand"));
- radius = enchantment.getLevel(enchantment.get("sharpness"), living.getEquip(player, "hand"));
- if(radius > 0){
- cancel = true;
- }
- location = block_loc;
- for(a = -radius; a < radius+1; a++){
- loc.setX(location, shears_X + a);
- for(b = -radius; b < radius+1; b++){
- loc.setY(location, shears_Y + b);
- for(c = -radius; c < radius+1; c++){
- loc.setZ(location, shears_Z + c);
- if(math.abs(a)+math.abs(b)+math.abs(c)+math.random(0,2) < radius+2){
- shear(location,block_type,player,unbreaking_level);
- }
- }
- }
- }
- goto("wait");
- function shear(block_loc,original_block_type,player,unbreaking_level){
- if(block.getType(block_loc) == original_block_type){
- if(!block.property.getValue(block_loc, block.getProperty("persistent"))){
- block.set(block_loc, "minecraft:air");
- item.drop(block_loc, read.item(original_block_type,1));
- if(player.isSurvival(player)){
- if(math.random(0,99) < 100/(unbreaking_level+1)){
- player.damageItem(player, 1);
- }
- }
- }
- }
- }
|