From 861fde408d299d9f4d922a171d254d20aadc8211 Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Tue, 13 Aug 2024 17:42:32 -0700 Subject: [PATCH] feature renames and usage updates --- Canopy [BP]/scripts/main.js | 4 ++-- Canopy [BP]/scripts/src/classes/ProbeManager.js | 4 ++-- Canopy [BP]/scripts/src/commands/claimprojectiles.js | 3 +++ Canopy [BP]/scripts/src/commands/feature.js | 5 ++--- Canopy [BP]/scripts/src/commands/help.js | 12 +++++++----- Canopy [BP]/scripts/src/config/database.js | 4 ++-- .../features/{pickupOnMine.js => autoItemPickup.js} | 6 +++--- .../src/features/{noExplosion.js => explosionOff.js} | 2 +- Canopy [BP]/scripts/src/features/flippinArrows.js | 1 - Canopy [BP]/scripts/src/features/renewableElytra.js | 2 +- 10 files changed, 23 insertions(+), 20 deletions(-) rename Canopy [BP]/scripts/src/features/{pickupOnMine.js => autoItemPickup.js} (89%) rename Canopy [BP]/scripts/src/features/{noExplosion.js => explosionOff.js} (67%) diff --git a/Canopy [BP]/scripts/main.js b/Canopy [BP]/scripts/main.js index 9b9a7b3..a8aef3a 100644 --- a/Canopy [BP]/scripts/main.js +++ b/Canopy [BP]/scripts/main.js @@ -33,7 +33,7 @@ import 'src/commands/scriptevents/spawn' // Features import 'src/features/InfoDisplay' import 'src/features/explosionNoBlockDamage' -import 'src/features/pickupOnMine' +import 'src/features/autoItemPickup' import 'src/features/universalChunkLoading' import 'src/features/noTileDrops' import 'src/features/flippinArrows' @@ -44,7 +44,7 @@ import 'src/features/pistonBedrockBreaking' import 'src/features/hotbarSwitching' import 'src/features/renewableSponge' import 'src/features/armorStandRespawning' -import 'src/features/noExplosion' +import 'src/features/explosionOff' import 'src/features/explosionChainReactionOnly' import 'src/features/instantTame' import 'src/features/entityInstantDeath' diff --git a/Canopy [BP]/scripts/src/classes/ProbeManager.js b/Canopy [BP]/scripts/src/classes/ProbeManager.js index 88aa152..3dd7f08 100644 --- a/Canopy [BP]/scripts/src/classes/ProbeManager.js +++ b/Canopy [BP]/scripts/src/classes/ProbeManager.js @@ -116,7 +116,7 @@ class ProbeManager { removeProbe(player) { const probe = this.probeMap[player.id]; - if (!probe) return console.warn(`[Probe Manager] Error while removing: No probe found for player ${player.name}`); + if (!probe) return console.warn(`[Probe Manager] Error while removing: No probe found for player ${player?.name}`); probe.detachFromPlayer(); if (probe.entity.isValid()) probe.entity.remove(); @@ -211,7 +211,7 @@ class ProbeManager { } } } - if (count > 0) console.warn(`[Probe Manager] Removed ${count} unused probes`); + if (count > 20) console.warn(`[Probe Manager] Large number of unused probes found! Removed ${count} unused probes.`); }, CLEANUP_INTERVAL); } } diff --git a/Canopy [BP]/scripts/src/commands/claimprojectiles.js b/Canopy [BP]/scripts/src/commands/claimprojectiles.js index 4130cef..e1778e2 100644 --- a/Canopy [BP]/scripts/src/commands/claimprojectiles.js +++ b/Canopy [BP]/scripts/src/commands/claimprojectiles.js @@ -18,6 +18,9 @@ function claimProjectilesCommand(sender, args) { if (!targetPlayer) return sender.sendMessage(`§cPlayer "${playerName}" was not found.`) const projectiles = getProjectilesInRange(sender, CLAIM_RADIUS); + + if (projectiles.length === 0) + return sender.sendMessage('§7No projectiles found in range.'); const numChanged = changeOwner(projectiles, targetPlayer); sender.sendMessage(`§7Successfully changed the owner of ${numChanged} projectiles to ${targetPlayer.name}.`) diff --git a/Canopy [BP]/scripts/src/commands/feature.js b/Canopy [BP]/scripts/src/commands/feature.js index a9a268c..e684052 100644 --- a/Canopy [BP]/scripts/src/commands/feature.js +++ b/Canopy [BP]/scripts/src/commands/feature.js @@ -7,7 +7,6 @@ import { resetCounterMap } from 'src/commands/counter' class RelatedFeatures { constructor() { this.dependancies = [ - { validFeature: 'commandJump', dependantFeature: 'commandJumpSurvival' }, { validFeature: 'commandWarp', dependantFeature: 'commandWarpSurvival' }, { validFeature: 'hotbarSwitching', dependantFeature: 'hotbarSwitchingSurvival' }, { validFeature: 'instantTame', dependantFeature: 'instantTameSurvival' }, @@ -28,10 +27,10 @@ new Command() function featureCommand(sender, args) { const globalFeatures = module.exports['features']; const { feature, enable } = args; - const loweredFeature = feature.toLowerCase(); - if (feature === null || enable === null) return sender.sendMessage(`§cUsage: ./feature `); + + const loweredFeature = feature.toLowerCase(); if (!isValidFeature(loweredFeature)) return sender.sendMessage(`§cInvalid feature: ${feature}`); diff --git a/Canopy [BP]/scripts/src/commands/help.js b/Canopy [BP]/scripts/src/commands/help.js index 006f6cf..160ccca 100644 --- a/Canopy [BP]/scripts/src/commands/help.js +++ b/Canopy [BP]/scripts/src/commands/help.js @@ -86,10 +86,10 @@ class HelpBook { this.helpPages[1].addItem('camera', './camera spectate', 'Survival-friendly spectator mode. Toggles freecam. (alias: ./cs)'); this.helpPages[1].addItem('change dimension', './changedimension [x y z]', 'Teleports you to the specified dimension.'); this.helpPages[1].addItem('claim projectiles', './claimprojectiles [playerName]', 'Changes the owner of all projectiles within a 10 block radius.'); - this.helpPages[1].addItem('hopper counters', './counter [color/all]', 'Displays the count and rates of the hopper counters. (alias: ./ct)'); + this.helpPages[1].addItem('hopper counters', './counter [color]', 'Displays the count and rates of the hopper counters. (alias: ./ct)'); this.helpPages[1].addItem('hopper counters', './counter ', 'Sets the mode of a hopper counter: countMode, perhourMode, perminuteMode, or persecondMode. (alias: ./ct)'); - this.helpPages[1].addItem('hopper counters', './counter realtime', 'Toggles real-world time and tick-based time to do rate calculations. (alias: ./ct)'); - this.helpPages[1].addItem('data', './data', 'Displays information about the block you are looking at.'); + this.helpPages[1].addItem('hopper counters', './counter [color] realtime', 'Like ./counter [color], but uses real-world time instead of tick-based time to do rate calculations. (alias: ./ct)'); + this.helpPages[1].addItem('data', './data', 'Displays information about the block or entity you are looking at.'); this.helpPages[2].addItem('distance', './distance target', 'Calculates the distance between you and the block or entity you are looking at. (alias: ./d)'); this.helpPages[2].addItem('distance', './distance from to [x y z]', 'Calculates the distance between two points. (alias: ./d)'); @@ -102,6 +102,7 @@ class HelpBook { this.helpPages[2].addItem('log', './log [precision]', 'Logs the location of the specified entity type in chat.'); this.helpPages[2].addItem('peek', './peek [search term]', 'Peeks at a block or entity\'s inventory. Use the search term to highlight items that include it. (alias: ./p)'); + this.helpPages[3].addItem('remove entity', './removeentity [id]', 'Removes the entity you are looking at. Specify an entity ID to remove a specific entity.'); this.helpPages[3].addItem('spawn', './spawn entities', 'Displays a list of all entities in the world.'); this.helpPages[3].addItem('spawn', './spawn recent [mobname]', 'Displays all mob spawns in the last 30s. Optionally specify a mob name to filter results.'); this.helpPages[3].addItem('spawn', './spawn tracking start [x1 y1 z1] [x2 y2 z2]', 'Starts tracking mob spawns. Specify coords to track spawns within that area.'); @@ -111,13 +112,14 @@ class HelpBook { this.helpPages[3].addItem('spawn', './spawn mocking ', 'Enables/disables mob spawning while allowing the spawning algorithm to run.'); this.helpPages[3].addItem('spawn', './spawn test', 'Resets spawn tracking data and all hopper counters.'); this.helpPages[3].addItem('summon tnt', './summontnt ', 'Summons the specified amount of primed TNT entity at your location.'); - this.helpPages[3].addItem('tick', './tick ', 'Slows down the server tick speed to the specified mspt.'); + this.helpPages[4].addItem('tick', './tick ', 'Slows down the server tick speed to the specified mspt.'); this.helpPages[4].addItem('tick', './tick step [steps]', 'Allows the server to run at normal speed for the specified amount of steps.'); this.helpPages[4].addItem('tick', './tick reset', 'Resets the server tick speed to normal.'); + this.helpPages[4].addItem('tnt fuse', './tntfuse ', 'Sets the fuse time of primed TNT entities in ticks.'); this.helpPages[4].addItem('trackevent', './trackevent [beforeEvent/afterEvent]', 'Toggles counting the specified event in the InfoDisplay.'); - this.helpPages[4].addItem('warp', './warp ', 'Teleports you to a warp. (alias: ./w)'); this.helpPages[4].addItem('warp', './warp ', 'Adds or removes a warp. (alias: ./w)'); + this.helpPages[4].addItem('warp', './warp ', 'Teleports you to a warp. (alias: ./w)'); this.helpPages[4].addItem('warps', './warps', 'Lists all available warps.'); this.helpPages[4].addItem('reset all', './resetall', 'Resets all §l§aCanopy§r§7 features and data.'); } diff --git a/Canopy [BP]/scripts/src/config/database.js b/Canopy [BP]/scripts/src/config/database.js index bf863be..586997e 100644 --- a/Canopy [BP]/scripts/src/config/database.js +++ b/Canopy [BP]/scripts/src/config/database.js @@ -21,6 +21,7 @@ const infoDisplay = newDB([ const features = newDB([ 'armorStandRespawning', + 'autoItemPickup', 'commandCamera', 'commandClaimProjectiles', 'commandJumpSurvival', @@ -35,15 +36,14 @@ const features = newDB([ 'entityInstantDeath', 'explosionChainReactionOnly', 'explosionNoBlockDamage', + 'explosionOff', 'flippinArrows', 'hopperCounters', 'hotbarSwitching', 'hotbarSwitchingSurvival', 'instantTame', 'instantTameSurvival', - 'noExplosion', 'noTileDrops', - 'pickupOnMine', 'pistonBedrockBreaking', 'renewableElytra', 'renewableSponge', diff --git a/Canopy [BP]/scripts/src/features/pickupOnMine.js b/Canopy [BP]/scripts/src/features/autoItemPickup.js similarity index 89% rename from Canopy [BP]/scripts/src/features/pickupOnMine.js rename to Canopy [BP]/scripts/src/features/autoItemPickup.js index ad642bd..6b9fe2a 100644 --- a/Canopy [BP]/scripts/src/features/pickupOnMine.js +++ b/Canopy [BP]/scripts/src/features/autoItemPickup.js @@ -8,15 +8,15 @@ system.runInterval(() => { }); world.afterEvents.playerBreakBlock.subscribe(blockEvent => { - if (!world.getDynamicProperty('pickupOnMine')) return; - if (!blockEvent.player.getDynamicProperty('pickupOnMine')) return; + if (!world.getDynamicProperty('autoItemPickup')) return; + if (!blockEvent.player.getDynamicProperty('autoItemPickup')) return; if (blockEvent.player.getGameMode() === 'creative') return; brokenBlockEventsThisTick.push(blockEvent); }); world.afterEvents.entitySpawn.subscribe(entityEvent => { if (entityEvent.cause !== 'Spawned' || entityEvent.entity.typeId !== 'minecraft:item') return; - if (!world.getDynamicProperty('pickupOnMine')) return; + if (!world.getDynamicProperty('autoItemPickup')) return; const item = entityEvent.entity; let brokenBlockEvent; diff --git a/Canopy [BP]/scripts/src/features/noExplosion.js b/Canopy [BP]/scripts/src/features/explosionOff.js similarity index 67% rename from Canopy [BP]/scripts/src/features/noExplosion.js rename to Canopy [BP]/scripts/src/features/explosionOff.js index 095c1de..486ba0a 100644 --- a/Canopy [BP]/scripts/src/features/noExplosion.js +++ b/Canopy [BP]/scripts/src/features/explosionOff.js @@ -1,6 +1,6 @@ import { world } from "@minecraft/server"; world.beforeEvents.explosion.subscribe((event) => { - if (!world.getDynamicProperty('noExplosion')) return; + if (!world.getDynamicProperty('explosionOff')) return; event.cancel = true; }); \ No newline at end of file diff --git a/Canopy [BP]/scripts/src/features/flippinArrows.js b/Canopy [BP]/scripts/src/features/flippinArrows.js index 54fc424..93bc183 100644 --- a/Canopy [BP]/scripts/src/features/flippinArrows.js +++ b/Canopy [BP]/scripts/src/features/flippinArrows.js @@ -13,7 +13,6 @@ const openIds = ['iron_trapdoor', 'iron_door']; const noInteractBlockIds = ['piston_arm_collision', 'sticky_piston_arm_collision', 'bed']; system.runInterval(() => { - // if (!world.getDynamicProperty('flippinArrows')) return; previousBlocks.shift(); if (previousBlocks.length < WAIT_TIME_BETWEEN_USE) { previousBlocks.push(null); diff --git a/Canopy [BP]/scripts/src/features/renewableElytra.js b/Canopy [BP]/scripts/src/features/renewableElytra.js index 0b8bb77..88827c4 100644 --- a/Canopy [BP]/scripts/src/features/renewableElytra.js +++ b/Canopy [BP]/scripts/src/features/renewableElytra.js @@ -4,7 +4,7 @@ world.afterEvents.entityDie.subscribe((event) => { if (!world.getDynamicProperty('renewableElytra')) return; const entity = event.deadEntity; if (entity?.typeId === 'minecraft:phantom' && event.damageSource.damagingProjectile?.typeId === 'minecraft:shulker_bullet') { - if (Math.random() > 0.05) return; + if (Math.random() > 0.01) return; entity.dimension.spawnItem(new ItemStack('minecraft:elytra', 1), entity.location); } }); \ No newline at end of file