Now is standalone from Canopy
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
||||
import { BlockPermutation, EntityComponentTypes, GameMode, ItemStack, system, world } from '@minecraft/server';
|
||||
import { structureCollection } from '../classes/StructureCollection';
|
||||
import { structureCollection } from '../classes/Structure/StructureCollection';
|
||||
import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, specialItemPlacementConversions,
|
||||
blockIdToItemStackMap } from '../data';
|
||||
import { fetchMatchingItemSlot } from '../utils';
|
||||
|
||||
const ACTION_SLOT = 35;
|
||||
const ACTION_SLOT = 27;
|
||||
|
||||
new BuilderOption({
|
||||
const builderOption = new BuilderOption({
|
||||
identifier: 'easyPlace',
|
||||
displayName: 'Easy Place',
|
||||
description: 'Always place the correct block.',
|
||||
howToUse: "Place blocks in a structure with a paper named 'Easy Place' in the bottom right slot of your inventory to always place the correct block.",
|
||||
onEnableCallback: () => { world.beforeEvents.playerPlaceBlock.subscribe(onPlayerPlaceBlock); },
|
||||
onDisableCallback: () => { world.beforeEvents.playerPlaceBlock.unsubscribe(onPlayerPlaceBlock); }
|
||||
})
|
||||
description: 'Always place the correct structure block.',
|
||||
howToUse: "Place blocks in a structure with a paper named 'Easy Place' in the inventory slot above your first hotbar slot to always place the correct block."
|
||||
});
|
||||
|
||||
world.beforeEvents.playerPlaceBlock.subscribe(onPlayerPlaceBlock);
|
||||
|
||||
function onPlayerPlaceBlock(event) {
|
||||
const { player, block, permutationBeingPlaced } = event;
|
||||
if (!player || !block || !hasActionItemInCorrectSlot(player)) return;
|
||||
const { player, block } = event;
|
||||
if (!player || !block || !builderOption.isEnabled(player.id) || !hasActionItemInCorrectSlot(player)) return;
|
||||
const structureBlock = structureCollection.fetchStructureBlock(block.dimension.id, block.location);
|
||||
if (!structureBlock)
|
||||
return;
|
||||
|
||||
@@ -4,19 +4,21 @@ import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlo
|
||||
blockIdToItemStackMap } from '../data';
|
||||
import { Raycaster } from '../classes/Raycaster';
|
||||
|
||||
const PROCESS_INTERVAL = 2;
|
||||
|
||||
let runner = void 0;
|
||||
new BuilderOption({
|
||||
const builderOption = new BuilderOption({
|
||||
identifier: 'fastEasyPlace',
|
||||
displayName: 'Fast Easy Place',
|
||||
description: 'Place structure blocks just by looking at them.',
|
||||
howToUse: "Look at structure blocks with a paper named 'Easy Place' in your hand to place them.",
|
||||
onEnableCallback: () => { runner = system.runInterval(onTick, 2); },
|
||||
onDisableCallback: () => { system.clearRun(runner); }
|
||||
})
|
||||
});
|
||||
|
||||
system.runInterval(onTick, PROCESS_INTERVAL);
|
||||
|
||||
function onTick() {
|
||||
for (const player of world.getAllPlayers()) {
|
||||
if (!player)
|
||||
if (!player || !builderOption.isEnabled(player.id))
|
||||
continue;
|
||||
processEasyPlace(player);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
||||
import { world } from '@minecraft/server';
|
||||
|
||||
new BuilderOption({
|
||||
const builderOption = new BuilderOption({
|
||||
identifier: 'materialGrabber',
|
||||
displayName: 'Material Grabber',
|
||||
description: 'Pulls structure items from inventories.',
|
||||
howToUse: "Interact with inventories using a paper named 'Material Grabber' to pull structure items from them.",
|
||||
onEnableCallback: () => {
|
||||
world.beforeEvents.playerInteractWithBlock.subscribe(onPlayerInteract);
|
||||
world.beforeEvents.playerInteractWithEntity.subscribe(onPlayerInteract);
|
||||
},
|
||||
onDisableCallback: () => {
|
||||
world.beforeEvents.playerInteractWithBlock.unsubscribe(onPlayerInteract);
|
||||
world.beforeEvents.playerInteractWithEntity.unsubscribe(onPlayerInteract);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
world.beforeEvents.playerInteractWithBlock.subscribe(onPlayerInteract);
|
||||
world.beforeEvents.playerInteractWithEntity.subscribe(onPlayerInteract);
|
||||
|
||||
function onPlayerInteract(event) {
|
||||
// get inventory
|
||||
|
||||
Reference in New Issue
Block a user