From 59615312c87d6d7b4095c4f002d324eaecd5f81a Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Wed, 18 Jun 2025 12:03:57 -0700 Subject: [PATCH] functional on 1.21.90 --- Construct[BP]/manifest.json | 10 ++--- Construct[BP]/scripts/blocks.js | 14 ++++++- Construct[BP]/scripts/classes/BlockInfo.js | 2 +- Construct[BP]/scripts/options/easyPlace.js | 42 +++---------------- .../scripts/options/fastEasyPlace.js | 42 +++---------------- Construct[BP]/scripts/utils.js | 34 +++++++++++++++ README.md | 4 +- 7 files changed, 66 insertions(+), 82 deletions(-) diff --git a/Construct[BP]/manifest.json b/Construct[BP]/manifest.json index e11bf55..cb3ab48 100644 --- a/Construct[BP]/manifest.json +++ b/Construct[BP]/manifest.json @@ -1,11 +1,11 @@ { "format_version": 2, "header": { - "name": "Construct [BP] v1.0.0", + "name": "Construct [BP] v1.0.1", "description": "Survival building addon by §aForestOfLight§r.", "uuid": "8c0c0153-d8b9-482a-889f-aef922b8fe58", - "min_engine_version": [1, 21, 80], - "version": [1, 0, 0] + "min_engine_version": [1, 21, 90], + "version": [1, 0, 1] }, "modules": [ { @@ -26,11 +26,11 @@ "dependencies": [ { "module_name": "@minecraft/server", - "version": "2.0.0-beta" + "version": "2.1.0-beta" }, { "module_name": "@minecraft/server-ui", - "version": "2.0.0-beta" + "version": "2.1.0-beta" }, { "uuid": "375ec465-3dc1-429f-8b4c-a337889e1ed4", // Construct RP diff --git a/Construct[BP]/scripts/blocks.js b/Construct[BP]/scripts/blocks.js index 9ecdd36..c0424ec 100644 --- a/Construct[BP]/scripts/blocks.js +++ b/Construct[BP]/scripts/blocks.js @@ -2098,6 +2098,18 @@ export const blocks = { "sound" : "stone", "textures" : "skull" }, + "dried_ghast" : { + "carried_textures" : "dried_ghast_tentacles", + "sound" : "dried_ghast", + "textures" : { + "down" : "dried_ghast_bottom", + "east" : "dried_ghast_left", + "north" : "dried_ghast_back", + "south" : "dried_ghast_front", + "up" : "dried_ghast_top", + "west" : "dried_ghast_right" + } + }, "dried_kelp_block" : { "carried_textures" : { "down" : "dried_kelp_block_top", @@ -6338,4 +6350,4 @@ export const blocks = { "sound" : "stone", "textures" : "skull" } -} +} \ No newline at end of file diff --git a/Construct[BP]/scripts/classes/BlockInfo.js b/Construct[BP]/scripts/classes/BlockInfo.js index 34f6b19..75292bd 100644 --- a/Construct[BP]/scripts/classes/BlockInfo.js +++ b/Construct[BP]/scripts/classes/BlockInfo.js @@ -45,7 +45,7 @@ class BlockInfo { static getSupplyMessage(player, block) { const itemStack = fetchMatchingItemSlot(player, block.getItemStack()?.typeId); - const isInSurvival = player.getGameMode() === GameMode.survival; + const isInSurvival = player.getGameMode() === GameMode.Survival; if (!itemStack && isInSurvival) return ' §c[No Supply]'; return ''; diff --git a/Construct[BP]/scripts/options/easyPlace.js b/Construct[BP]/scripts/options/easyPlace.js index 869bce4..0c92ad4 100644 --- a/Construct[BP]/scripts/options/easyPlace.js +++ b/Construct[BP]/scripts/options/easyPlace.js @@ -1,9 +1,9 @@ import { BuilderOption } from '../classes/Builder/BuilderOption'; import { BlockPermutation, EntityComponentTypes, EquipmentSlot, GameMode, ItemStack, system, world } from '@minecraft/server'; import { structureCollection } from '../classes/Structure/StructureCollection'; -import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, specialItemPlacementConversions, +import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, blockIdToItemStackMap } from '../data'; -import { fetchMatchingItemSlot } from '../utils'; +import { fetchMatchingItemSlot, placeBlock } from '../utils'; import { Builders } from '../classes/Builder/Builders'; const builderOption = new BuilderOption({ @@ -66,9 +66,10 @@ function tryPlaceBlock(event, player, block, structureBlock) { if (shouldPreventAction(player, structureBlock)) return preventAction(event, player); structureBlock = tryConvertBannedToValidBlock(structureBlock); - if (player.getGameMode() === GameMode.creative) { - placeBlock(block, structureBlock); - } else if (player.getGameMode() === GameMode.survival) { + if (player.getGameMode() === GameMode.Creative) { + event.cancel = true; + placeBlock(player, block, structureBlock); + } else if (player.getGameMode() === GameMode.Survival) { structureBlock = tryConvertToDefaultState(structureBlock); tryPlaceBlockSurvival(event, player, block, structureBlock); } @@ -134,35 +135,4 @@ function getPlaceableItemStack(structureBlock) { const blockId = structureBlock.type.id.replace('minecraft:', ''); const newItemId = blockIdToItemStackMap[blockId]; return newItemId ? new ItemStack(newItemId) : structureBlock.getItemStack(); -} - -function placeBlock(player, block, structureBlock, itemSlot) { - system.run(() => { - if (itemSlot) - consumeItem(itemSlot); - block.setPermutation(structureBlock); - playSoundEffect(player, block, structureBlock); - }); -} - -function consumeItem(itemSlot) { - if (specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')]) { - consumeSpecial(itemSlot); - } else { - if (itemSlot.amount === 1) - itemSlot.setItem(void 0); - else - itemSlot.amount--; - } -} - -function consumeSpecial(itemSlot) { - itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')])); -} - -function playSoundEffect(player, block, structureBlock) { - const blockId = structureBlock.type.id.replace('minecraft:', ''); - const blockData = blocks[blockId]; - const blockSound = blockData['sound'] || 'stone'; - player.dimension.playSound('dig.' + blockSound, block.location); } \ No newline at end of file diff --git a/Construct[BP]/scripts/options/fastEasyPlace.js b/Construct[BP]/scripts/options/fastEasyPlace.js index 9b419b4..a9a3392 100644 --- a/Construct[BP]/scripts/options/fastEasyPlace.js +++ b/Construct[BP]/scripts/options/fastEasyPlace.js @@ -1,10 +1,10 @@ import { BuilderOption } from '../classes/Builder/BuilderOption'; import { BlockPermutation, EntityComponentTypes, EquipmentSlot, GameMode, InputMode, ItemStack, system, world } from '@minecraft/server'; -import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, specialItemPlacementConversions, +import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, blockIdToItemStackMap } from '../data'; +import { placeBlock } from '../utils'; import { Raycaster } from '../classes/Raycaster'; import { Builders } from '../classes/Builder/Builders'; -import { blocks } from '../blocks'; const PROCESS_INTERVAL = 2; // Fast Easy Place will attempt to place twice when at an interval of 1. @@ -88,9 +88,9 @@ function isHoldingActionItem(player) { function tryPlaceBlock(player, worldBlock, structureBlock) { if (isBannedBlock(player, structureBlock) || !locationIsPlaceable(worldBlock)) return; structureBlock = tryConvertBannedToValidBlock(structureBlock); - if (player.getGameMode() === GameMode.creative) { + if (player.getGameMode() === GameMode.Creative) { placeBlock(player, worldBlock, structureBlock); - } else if (player.getGameMode() === GameMode.survival) { + } else if (player.getGameMode() === GameMode.Survival) { structureBlock = tryConvertToDefaultState(structureBlock); tryPlaceBlockSurvival(player, worldBlock, structureBlock); } @@ -139,9 +139,8 @@ function tryConvertToDefaultState(structureBlock) { function tryPlaceBlockSurvival(player, block, structureBlock) { const placeableItemStack = getPlaceableItemStack(structureBlock); const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId); - if (itemSlotToUse) { + if (itemSlotToUse) placeBlock(player, block, structureBlock, itemSlotToUse); - } } function getPlaceableItemStack(structureBlock) { @@ -161,35 +160,4 @@ function fetchMatchingItemSlot(player, itemToMatchId) { if (itemSlot.hasItem() && itemSlot?.typeId === itemToMatchId) return itemSlot; } -} - -function placeBlock(player, block, structureBlock, itemSlot) { - system.run(() => { - if (itemSlot) - consumeItem(itemSlot); - block.setPermutation(structureBlock); - playSoundEffect(player, block, structureBlock); - }); -} - -function consumeItem(itemSlot) { - if (specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')]) { - consumeSpecial(itemSlot); - } else { - if (itemSlot.amount === 1) - itemSlot.setItem(void 0); - else - itemSlot.amount--; - } -} - -function consumeSpecial(itemSlot) { - itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')])); -} - -function playSoundEffect(player, block, structureBlock) { - const blockId = structureBlock.type.id.replace('minecraft:', ''); - const blockData = blocks[blockId]; - const blockSound = blockData['sound'] || 'stone'; - player.dimension.playSound('dig.' + blockSound, block.location); } \ No newline at end of file diff --git a/Construct[BP]/scripts/utils.js b/Construct[BP]/scripts/utils.js index 8505af9..c2d767e 100644 --- a/Construct[BP]/scripts/utils.js +++ b/Construct[BP]/scripts/utils.js @@ -1,5 +1,7 @@ import { system, EntityComponentTypes } from '@minecraft/server'; import { FormCancelationReason } from '@minecraft/server-ui'; +import { specialItemPlacementConversions } from './data'; +import { blocks } from './blocks'; export async function forceShow(player, form, timeout = Infinity) { const startTick = system.currentTick; @@ -24,4 +26,36 @@ export function fetchMatchingItemSlot(entity, itemToMatchId) { if (itemSlot.hasItem() && itemSlot?.typeId === itemToMatchId) return itemSlot; } +} + +export function placeBlock(player, placedBlock, blockToPlace, itemSlotToConsume = void 0) { + system.run(() => { + if (itemSlotToConsume) + consumeItem(itemSlotToConsume); + placedBlock.setPermutation(blockToPlace); + playBlockPlacementSound(player, placedBlock, blockToPlace); + }); +} + +function consumeItem(itemSlot) { + if (specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')]) { + itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')])); + } else { + if (itemSlot.amount === 1) + itemSlot.setItem(void 0); + else + itemSlot.amount--; + } +} + +function playBlockPlacementSound(player, block, structureBlock) { + const blockId = structureBlock.type.id.replace('minecraft:', ''); + const blockData = blocks[blockId]; + let blockSound = blockData['sound'] || 'stone'; + if (['glass', 'terracotta'].includes(blockSound)) + blockSound = 'stone'; + let blockSoundId = 'dig.' + blockSound; + if (['iron', 'calcite'].includes(blockSound)) + blockSoundId = 'place.' + blockSound; + player.dimension.playSound(blockSoundId, block.location); } \ No newline at end of file diff --git a/README.md b/README.md index ceb123a..b3b8335 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![GitHub Downloads](https://img.shields.io/github/downloads/ForestOfLight/Construct/total?label=Github%20downloads&logo=github)](https://github.com/ForestOfLight/Construct/releases) [![Curseforge Downloads](https://cf.way2muchnoise.eu/full_1283139_downloads.svg)](https://www.curseforge.com/minecraft-bedrock/addons/construct) -[![Minecraft - Version](https://img.shields.io/badge/Minecraft-v1.21.80_(Bedrock)-brightgreen)](https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs) +[![Minecraft - Version](https://img.shields.io/badge/Minecraft-v1.21.90_(Bedrock)-brightgreen)](https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs) [![Discord](https://badgen.net/discord/members/9KGche8fxm?icon=discord&label=Discord&list=what)](https://discord.gg/9KGche8fxm) @@ -56,7 +56,7 @@ Construct uses Minecraft's vanilla structure system so that you can easily creat Gives you the Construct item. Use it to open the Construct menu. **Usage: `./construct`** -Shows the construct form. Only available while **Canopy** is installed. +Shows the Construct menu. Only available while **Canopy** is installed. ## Join the Community