Hello there,
how can i either create a explosion on a certain location or make a TNT Block instantly explodes?
I tried with Manipulators but i didnt find anything useful.
If you want to use TNT, you would have to set the fuse on the entity rather than the block (not sure how)
Don’t make a tnt block, make a tnt entity. The API is rather lacking when it comes to explosions at the moment, there’s several events that need fleshing out yet as well.
It should be possible to create a primed TNT entity and detonate it immediately, example:
Optional<Entity> optional = world.createEntity(EntityTypes.PRIMED_TNT, position);
if (optional.isPresent()) {
PrimedTNT tnt = (PrimedTNT) optional.get();
if (world.spawnEntity(tnt)) {
tnt.detonate();
}
}
cool thanks i will give it a try
but what should replace world. ?
position is the location where it needs to be spawned right ?!
I assume you have a Location
object.
World world = (World) location.getExtent();
Vector3d position = location.getPosition();
World world = (World) location.getExtent();
Vector3d position = location.getPosition();
Optional optional = world.createEntity(EntityTypes.PRIMED_TNT, position);
if (optional.isPresent()) {
PrimedTNT tnt = (PrimedTNT) optional.get();
if (world.spawnEntity(tnt)) {
tnt.detonate();
}
}
I did this but on
world.createEntity(EntityTypes.PRIMED_TNT, position);
it says: The type com.google.common.base.Optional cannot be resolved. It is indirectly referenced from required .class files.
Can i still build or will it not work ?
By the way same happens here:
@Subscribe
public void onInit(InitializationEvent event){
CommandSpec testCmd = CommandSpec.builder()
.description(Texts.of(“This is a Test Command”))
.executor(new Test())
.build();
game.getCommandDispatcher().register(this, testCmd, “test”);
}
on the game.get… line.
You haven’t setup your workspace correctly (you’re missing required dependencies)
See the documentation https://docs.spongepowered.org/en/plugin/basics/workspace/index.html