BlockPistonRetractEvent keep redstone on back, pops off on sticky but not regular piston

Discussion in 'Spigot Help' started by Fahlur, Jul 14, 2018.

  1. Basically in BlockPistonRetractEvent, when the piston is facing down I dont want it to break the redstone on retract. It works fine with a regular piston but when I do a sticky piston its like it cokmpletely ignores the fact and breaks the item anyways.

    any ideas?

    I have tried blockbreakevent but it doesn't work for this. I have checked with just the event to say hello world in a broadcast if the event fires and it doesn't when the redstone component or otherwise just pops off the piston during retraction.

    What im explaining:

    Code (Text):
    public Material[] apBlocks = new Material[] {

    public void pistonRetract(BlockPistonRetractEvent e) {
    Block block = e.getBlock();

     Location loc = block.getLocation().add(0, 1, 0);

     if (Arrays.asList(apBlocks).contains(loc.getBlock().getState().getType())) {

      Material bType = loc.getBlock().getType();
      byte bData = loc.getBlock().getData();


      Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
       public void run() {

        Block d = loc.getBlock();


      }, 3L);
    #1 Fahlur, Jul 14, 2018
    Last edited: Jul 16, 2018
  2. Rather than using that event, how about BlockBreakEvent:

    Code (Java):

    private void onLeverBreak(BlockBreakEvent event)
        if(event.getBlock() != null)
            if(event.getBlock().getType() == Material.LEVER)
                Location check_location = event.getBlock().getLocation().subtract(0, 1, 0);
                Block under = check_location.getBlock();
                if(under != null)
                    if(under.getType() == Material.PISTON_STICKY_BASE)
  3. I attempted block break event originally. It didnt even register the fact the items were broken because of the piston retract. It didnt fire.

    just encase I attempted the example and that didnt fire either. Whilst my other one worked fine. with exception to the sticky piston.

    edit 2:
    I guess I would have to presume that the blockbreak event should be registering that, which in fact make it a bug that it doesnt? Since it does not. I even ran the event to just tell me hello world if a block was broken and it detected when I broke by hand. but when it pops off the piston it doesnt.
    #3 Fahlur, Jul 15, 2018
    Last edited: Jul 16, 2018
  4. hm any ideas?
  5. Make a scheduler and after let's say 10 ticks, spawn the lever back.
  6. didnt seem to work. also doesnt matter on levers much anymore unless I do some sort of trickery to allow them on pistons in 1.13 (that ability to put buttons and levers on pistons is gone in 1.13) plates and other redstone seems fine.

    edit: heh seems in 1.13 pre7 the regular piston no longer fires the BlockPistonRetractEvent. But sticky does.
    edit-2: and lovely, they dont register any block thats basically rails, redstone, etc they register them as air. tried multiple different things. worked fine in 1.12.2.. uhg
    #6 Fahlur, Jul 18, 2018
    Last edited: Jul 19, 2018

Share This Page