Skip to content

Commit

Permalink
Merge branch 'v1.3.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Dec 5, 2024
2 parents 7f78974 + ff7f153 commit 61c08b9
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 50 deletions.
21 changes: 3 additions & 18 deletions Canopy [BP]/entities/tnt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -77,17 +69,10 @@
]
}
},
"canopy:normalFuse": {
"add": {
"component_groups": [
"canopy:normalFuse"
]
}
},
"canopy:longFuse": {
"canopy:fuse": {
"add": {
"component_groups": [
"canopy:longFuse"
"canopy:fuse"
]
}
},
Expand Down
8 changes: 4 additions & 4 deletions Canopy [BP]/manifest.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand All @@ -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]
Expand Down
20 changes: 10 additions & 10 deletions Canopy [BP]/scripts/lib/canopy/Rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions Canopy [BP]/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/classes/Instaminable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/commands/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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 });
Expand Down
19 changes: 19 additions & 0 deletions Canopy [BP]/scripts/src/commands/sit.js
Original file line number Diff line number Diff line change
@@ -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);
}
20 changes: 11 additions & 9 deletions Canopy [BP]/scripts/src/commands/tntfuse.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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) {
Expand All @@ -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)] });
}
Expand Down
6 changes: 4 additions & 2 deletions Canopy [BP]/scripts/src/rules/playerSit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -52,4 +52,6 @@ function cleanupRideableEntities() {
}
});
});
}
}

export { sit };
4 changes: 2 additions & 2 deletions Canopy [RP]/manifest.json
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -17,7 +17,7 @@
"dependencies": [
{
"uuid": "7f6b23df-a583-476b-b0e4-87457e65f7c0", // Canopy [BP]
"version": [1, 3, 5]
"version": [1, 3, 6]
}
]
}
2 changes: 1 addition & 1 deletion Canopy [RP]/texts/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion Canopy [RP]/texts/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 61c08b9

Please sign in to comment.