make showStructBlockInfo not a rule

This commit is contained in:
ForestOfLight
2025-03-17 00:52:43 -07:00
Unverified
parent fb3deea181
commit 9eea8b4413
4 changed files with 33 additions and 42 deletions
+6 -6
View File
@@ -30,14 +30,14 @@ Removes a structure.
## Roadmap ## Roadmap
- [ ] Add new structures by pasting a string - [ ] place structure **(in progress)**
- [ ] Make a viewable material list - [x] easyPlace rule
- [x] Make a viewable material list
- [ ] Make automatic material gathering from inventories
- [ ] structure movement & rotation
- [ ] structuraMode & holoprintMode rules for ease of use - [ ] structuraMode & holoprintMode rules for ease of use
- [ ] Make automatic material grabbing from inventories
- [ ] structure placement (ghost and solid)
- [ ] easyPlace rule
- [ ] more litematica features!
- [ ] send structure as a scriptevent so that other addons can use it - [ ] send structure as a scriptevent so that other addons can use it
- [ ] more litematica features!
## Issues & Suggestions ## Issues & Suggestions
+24
View File
@@ -0,0 +1,24 @@
import { system, world } from '@minecraft/server';
import { Raycaster } from '../classes/Raycaster';
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
if (!player)
continue;
showStructureBlockInfo(player);
}
});
function showStructureBlockInfo(player) {
const block = Raycaster.getTargetedStructureBlock(player, { isFirst: true, collideWithWorldBlocks: true });
if (!block)
return;
player.onScreenDisplay.setActionBar({ text: getFormattedBlockInfo(block.permutation) });
}
function getFormattedBlockInfo(block) {
const states = block.getAllStates();
if (Object.keys(states).length === 0)
return `Structure:\n§a${block.type.id}`;
return `Structure:\n§a${block.type.id}\n§7${JSON.stringify(block.getAllStates())}`;
}
+3 -1
View File
@@ -1,7 +1,9 @@
// Rules // Rules
import './rules/easyPlace'; import './rules/easyPlace';
import './rules/fastEasyPlace'; import './rules/fastEasyPlace';
import './rules/showStructBlockInfo';
// Commands // Commands
import './commands/struct'; import './commands/struct';
// Other
import './classes/BlockInfo';
-35
View File
@@ -1,35 +0,0 @@
import { Rule } from '../lib/canopy/CanopyExtension';
import { extension } from '../config';
import { system, world } from '@minecraft/server';
import { Raycaster } from '../classes/Raycaster';
let runner = void 0;
const showStructBlockInfo = new Rule({
identifier: 'showStructBlockInfo',
description: { text: 'Shows block and state info for structure blocks you are looking at.' },
onEnableCallback: () => { runner = system.runInterval(onTick); },
onDisableCallback: () => { system.clearRun(runner); }
})
extension.addRule(showStructBlockInfo);
function onTick() {
for (const player of world.getAllPlayers()) {
if (!player)
continue;
showStructureBlockInfo(player);
}
}
function showStructureBlockInfo(player) {
const block = Raycaster.getTargetedStructureBlock(player, { isFirst: true, collideWithWorldBlocks: true });
if (!block)
return;
player.onScreenDisplay.setActionBar({ text: getFormattedBlockInfo(block.permutation) });
}
function getFormattedBlockInfo(block) {
const states = block.getAllStates();
if (Object.keys(states).length === 0)
return `Structure:\n§a${block.type.id}`;
return `Structure:\n§a${block.type.id}\n§7${JSON.stringify(block.getAllStates())}`;
}