From 3bf525c553b9fe65e7001c48fff07f4899edc923 Mon Sep 17 00:00:00 2001 From: PavelDobCZ23 Date: Wed, 14 Jun 2023 23:18:33 +0200 Subject: [PATCH] Update 1.6.0 --- .gitignore | 5 + manifest.json => src/manifest.json | 106 +++++++++--------- pack_icon.png => src/pack_icon.png | Bin src/scripts/main.js | 27 +++++ src/subpacks/easy/scripts/mob_list.js | 2 + .../subpacks/hard/scripts}/mob_list.js | 2 +- src/subpacks/normal/scripts/mob_list.js | 2 + subpacks/easy/scripts/modules/mob_list.js | 2 - subpacks/normal/scripts/modules/mob_list.js | 2 - 9 files changed, 90 insertions(+), 58 deletions(-) create mode 100644 .gitignore rename manifest.json => src/manifest.json (85%) rename pack_icon.png => src/pack_icon.png (100%) create mode 100644 src/scripts/main.js create mode 100644 src/subpacks/easy/scripts/mob_list.js rename {subpacks/hard/scripts/modules => src/subpacks/hard/scripts}/mob_list.js (99%) create mode 100644 src/subpacks/normal/scripts/mob_list.js delete mode 100644 subpacks/easy/scripts/modules/mob_list.js delete mode 100644 subpacks/normal/scripts/modules/mob_list.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed5a5f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/exports +/exports/* +/scripts/ +/scripts/* +mcproject.json \ No newline at end of file diff --git a/manifest.json b/src/manifest.json similarity index 85% rename from manifest.json rename to src/manifest.json index 22ff264..6d8d754 100644 --- a/manifest.json +++ b/src/manifest.json @@ -1,54 +1,54 @@ -{ - "metadata": { - "authors": ["PavelDobCZ23"], - "license": "GNU GPL v3 + The Commons Clause", - "url": "https://www.icecraftstudio.repl.co" - }, - "format_version": 2, - "header": { - "description": "Any block you break will now spawn a random mob! Good luck. §9Made by PavelDobCZ23", - "name": "Broken Blocks Spawn Mobs", - "uuid": "8186a5c4-2ff6-4ae3-851d-cc064b3ebf15", - "version": [ 1, 5, 0 ], - "min_engine_version": [ 1, 19, 80 ] - }, - "modules": [ - { - "description": "Broken Blocks Spawn Mobs [BP] - data module", - "type": "data", - "uuid": "02f9fff8-b396-4b0e-8dc8-8f4248720e95", - "version": [1, 5, 0] - }, - { - "description": "Broken Blocks Spawn Mobs [BP] - script module", - "type": "script", - "language": "javascript", - "uuid": "dba56e9e-7496-4366-a01e-8ed733aeaa59", - "version": [1, 5, 0], - "entry": "scripts/main.js" - } - ], - "dependencies": [ - { - "module_name": "@minecraft/server", - "version": "1.2.0-beta" - } - ], - "subpacks": [ - { - "folder_name": "easy", - "name": "§aEasy Mode", - "memory_tier": 0 - }, - { - "folder_name": "hard", - "name": "§4Hard Mode", - "memory_tier": 0 - }, - { - "folder_name": "normal", - "name": "Normal Mode", - "memory_tier": 0 - } - ] +{ + "metadata": { + "authors": ["PavelDobCZ23"], + "license": "GNU GPL v3 + The Commons Clause", + "url": "https://www.icecraftstudio.repl.co" + }, + "format_version": 2, + "header": { + "description": "Any block you break will now spawn a random mob! Good luck. §9Made by PavelDobCZ23", + "name": "Broken Blocks Spawn Mobs", + "uuid": "8186a5c4-2ff6-4ae3-851d-cc064b3ebf15", + "version": [ 1, 6, 0 ], + "min_engine_version": [ 1, 20, 0 ] + }, + "modules": [ + { + "description": "Broken Blocks Spawn Mobs [BP] - data module", + "type": "data", + "uuid": "02f9fff8-b396-4b0e-8dc8-8f4248720e95", + "version": [1, 6, 0] + }, + { + "description": "Broken Blocks Spawn Mobs [BP] - script module", + "type": "script", + "language": "javascript", + "uuid": "dba56e9e-7496-4366-a01e-8ed733aeaa59", + "version": [1, 6, 0], + "entry": "scripts/main.js" + } + ], + "dependencies": [ + { + "module_name": "@minecraft/server", + "version": "1.3.0-beta" + } + ], + "subpacks": [ + { + "folder_name": "easy", + "name": "§aEasy Mode", + "memory_tier": 0 + }, + { + "folder_name": "hard", + "name": "§4Hard Mode", + "memory_tier": 0 + }, + { + "folder_name": "normal", + "name": "Normal Mode", + "memory_tier": 0 + } + ] } \ No newline at end of file diff --git a/pack_icon.png b/src/pack_icon.png similarity index 100% rename from pack_icon.png rename to src/pack_icon.png diff --git a/src/scripts/main.js b/src/scripts/main.js new file mode 100644 index 0000000..84f95a8 --- /dev/null +++ b/src/scripts/main.js @@ -0,0 +1,27 @@ +import { world } from "@minecraft/server"; +import { mobList } from "./mob_list.js"; + +world.afterEvents.blockBreak.subscribe(async (eventData) => { + const locX = eventData.block.location.x; + const locY = eventData.block.location.y; + const locZ = eventData.block.location.z; + await eventData.player.runCommandAsync(`summon ${randChoice(mobList)} ${locX} ${locY} ${locZ}`); +}); + +function randInt(min, max) { + max++; + return Math.floor(Math.random() * (max - min)) + min; +} + +function randChoice(array, num) { + if (num) { + const choice = []; + while (num > 0) { + num--; + choice.push(array[randInt(0, array.length - 1)]); + } + return choice; + } else { + return array[randInt(0, array.length - 1)]; + } +} \ No newline at end of file diff --git a/src/subpacks/easy/scripts/mob_list.js b/src/subpacks/easy/scripts/mob_list.js new file mode 100644 index 0000000..b4f4d9f --- /dev/null +++ b/src/subpacks/easy/scripts/mob_list.js @@ -0,0 +1,2 @@ +const mobList = ["allay","axolotl","bat","bee","camel","cat","chicken","cow","dolphin","donkey","fox","frog","glow_squid","horse","iron_golem","llama","mooshroom","mule","ocelot","parrot","pig","polar_bear","rabbit","sheep","skeleton_horse","sniffer","snow_golem","squid","strider","tadpole","turtle","villager","wandering_trader","wolf","zombie_horse"]; +export {mobList} \ No newline at end of file diff --git a/subpacks/hard/scripts/modules/mob_list.js b/src/subpacks/hard/scripts/mob_list.js similarity index 99% rename from subpacks/hard/scripts/modules/mob_list.js rename to src/subpacks/hard/scripts/mob_list.js index 2d0a91c..47529cd 100644 --- a/subpacks/hard/scripts/modules/mob_list.js +++ b/src/subpacks/hard/scripts/mob_list.js @@ -1,2 +1,2 @@ -const mobList = ["blaze","cave_spider","creeper","drowned","elder_guardian","enderman","endermite","evocation_illager","ghast","guardian","hoglin","husk","magma_cube","phantom","pillager","ravager","shulker","silverfish","skeleton","slime","spider","stray","vex","vindicator","witch","wither_skeleton","zoglin","zombie","zombie_pigman","zombie_villager"]; +const mobList = ["blaze","cave_spider","creeper","drowned","elder_guardian","enderman","endermite","evocation_illager","ghast","guardian","hoglin","husk","magma_cube","phantom","pillager","ravager","shulker","silverfish","skeleton","slime","spider","stray","vex","vindicator","witch","wither_skeleton","zoglin","zombie","zombie_pigman","zombie_villager"]; export {mobList} \ No newline at end of file diff --git a/src/subpacks/normal/scripts/mob_list.js b/src/subpacks/normal/scripts/mob_list.js new file mode 100644 index 0000000..33f9705 --- /dev/null +++ b/src/subpacks/normal/scripts/mob_list.js @@ -0,0 +1,2 @@ +const mobList = ["allay","axolotl","bat","bee","blaze","camel","cat","cave_spider","chicken","cow","creeper","dolphin","donkey","drowned","elder_guardian","enderman","endermite","evocation_illager","fox","frog","ghast","glow_squid","guardian","hoglin","horse","husk","iron_golem","llama","magma_cube","mooshroom","mule","ocelot","parrot","phantom","pig","pillager","polar_bear","rabbit","ravager","sheep","shulker","silverfish","skeleton","skeleton_horse","slime","sniffer","snow_golem","spider","squid","stray","strider","tadpole","turtle","vex","villager","vindicator","wandering_trader","witch","wither_skeleton","wolf","zoglin","zombie","zombie_horse","zombie_pigman","zombie_villager"]; +export {mobList} \ No newline at end of file diff --git a/subpacks/easy/scripts/modules/mob_list.js b/subpacks/easy/scripts/modules/mob_list.js deleted file mode 100644 index 3c75e99..0000000 --- a/subpacks/easy/scripts/modules/mob_list.js +++ /dev/null @@ -1,2 +0,0 @@ -const mobList = ["allay","axolotl","bat","bee","cat","chicken","cow","dolphin","donkey","fox","frog","glow_squid","horse","iron_golem","llama","mooshroom","mule","ocelot","parrot","pig","polar_bear","rabbit","sheep","skeleton_horse","snow_golem","squid","strider","tadpole","turtle","villager","wandering_trader","wolf","zombie_horse"]; -export {mobList} \ No newline at end of file diff --git a/subpacks/normal/scripts/modules/mob_list.js b/subpacks/normal/scripts/modules/mob_list.js deleted file mode 100644 index 7899b6e..0000000 --- a/subpacks/normal/scripts/modules/mob_list.js +++ /dev/null @@ -1,2 +0,0 @@ -const mobList = ["allay","axolotl","bat","bee","blaze","cat","cave_spider","chicken","cow","creeper","dolphin","donkey","drowned","elder_guardian","enderman","endermite","evocation_illager","fox","frog","ghast","glow_squid","guardian","hoglin","horse","husk","iron_golem","llama","magma_cube","mooshroom","mule","ocelot","parrot","phantom","pig","pillager","polar_bear","rabbit","ravager","sheep","shulker","silverfish","skeleton","skeleton_horse","slime","snow_golem","spider","squid","stray","strider","tadpole","turtle","vex","villager","vindicator","wandering_trader","witch","wither_skeleton","wolf","zoglin","zombie","zombie_horse","zombie_pigman","zombie_villager"]; -export {mobList} \ No newline at end of file