diff --git a/Canopy [BP]/entities/tnt.json b/Canopy [BP]/entities/tnt.json index b3a943a..b5ac436 100644 --- a/Canopy [BP]/entities/tnt.json +++ b/Canopy [BP]/entities/tnt.json @@ -20,15 +20,7 @@ "causes_fire": false } }, - "canopy:normalFuse": { - "minecraft:explode": { - "fuse_length": 4, - "fuse_lit": true, - "power": 4, - "causes_fire": false - } - }, - "canopy:longFuse": { + "canopy:fuse": { "minecraft:explode": { "fuse_length": 3600, "fuse_lit": true, @@ -77,17 +69,10 @@ ] } }, - "canopy:normalFuse": { - "add": { - "component_groups": [ - "canopy:normalFuse" - ] - } - }, - "canopy:longFuse": { + "canopy:fuse": { "add": { "component_groups": [ - "canopy:longFuse" + "canopy:fuse" ] } }, diff --git a/Canopy [BP]/manifest.json b/Canopy [BP]/manifest.json index 5627327..9b3f147 100644 --- a/Canopy [BP]/manifest.json +++ b/Canopy [BP]/manifest.json @@ -1,11 +1,11 @@ { "format_version": 2, "header": { - "name": "Canopy [BP] v1.3.5", + "name": "Canopy [BP] v1.3.6", "description": "Technical informatics & features addon by §aForestOfLight§r.", "uuid": "7f6b23df-a583-476b-b0e4-87457e65f7c0", - "min_engine_version": [1, 21, 30], - "version": [1, 3, 5] + "min_engine_version": [1, 21, 50], + "version": [1, 3, 6] }, "modules": [ { @@ -26,7 +26,7 @@ "dependencies": [ { "module_name": "@minecraft/server", - "version": "1.16.0-beta" + "version": "1.17.0-beta" }, { "uuid": "bcf34368-ed0c-4cf7-938e-582cccf9950d", // Canopy [RP] diff --git a/Canopy [BP]/scripts/lib/canopy/Rule.js b/Canopy [BP]/scripts/lib/canopy/Rule.js index baacf0b..e571ea4 100644 --- a/Canopy [BP]/scripts/lib/canopy/Rule.js +++ b/Canopy [BP]/scripts/lib/canopy/Rule.js @@ -60,16 +60,7 @@ class Rule { } return this.parseString(world.getDynamicProperty(this.#identifier)); } - - parseString(value) { - try { - return JSON.parse(value); - } catch (error) { - if (value === 'undefined') return undefined; - if (value === 'NaN') return NaN; - } - } - + async recieveRuleValue(scriptEventReceive, resolve) { if (scriptEventReceive.id !== 'canopyExtension:ruleValueResponse' || scriptEventReceive.sourceType !== 'Server') return; const splitMessage = scriptEventReceive.message.split(' '); @@ -81,6 +72,15 @@ class Rule { // console.warn(`[Canopy] Received rule value: ${extensionName}:${ruleID} ${value}`); resolve(value); } + + parseString(value) { + try { + return JSON.parse(value); + } catch (error) { + if (value === 'undefined') return undefined; + if (value === 'NaN') return NaN; + } + } setValue(value) { if (this.#extensionName) { diff --git a/Canopy [BP]/scripts/main.js b/Canopy [BP]/scripts/main.js index 5053b2b..07c7196 100644 --- a/Canopy [BP]/scripts/main.js +++ b/Canopy [BP]/scripts/main.js @@ -24,6 +24,7 @@ import 'src/commands/tntfuse' import 'src/commands/removeentity' import 'src/commands/pos' import 'src/commands/cleanup' +import 'src/commands/sit' // Script Events import 'src/commands/scriptevents/counter' diff --git a/Canopy [BP]/scripts/src/classes/Instaminable.js b/Canopy [BP]/scripts/src/classes/Instaminable.js index a12b5f6..1f71168 100644 --- a/Canopy [BP]/scripts/src/classes/Instaminable.js +++ b/Canopy [BP]/scripts/src/classes/Instaminable.js @@ -5,7 +5,7 @@ const beaconRefreshOffset = new Map(); const BEACON_REFRESH_RATE = 80; world.afterEvents.effectAdd.subscribe(event => { - if (event.effect.typeId !== 'haste' || event.entity?.typeId !== 'minecraft:player') return; + if (event.effect?.typeId !== 'haste' || event.entity?.typeId !== 'minecraft:player') return; beaconRefreshOffset[event.entity.id] = system.currentTick % BEACON_REFRESH_RATE; }); diff --git a/Canopy [BP]/scripts/src/commands/camera.js b/Canopy [BP]/scripts/src/commands/camera.js index f19896e..53565fc 100644 --- a/Canopy [BP]/scripts/src/commands/camera.js +++ b/Canopy [BP]/scripts/src/commands/camera.js @@ -190,7 +190,7 @@ function startSpectate(sender) { system.runTimeout(() => { sender.setGameMode('spectator'); for (let effect of sender.getEffects()) - sender.removeEffect(effect.typeId); + sender.removeEffect(effect?.typeId); sender.addEffect('night_vision', 999999, { amplifier: 0, showParticles: false }); sender.addEffect('conduit_power', 999999, { amplifier: 0, showParticles: false }); sender.onScreenDisplay.setActionBar({ translate: 'commands.camera.spectate.started' }); @@ -203,7 +203,7 @@ function endSpectate(sender) { sender.setDynamicProperty('isSpectating', false); system.runTimeout(() => { for (let effect of sender.getEffects()) - sender.removeEffect(effect.typeId); + sender.removeEffect(effect?.typeId); sender.teleport(beforeSpectatorPlayer.location, { dimension: world.getDimension(beforeSpectatorPlayer.dimensionId), rotation: beforeSpectatorPlayer.rotation }); for (const effect of beforeSpectatorPlayer.effects) { sender.addEffect(effect.typeId, Math.min(20000000, effect.duration), { amplifier: effect.amplifier }); diff --git a/Canopy [BP]/scripts/src/commands/sit.js b/Canopy [BP]/scripts/src/commands/sit.js new file mode 100644 index 0000000..4c5035b --- /dev/null +++ b/Canopy [BP]/scripts/src/commands/sit.js @@ -0,0 +1,19 @@ +import { Command } from 'lib/canopy/Canopy'; +import { sit } from 'src/rules/playerSit'; + +new Command({ + name: 'sit', + description: { translate: 'commands.sit' }, + usage: 'sit', + args: [ + { type: 'number', name: 'distance' }, + ], + callback: sitCommand, + contingentRules: ['playerSit'] +}); + +function sitCommand(sender, args) { + if (sender?.getComponent('riding')?.entityRidingOn) + return sender.sendMessage({ translate: 'commands.sit.busy' }); + sit(sender, args); +} \ No newline at end of file diff --git a/Canopy [BP]/scripts/src/commands/tntfuse.js b/Canopy [BP]/scripts/src/commands/tntfuse.js index 625a1a0..303896e 100644 --- a/Canopy [BP]/scripts/src/commands/tntfuse.js +++ b/Canopy [BP]/scripts/src/commands/tntfuse.js @@ -1,6 +1,7 @@ import { system, world } from '@minecraft/server' import { Rule, Command } from 'lib/canopy/Canopy' +const MIN_FUSE_TICKS = 1; const MAX_FUSE_TICKS = 72000; new Rule({ @@ -21,20 +22,21 @@ const cmd = new Command({ }); world.afterEvents.entitySpawn.subscribe(async (event) => { - if (event.entity.typeId !== 'minecraft:tnt') return; + if (event.entity?.typeId !== 'minecraft:tnt') return; const fuseTimeProperty = world.getDynamicProperty('tntFuseTime'); let fuseTime = 80; - if (fuseTimeProperty !== undefined && await Rule.getValue('commandTntFuse')) + if (fuseTimeProperty !== undefined && Rule.getNativeValue('commandTntFuse')) fuseTime = fuseTimeProperty; - - if (fuseTime === 80) { - event.entity.triggerEvent('canopy:normalFuse'); + + if (fuseTime === 1) { + event.entity.triggerEvent('canopy:explode'); } else { - event.entity.triggerEvent('canopy:longFuse'); + event.entity.triggerEvent('canopy:fuse'); system.runTimeout(() => { event.entity.triggerEvent('canopy:explode'); - }, fuseTime); + }, fuseTime - 1); } + }); function tntfuseCommand(sender, args) { @@ -44,8 +46,8 @@ function tntfuseCommand(sender, args) { } else if (ticks === 'reset') { ticks = 80; sender.sendMessage({ translate: 'commands.tntfuse.reset.success' }); - } else if (ticks < 0 || ticks > MAX_FUSE_TICKS) - return sender.sendMessage({ translate: 'commands.tntfuse.set.fail', with: [String(ticks), String(MAX_FUSE_TICKS)] }); + } else if (ticks < MIN_FUSE_TICKS || ticks > MAX_FUSE_TICKS) + return sender.sendMessage({ translate: 'commands.tntfuse.set.fail', with: [String(ticks), String(MIN_FUSE_TICKS), String(MAX_FUSE_TICKS)] }); else { sender.sendMessage({ translate: 'commands.tntfuse.set.success', with: [String(ticks)] }); } diff --git a/Canopy [BP]/scripts/src/rules/playerSit.js b/Canopy [BP]/scripts/src/rules/playerSit.js index 6f274ef..cb23fd6 100644 --- a/Canopy [BP]/scripts/src/rules/playerSit.js +++ b/Canopy [BP]/scripts/src/rules/playerSit.js @@ -2,7 +2,7 @@ import { DimensionTypes, system, world } from '@minecraft/server'; import { Rule } from 'lib/canopy/Canopy'; const SNEAK_COUNT = 3; -const SNEAK_SPEED = 6; +const SNEAK_SPEED = 10; new Rule({ category: 'Rules', @@ -52,4 +52,6 @@ function cleanupRideableEntities() { } }); }); -} \ No newline at end of file +} + +export { sit }; \ No newline at end of file diff --git a/Canopy [RP]/manifest.json b/Canopy [RP]/manifest.json index c4b126a..b8d11c6 100644 --- a/Canopy [RP]/manifest.json +++ b/Canopy [RP]/manifest.json @@ -1,7 +1,7 @@ { "format_version": 2, "header": { - "name": "Canopy [RP] v1.3.5", + "name": "Canopy [RP] v1.3.6", "description": "Technical informatics & features addon by §aForestOfLight§r.", "uuid": "bcf34368-ed0c-4cf7-938e-582cccf9950d", "version": [1, 0, 1], @@ -17,7 +17,7 @@ "dependencies": [ { "uuid": "7f6b23df-a583-476b-b0e4-87457e65f7c0", // Canopy [BP] - "version": [1, 3, 5] + "version": [1, 3, 6] } ] } \ No newline at end of file diff --git a/Canopy [RP]/texts/de_DE.lang b/Canopy [RP]/texts/de_DE.lang index 7251595..0f553f4 100644 --- a/Canopy [RP]/texts/de_DE.lang +++ b/Canopy [RP]/texts/de_DE.lang @@ -194,7 +194,7 @@ commands.tick.sleep.success=§7%1 Pausiert den Server für %2 ms. commands.tntfuse=Setzt die Zündungszeit von gezündetem TNT in Ticks. commands.tntfuse.reset.success=§7Setzt die TNT-Zündzeit auf §a80§7 Ticks zurück. -commands.tntfuse.set.fail=§cUngültige Zünderzeit: %1 Ticks. Muss zwischen 0 und %2 Ticks liegen. +commands.tntfuse.set.fail=§cUngültige Zünderzeit: %1 Ticks. Muss zwischen $2 und %3 Ticks liegen. commands.tntfuse.set.success=§7TNT- Zündungszeit auf §a%s§7 Ticks eingestellt. commands.trackevent=Zählt, wie oft ein Ereignis auftritt. Zeigt die Anzahl im InfoDisplay an. diff --git a/Canopy [RP]/texts/en_US.lang b/Canopy [RP]/texts/en_US.lang index 97b0312..50e8a36 100644 --- a/Canopy [RP]/texts/en_US.lang +++ b/Canopy [RP]/texts/en_US.lang @@ -146,6 +146,9 @@ commands.removeentity.success=§7Removed %1 with id '%2'. commands.resetall=Resets all §lCanopy§r§8 rules and data. Use with caution. commands.resetall.success=§7All §lCanopy§r§8 player and world dynamic properties have been reset. +commands.sit=Makes your player sit down. +commands.sit.busy=§cYou are busy and cannot sit down. + commands.spawn=Spawn command for tracking and mocking spawns. commands.spawn.entities=Displays a list of all entities & their positions in the world. commands.spawn.recent=Displays all mob spawns from the last 30s. Specify a mob name to filter. @@ -194,7 +197,7 @@ commands.tick.sleep.success=§7%1 pausing the server for %2 ms. commands.tntfuse=Sets the fuse time of primed TNT in ticks. commands.tntfuse.reset.success=§7Reset TNT fuse time to §a80§7 ticks. -commands.tntfuse.set.fail=§cInvalid fuse time: %1 ticks. Must be between 0 and %2 ticks. +commands.tntfuse.set.fail=§cInvalid fuse time: %1 ticks. Must be between %2 and %3 ticks. commands.tntfuse.set.success=§7TNT fuse time set to §a%s§7 ticks. commands.trackevent=Count the number of times any event occurs. Displays the count in the InfoDisplay.