Search code examples
javaminecraftbukkit

Emit redstone signal to a block Bukkit 1.12.2


First of all, this is the first time I create a Bukkit plugin.

Basically, when someone does a certain action with a block and checks certain conditions, I would like it to emit a redstone signal (the block). The code is executed in the Bukkit PlayerInteractEvent. Except that after a lot of research, I still haven't found a single (working) solution, neither on the forums, nor in the documentation.

I don't know how to tell Minecraft that this block can emit redstone (if it needs it). If I don't say anything stupid, it was created with a dynamX pack (the mod that contains the block).

I already looked at this solution: Bukkit: Set a block powered, but it doesn't match my expectations and doesn't work.

So I was wondering if it was possible to emit a redstone signal on a specific block with Bukkit 1.12.2, or at a specific coordinate. This would solve all the problems related to this.

I thank you in advance.


Solution

  • Currently, it seems that it is not possible for bukkit to set a block as a redstone source. However, you can trick the game by temporary replacing the block by a redstone emitter :

    1. The PlayerInteractEvent is emitted, and the conditions you specified are checked.
    2. You temporary replace the block that you clicked for 2 ticks by a redstone block
    3. After those 2 ticks, you replace the redstone block by the original block

    This solution might not work for you, but it is the best that i could find.