Skip to content

Commit

Permalink
command syntax, hopperCounters, noTileDrops, and rebrand
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Jul 5, 2024
1 parent c2aafd2 commit 43a6cb8
Show file tree
Hide file tree
Showing 50 changed files with 883 additions and 755 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions Info Display [BP]/manifest.json → Canopy [BP]/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"format_version": 2,
"header": {
"name": "Info Display [BP]",
"description": "Info Display by §uAlecs§r and largely expanded by §aForestOfLight§r for the §dAmelix Foundation§r.",
"name": "Canopy [BP]",
"description": "Technical informatics and QoL addon by §aForestOfLight§r.",
"uuid": "e9f3a30c-f040-4cb7-a146-e15e7088f2ff",
"min_engine_version": [1, 21, 1],
"version": [1, 2, 2]
"version": [1, 2, 3]
},
"modules": [
{
Expand Down
Binary file added Canopy [BP]/pack_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions Canopy [BP]/scripts/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as mc from '@minecraft/server'

// Config
import 'src/config/database'

// Commands
import 'src/commands/info'
import 'src/commands/help'
import 'src/commands/peek'
import 'src/commands/jump'
import 'src/commands/warp'
import 'src/commands/gamemode'
import 'src/commands/camera'
import 'src/commands/feature'
import 'src/commands/distance'
import 'src/commands/tntlog'
import 'src/commands/summontnt'
import 'src/commands/entitydensity'
import 'src/commands/health'
import 'src/commands/counter'
import 'src/commands/resetall'
import 'src/commands/data'

// Features
import 'src/features/InfoDisplay'
import 'src/features/noExplosionBlockDamage'
import 'src/features/pickupOnMine'
import 'src/features/universalChunkLoading'
import 'src/features/noTileDrops'

let hasShownWelcome = false;

mc.world.afterEvents.playerJoin.subscribe((event) => {
let runner = mc.system.runInterval(() => {
const players = mc.world.getPlayers({ name: event.playerName });
players.forEach(player => {
if (!hasShownWelcome && player.isValid()) {
mc.system.clearRun(runner);
hasShownWelcome = true;
displayWelcome(player);
}
});
});
});

function displayWelcome(player) {
let output = '';
output += `§a + ----- +\n`;
output += `§a / / |\n`;
output += `§a+ ----- + |\n`;
output += `§a | | +\n`;
output += `§a | | /\n`;
output += `§a+ ----- +\n`;
output += `§7This server is running §l§aCanopy§r§7. Type ./help to get started.§r\n`;
player.sendMessage(output);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Command from 'stickycore/command'
import * as mc from '@minecraft/server'
import Utils from 'stickycore/utils'

mc.world.beforeEvents.playerLeave.subscribe((ev) => {
const player = ev.player;
Expand All @@ -16,23 +15,19 @@ mc.world.afterEvents.playerDimensionChange.subscribe((ev) => {
});

new Command()
.setName('placecamera')
.setCallback(placeCameraCommand)
.setName('camera')
.addArgument('string', 'action')
.setCallback(cameraCommand)
.build()

new Command()
.setName('pc')
.setCallback(placeCameraCommand)
.setName('cp')
.setCallback((sender) => cameraCommand(sender, 'place'))
.build()

new Command()
.setName('viewcamera')
.setCallback(viewCameraCommand)
.build()

new Command()
.setName('vc')
.setCallback(viewCameraCommand)
.setName('cv')
.setCallback((sender) => cameraCommand(sender, 'view'))
.build()

class Camera {
Expand All @@ -43,10 +38,26 @@ class Camera {
}
}

function placeCameraCommand(sender) {
function cameraCommand(sender, args) {
const { action } = args;
if (!mc.world.getDynamicProperty('placecamera')) return sender.sendMessage('§cThe placecamera feature is disabled.');

switch (action) {
case 'place':
placeCameraAction(sender);
break;
case 'view':
viewCameraAction(sender);
break;
default:
sender.sendMessage('§cUsage: ./camera <place/view>');
break;
}
}

function placeCameraAction(sender) {
let camera;

if (!mc.world.getDynamicProperty('placecamera')) return sender.sendMessage('§cThe placecamera feature is disabled.');
if (sender.getDynamicProperty('isViewingCamera')) return sender.sendMessage('§cYou cannot place a camera while viewing one.');

camera = new Camera(
Expand All @@ -62,10 +73,9 @@ function placeCamera(sender, camera) {
sender.sendMessage(`§7Camera placed at [${camera.location.x.toFixed(0)}, ${camera.location.y.toFixed(0)}, ${camera.location.z.toFixed(0)}].`);
}

function viewCameraCommand(sender) {
function viewCameraAction(sender) {
let placedCamera;

if (!mc.world.getDynamicProperty('placecamera')) return sender.sendMessage('§cThe placecamera feature is disabled.');
if (!sender.getDynamicProperty('placedCamera')) return sender.sendMessage('§cYou have not placed a camera yet.');

placedCamera = JSON.parse(sender.getDynamicProperty('placedCamera'));
Expand All @@ -88,7 +98,6 @@ function startCameraView(sender, placedCamera) {
rotation: placedCamera.rotation
});
sender.setDynamicProperty('isViewingCamera', true);
// sender.sendMessage(`§7Now viewing placed camera at ${Utils.stringifyLocation(placedCamera.location, 0)}.`);
}

function endCameraView(sender) {
Expand All @@ -100,5 +109,4 @@ function endCameraView(sender) {
sender.camera.clear();
}, 8);
sender.setDynamicProperty('isViewingCamera', false);
// sender.sendMessage(`§7Stopped viewing placed camera.`);
}
Loading

0 comments on commit 43a6cb8

Please sign in to comment.