Skip to content

Commit

Permalink
Performance optimisations. Update for MC 1.20.40
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelDobCZ23 committed Nov 5, 2023
1 parent 688c210 commit fe8d6f2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/exports/*
/scripts/
/scripts/*
mcproject.json
mcproject.json
/node_modules
/package-lock.json
/package.json
10 changes: 5 additions & 5 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
},
"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": [
{
"description": "On Campfire - On Fire [BP] - script module",
"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": [
Expand Down
37 changes: 28 additions & 9 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit fe8d6f2

Please sign in to comment.