12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- event.load("block_break");
- cobweb_radius = 1;
- sword = item.getTag("km:sword");
- msg("dev", "§bCobwebs §rloaded.");
- @wait
- wait();
- if(cancel) {
- goto("wait");
- }
- if(block_type != "minecraft:cobweb"){
- goto("wait");
- }
- equip = living.getEquip(player, "hand");
- if(!item.hasTag(sword, equip)){
- goto("wait");
- }
- cobweb_X = loc.getX(block_loc);
- cobweb_Y = loc.getY(block_loc);
- cobweb_Z = loc.getZ(block_loc);
- unbreaking_level = enchantment.getLevel(enchantment.get("unbreaking"), equip);
- location = block_loc;
- for(a = -cobweb_radius; a < cobweb_radius+1; a++){
- loc.setX(location, cobweb_X + a);
- for(b = -cobweb_radius; b < cobweb_radius+1; b++){
- loc.setY(location, cobweb_Y + b);
- for(c = -cobweb_radius; c < cobweb_radius+1; c++){
- loc.setZ(location, cobweb_Z + c);
- if(math.abs(a)+math.abs(b)+math.abs(c)+math.random(0,2) < cobweb_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){
- block.break(block_loc, player);
- if(math.random(0,99) < 100/(unbreaking_level+1)){
- player.damageItem(player, 1);
- }
- }
- }
|