diff --git a/.gitignore b/.gitignore index ed5a5f0..03f3d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ /exports/* /scripts/ /scripts/* -mcproject.json \ No newline at end of file +mcproject.json +/node_modules +/package-lock.json +/package.json \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json index 140b05d..07d72c7 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -6,11 +6,11 @@ }, "format_version": 2, "header": { - "description": "Campfires now set you and the entites on fire like they used to! §9Made by PavelDobCZ23", + "description": "Campfires now set you and the entites on fire like they used to! For MC - §l1.20.40§r §9Made by PavelDobCZ23", "name": "On Campfire - On Fire", "uuid": "03862db4-c4b9-42e1-b57b-daf391a5a05a", - "version": [ 1, 4, 0 ], - "min_engine_version": [ 1, 20, 30 ] + "version": [ 1, 5, 0 ], + "min_engine_version": [ 1, 20, 40 ] }, "modules": [ { @@ -18,14 +18,14 @@ "type": "script", "language": "javascript", "uuid": "514c9ddc-fd40-4189-9b10-bfc358089a33", - "version": [1, 4, 0], + "version": [1, 5, 0], "entry": "scripts/main.js" } ], "dependencies": [ { "module_name": "@minecraft/server", - "version": "1.6.0-beta" + "version": "1.7.0-beta" } ], "subpacks": [ diff --git a/src/scripts/main.js b/src/scripts/main.js index abc3645..88d22c4 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,18 +1,37 @@ import { system, world } from '@minecraft/server'; import { SCHEDULED_TICKS } from './config/config'; -const DIMENSION_LIST = ['minecraft:overworld','minecraft:nether','minecraft:the_end']; +const DIMENSION_LIST = ['minecraft:overworld','minecraft:nether','minecraft:the_end']; +// A lot of entities to exclude which don't need to burn anyways, optimises performance +const NO_BURN_ENTITY_TYPES = [ + 'minecraft:item','minecraft:xp_orb', //~ Drops + 'minecraft:arrow','minecraft:dragon_fireball','minecraft:egg','minecraft:ender_pearl','minecraft:evocation_fang','minecraft:eye_of_ender_signal', + 'minecraft:fireball','minecraft:fireworks_rocket','minecraft:fishing_hook','minecraft:lingering_potion','minecraft:llama_spit', + 'minecraft:shulker_bullet','minecraft:small_fireball','minecraft:snowball','minecraft:splash_potion','minecraft:thrown_trident', + 'minecraft:wither_skull','minecraft:wither_skull_dangerous','minecraft:xp_bottle', //~ Projectiles + 'minecraft:agent','minecraft:balloon','minecraft:chalkboard','minecraft:ice_bomb','minecraft:npc','minecraft:tripod_camera', //~ EDU + 'minecraft:falling_block','minecraft:moving_block','minecraft:painting','minecraft:tnt','minecraft:ender_crystal', //~ Blocks + 'minecraft:shield','minecraft:elder_guardian_ghost','minecraft:leash_knot','minecraft:area_effect_cloud' //~ Others +] +const NO_BURN_ENTITY_FAMILIES = ['minecart','lightning'] system.runInterval(() => { for (let index = 0;index < DIMENSION_LIST.length;index++) { const dimension = world.getDimension(DIMENSION_LIST[index]); - for (const entity of dimension.getEntities()) { - try { - const blockLocation = {x:Math.floor(entity.location.x),y:Math.floor(entity.location.y),z:Math.floor(entity.location.z)}; - const blockStandingIn = dimension.getBlock(blockLocation); - if (blockStandingIn?.typeId === 'minecraft:campfire' || blockStandingIn?.typeId === 'minecraft:soul_campfire') { - entity.setOnFire(8); - } - } catch {} + for (const entity of dimension.getEntities({ + excludeFamilies: NO_BURN_ENTITY_FAMILIES, + excludeTypes: NO_BURN_ENTITY_TYPES + })) { + system.run(() => { + try { + const blockStandingIn = dimension.getBlock(entity.location); + if ( + blockStandingIn?.typeId === 'minecraft:campfire' || + blockStandingIn?.typeId === 'minecraft:soul_campfire' + ) { + entity.setOnFire(8); + } + } catch {} + }); } } },SCHEDULED_TICKS); \ No newline at end of file