Bedrock-OSS / bedrock-boost

MIT License
9 stars 3 forks source link

Add support for destroying Blocks #5

Closed theaddonn closed 5 days ago

theaddonn commented 3 weeks ago

There are a lot of ways to break blocks, but the Scripting API doesn't offer any direct way to destroy a block. You surely can just run a command that makes this possible in the API, but adding a Polyfill for this might introduce the needed abstraction.

In my opinion a simple solution would be good enough, such as the following:

let block = world
    .getDimension("minecraft:overworld")
    .getBlock(Vec.from(0, 0, 0))
    .destroy({
        replacement: "air",
        drops: true,
        ...
     })

Would you consider this as useful/does this even make sense or is it just me being lazy and loving pretty abstractions?

stirante commented 3 weeks ago

Adding a new method to an existing type seems pretty annoying so that the autocomplete doesn't complain about it. It could fit into CommandUtils though.

stirante commented 5 days ago

Added in https://github.com/Bedrock-OSS/bedrock-boost/commit/6bd3ee6fe952b4c494a669e14c29527d3630f7a2 Did not add the option to set the old block handling, cause destroy is the only one, that makes sense. keep won't do anything and replace can be done probably faster with setType('minecraft:air').

theaddonn commented 5 days ago

lovely!