CraftTweaker

CraftTweaker

151M Downloads

Scripts can't destroy blocks

iridiumlynx opened this issue ยท 3 comments

commented

Issue Description:

There is no destroyBlock method in IWorld.

What happens:

nothing

What you expected to happen:

I expected a way to destroy blocks exist.

Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):

https://pastebin.com/fWf1NZGS

crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):

https://pastebin.com/DQiZKrGD


Affected Versions (Do not use "latest"):

  • Minecraft: 1.12.2
  • Forge: 1.12.2-14.23.5.2768
  • Crafttweaker: 1.12-4.1.14
  • Using a server: no
commented

That is incorrect, you can set the blockstate to minecraft:air:

Example, turns whatever block the player clicks on to air (i.e. "destroys" it)

events.onPlayerInteract(function(event as crafttweaker.event.PlayerInteractEvent){
	if(!event.world.remote) {
	    event.world.setBlockState(<blockstate:minecraft:air>, event.position);
	}
});

Also, could you maybe join the Blamejared discord server for such quetions that can be addressed there easier, and moreover faster ^^

https://discord.blamejared.com

commented

Thanks. I Tried using event.player.world.destroyBlock((<minecraft:stone>.asBlock()).definition.defaultState,targetBlockPos); but this didn't work.

commented

The documentation doesn't contain information on bracket handlers for blockstates.