functional on 1.21.90

This commit is contained in:
ForestOfLight
2025-06-18 12:03:57 -07:00
Unverified
parent 5c5a4d65fb
commit 59615312c8
7 changed files with 66 additions and 82 deletions
+13 -1
View File
@@ -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"
}
}
}
+1 -1
View File
@@ -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 '';
+6 -36
View File
@@ -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);
}
+5 -37
View File
@@ -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);
}
+34
View File
@@ -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);
}