functional on 1.21.90
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"header": {
|
"header": {
|
||||||
"name": "Construct [BP] v1.0.0",
|
"name": "Construct [BP] v1.0.1",
|
||||||
"description": "Survival building addon by §aForestOfLight§r.",
|
"description": "Survival building addon by §aForestOfLight§r.",
|
||||||
"uuid": "8c0c0153-d8b9-482a-889f-aef922b8fe58",
|
"uuid": "8c0c0153-d8b9-482a-889f-aef922b8fe58",
|
||||||
"min_engine_version": [1, 21, 80],
|
"min_engine_version": [1, 21, 90],
|
||||||
"version": [1, 0, 0]
|
"version": [1, 0, 1]
|
||||||
},
|
},
|
||||||
"modules": [
|
"modules": [
|
||||||
{
|
{
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"module_name": "@minecraft/server",
|
"module_name": "@minecraft/server",
|
||||||
"version": "2.0.0-beta"
|
"version": "2.1.0-beta"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"module_name": "@minecraft/server-ui",
|
"module_name": "@minecraft/server-ui",
|
||||||
"version": "2.0.0-beta"
|
"version": "2.1.0-beta"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "375ec465-3dc1-429f-8b4c-a337889e1ed4", // Construct RP
|
"uuid": "375ec465-3dc1-429f-8b4c-a337889e1ed4", // Construct RP
|
||||||
|
|||||||
@@ -2098,6 +2098,18 @@ export const blocks = {
|
|||||||
"sound" : "stone",
|
"sound" : "stone",
|
||||||
"textures" : "skull"
|
"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" : {
|
"dried_kelp_block" : {
|
||||||
"carried_textures" : {
|
"carried_textures" : {
|
||||||
"down" : "dried_kelp_block_top",
|
"down" : "dried_kelp_block_top",
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class BlockInfo {
|
|||||||
|
|
||||||
static getSupplyMessage(player, block) {
|
static getSupplyMessage(player, block) {
|
||||||
const itemStack = fetchMatchingItemSlot(player, block.getItemStack()?.typeId);
|
const itemStack = fetchMatchingItemSlot(player, block.getItemStack()?.typeId);
|
||||||
const isInSurvival = player.getGameMode() === GameMode.survival;
|
const isInSurvival = player.getGameMode() === GameMode.Survival;
|
||||||
if (!itemStack && isInSurvival)
|
if (!itemStack && isInSurvival)
|
||||||
return ' §c[No Supply]';
|
return ' §c[No Supply]';
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
||||||
import { BlockPermutation, EntityComponentTypes, EquipmentSlot, GameMode, ItemStack, system, world } from '@minecraft/server';
|
import { BlockPermutation, EntityComponentTypes, EquipmentSlot, GameMode, ItemStack, system, world } from '@minecraft/server';
|
||||||
import { structureCollection } from '../classes/Structure/StructureCollection';
|
import { structureCollection } from '../classes/Structure/StructureCollection';
|
||||||
import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks, specialItemPlacementConversions,
|
import { bannedBlocks, bannedToValidBlockMap, whitelistedBlockStates, resetToBlockStates, bannedDimensionBlocks,
|
||||||
blockIdToItemStackMap } from '../data';
|
blockIdToItemStackMap } from '../data';
|
||||||
import { fetchMatchingItemSlot } from '../utils';
|
import { fetchMatchingItemSlot, placeBlock } from '../utils';
|
||||||
import { Builders } from '../classes/Builder/Builders';
|
import { Builders } from '../classes/Builder/Builders';
|
||||||
|
|
||||||
const builderOption = new BuilderOption({
|
const builderOption = new BuilderOption({
|
||||||
@@ -66,9 +66,10 @@ function tryPlaceBlock(event, player, block, structureBlock) {
|
|||||||
if (shouldPreventAction(player, structureBlock))
|
if (shouldPreventAction(player, structureBlock))
|
||||||
return preventAction(event, player);
|
return preventAction(event, player);
|
||||||
structureBlock = tryConvertBannedToValidBlock(structureBlock);
|
structureBlock = tryConvertBannedToValidBlock(structureBlock);
|
||||||
if (player.getGameMode() === GameMode.creative) {
|
if (player.getGameMode() === GameMode.Creative) {
|
||||||
placeBlock(block, structureBlock);
|
event.cancel = true;
|
||||||
} else if (player.getGameMode() === GameMode.survival) {
|
placeBlock(player, block, structureBlock);
|
||||||
|
} else if (player.getGameMode() === GameMode.Survival) {
|
||||||
structureBlock = tryConvertToDefaultState(structureBlock);
|
structureBlock = tryConvertToDefaultState(structureBlock);
|
||||||
tryPlaceBlockSurvival(event, player, block, structureBlock);
|
tryPlaceBlockSurvival(event, player, block, structureBlock);
|
||||||
}
|
}
|
||||||
@@ -135,34 +136,3 @@ function getPlaceableItemStack(structureBlock) {
|
|||||||
const newItemId = blockIdToItemStackMap[blockId];
|
const newItemId = blockIdToItemStackMap[blockId];
|
||||||
return newItemId ? new ItemStack(newItemId) : structureBlock.getItemStack();
|
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);
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
import { BuilderOption } from '../classes/Builder/BuilderOption';
|
||||||
import { BlockPermutation, EntityComponentTypes, EquipmentSlot, GameMode, InputMode, ItemStack, system, world } from '@minecraft/server';
|
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';
|
blockIdToItemStackMap } from '../data';
|
||||||
|
import { placeBlock } from '../utils';
|
||||||
import { Raycaster } from '../classes/Raycaster';
|
import { Raycaster } from '../classes/Raycaster';
|
||||||
import { Builders } from '../classes/Builder/Builders';
|
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.
|
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) {
|
function tryPlaceBlock(player, worldBlock, structureBlock) {
|
||||||
if (isBannedBlock(player, structureBlock) || !locationIsPlaceable(worldBlock)) return;
|
if (isBannedBlock(player, structureBlock) || !locationIsPlaceable(worldBlock)) return;
|
||||||
structureBlock = tryConvertBannedToValidBlock(structureBlock);
|
structureBlock = tryConvertBannedToValidBlock(structureBlock);
|
||||||
if (player.getGameMode() === GameMode.creative) {
|
if (player.getGameMode() === GameMode.Creative) {
|
||||||
placeBlock(player, worldBlock, structureBlock);
|
placeBlock(player, worldBlock, structureBlock);
|
||||||
} else if (player.getGameMode() === GameMode.survival) {
|
} else if (player.getGameMode() === GameMode.Survival) {
|
||||||
structureBlock = tryConvertToDefaultState(structureBlock);
|
structureBlock = tryConvertToDefaultState(structureBlock);
|
||||||
tryPlaceBlockSurvival(player, worldBlock, structureBlock);
|
tryPlaceBlockSurvival(player, worldBlock, structureBlock);
|
||||||
}
|
}
|
||||||
@@ -139,10 +139,9 @@ function tryConvertToDefaultState(structureBlock) {
|
|||||||
function tryPlaceBlockSurvival(player, block, structureBlock) {
|
function tryPlaceBlockSurvival(player, block, structureBlock) {
|
||||||
const placeableItemStack = getPlaceableItemStack(structureBlock);
|
const placeableItemStack = getPlaceableItemStack(structureBlock);
|
||||||
const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId);
|
const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId);
|
||||||
if (itemSlotToUse) {
|
if (itemSlotToUse)
|
||||||
placeBlock(player, block, structureBlock, itemSlotToUse);
|
placeBlock(player, block, structureBlock, itemSlotToUse);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function getPlaceableItemStack(structureBlock) {
|
function getPlaceableItemStack(structureBlock) {
|
||||||
const blockId = structureBlock.type.id.replace('minecraft:', '');
|
const blockId = structureBlock.type.id.replace('minecraft:', '');
|
||||||
@@ -162,34 +161,3 @@ function fetchMatchingItemSlot(player, itemToMatchId) {
|
|||||||
return itemSlot;
|
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);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import { system, EntityComponentTypes } from '@minecraft/server';
|
import { system, EntityComponentTypes } from '@minecraft/server';
|
||||||
import { FormCancelationReason } from '@minecraft/server-ui';
|
import { FormCancelationReason } from '@minecraft/server-ui';
|
||||||
|
import { specialItemPlacementConversions } from './data';
|
||||||
|
import { blocks } from './blocks';
|
||||||
|
|
||||||
export async function forceShow(player, form, timeout = Infinity) {
|
export async function forceShow(player, form, timeout = Infinity) {
|
||||||
const startTick = system.currentTick;
|
const startTick = system.currentTick;
|
||||||
@@ -25,3 +27,35 @@ export function fetchMatchingItemSlot(entity, itemToMatchId) {
|
|||||||
return itemSlot;
|
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);
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
[](https://github.com/ForestOfLight/Construct/releases)
|
[](https://github.com/ForestOfLight/Construct/releases)
|
||||||
[](https://www.curseforge.com/minecraft-bedrock/addons/construct)
|
[](https://www.curseforge.com/minecraft-bedrock/addons/construct)
|
||||||
[-brightgreen)](https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs)
|
[-brightgreen)](https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs)
|
||||||
[](https://discord.gg/9KGche8fxm)
|
[](https://discord.gg/9KGche8fxm)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -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.
|
Gives you the Construct item. Use it to open the Construct menu.
|
||||||
|
|
||||||
**Usage: `./construct`**
|
**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
|
## Join the Community
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user