#destroyBlock prototype
1 messages · Page 1 of 1 (latest)
so this works on dimensions right? so it can be used like block.dimension.destroyBlock({})
?
its working fine but its gives error Failed to spawn item entity
btw i used that will playerInterarctWithBlockAfterEvent maybe its because afterEvent
problem with the code is that the nbt data of the block will not be transferred to newly-created ItemStack
haven't think of a way yet
alr
you can do block.getItemStack(1, true) instead
create the itemstack before modifying the block
create a new variable that is like you mentioned
then pass the new variable to the first arg of spawnItem function
replacing the new ItemStack thing
im sorry but you are doing things wrong
import { world, system, BlockPermutation, ItemStack, Dimension } from "@minecraft/server";
/**
* Destroys a block at the entered location.
* @param {Object} location - Location of the block to be destroyed.
* @param {number} location.x - The x coordinate of the block.
* @param {number} location.y - The y coordinate of the block.
* @param {number} location.z - The z coordinate of the block.
*/
Dimension.prototype.destroyBlock = function(location) {
const block = this.getBlock(location);
if (block.typeId === "minecraft:air") {
return;
}
const block_item = block.getItemStack(1, true)
const perm = BlockPermutation.resolve("minecraft:air");
block.setPermutation(perm);
this.spawnItem(block_item, location);
};
this should fix it
i mean yeah
pls make post only when u are finally done, dont use this as chat
edited org message?
player.runCommand(