Skip to content

Commit

Permalink
feature renames and usage updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Aug 14, 2024
1 parent 425b6a7 commit 861fde4
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/classes/ProbeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
Expand Down
3 changes: 3 additions & 0 deletions Canopy [BP]/scripts/src/commands/claimprojectiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}.`)
Expand Down
5 changes: 2 additions & 3 deletions Canopy [BP]/scripts/src/commands/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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 <feature> <true/false>`);

const loweredFeature = feature.toLowerCase();
if (!isValidFeature(loweredFeature))
return sender.sendMessage(`§cInvalid feature: ${feature}`);

Expand Down
12 changes: 7 additions & 5 deletions Canopy [BP]/scripts/src/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dimension> [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 <color/all> <mode>', '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 <x y z> to [x y z]', 'Calculates the distance between two points. (alias: ./d)');
Expand All @@ -102,6 +102,7 @@ class HelpBook {
this.helpPages[2].addItem('log', './log <tnt/projectiles/falling_blocks> [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.');
Expand All @@ -111,13 +112,14 @@ class HelpBook {
this.helpPages[3].addItem('spawn', './spawn mocking <true/false>', '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 <amount>', 'Summons the specified amount of primed TNT entity at your location.');
this.helpPages[3].addItem('tick', './tick <mspt>', 'Slows down the server tick speed to the specified mspt.');

this.helpPages[4].addItem('tick', './tick <mspt>', '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 <ticks/reset>', 'Sets the fuse time of primed TNT entities in ticks.');
this.helpPages[4].addItem('trackevent', './trackevent <eventName> [beforeEvent/afterEvent]', 'Toggles counting the specified event in the InfoDisplay.');
this.helpPages[4].addItem('warp', './warp <name>', 'Teleports you to a warp. (alias: ./w)');
this.helpPages[4].addItem('warp', './warp <add/remove> <name>', 'Adds or removes a warp. (alias: ./w)');
this.helpPages[4].addItem('warp', './warp <name>', '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.');
}
Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/config/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const infoDisplay = newDB([

const features = newDB([
'armorStandRespawning',
'autoItemPickup',
'commandCamera',
'commandClaimProjectiles',
'commandJumpSurvival',
Expand All @@ -35,15 +36,14 @@ const features = newDB([
'entityInstantDeath',
'explosionChainReactionOnly',
'explosionNoBlockDamage',
'explosionOff',
'flippinArrows',
'hopperCounters',
'hotbarSwitching',
'hotbarSwitchingSurvival',
'instantTame',
'instantTameSurvival',
'noExplosion',
'noTileDrops',
'pickupOnMine',
'pistonBedrockBreaking',
'renewableElytra',
'renewableSponge',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
});
1 change: 0 additions & 1 deletion Canopy [BP]/scripts/src/features/flippinArrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/features/renewableElytra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

0 comments on commit 861fde4

Please sign in to comment.