Development Assistance Piston moving non-movable blocks

Discussion in 'Plugin Help/Development/Requests' started by Veilbreaker, Jun 4, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Veilbreaker

    I tried to code a small plugin for pistons to move barrier blocks (id 166) based on a theory I had to do it, but it doesn't seem to work. Could someone please point my code in a better direction?

    The barrier block doesn't get pushed by the piston, or even move at all.

    Code:
    public class BarriersCanMove extends JavaPlugin implements Listener{
        public BarriersCanMove (BarriersCanMove plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
      
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onPistonExtend (BlockPistonEvent e) {
            Block block = e.getBlock();
          
            if (block.getTypeId() == 166) {
              
                if (BlockFace.DOWN != null) {
                    Location newBlockLoc = new Location(block.getWorld(), block.getX(), block.getY() - 1, block.getZ());
                    Block barrier = newBlockLoc.getBlock();
                  
                    block.setTypeId(0);
                    barrier.setTypeId(166);
                    e.setCancelled(false);
                }
                else if (BlockFace.UP != null) {
                    Location newBlockLoc = new Location(block.getWorld(), block.getX(), block.getY() + 1, block.getZ());
                    Block barrier = newBlockLoc.getBlock();
                  
                    block.setTypeId(0);
                    barrier.setTypeId(166);
                    e.setCancelled(false);
                }
            }
        }
    }
    Everything in the code is based off https://hub.spigotmc.org/javadocs/bukkit/.
     
    Last edited: Jun 4, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  3. Offline

    Veilbreaker

    It's craftbukkit though. Craftbukkit 1.8.3 compiled from the source
     
  4. Offline

    pie_flavor

    @Veilbreaker CraftBukkit 1.8 doesn't exist. And @timtower doesn't know you replied until you tag him. Any 1.8 is Spigot or some other non-bukkit system. It's not Craftbukkit unless you download it either from dl.bukkit.org or savebukkit.org
    Also, BlockFace.DOWN and BlockFace.UP are constants. They will never be null, ever. I think what you are looking for is
    Code:
    if (((PistonBaseMaterial) e.getBlock().getData()).getFacing().equals(BlockFace.UP)) {
     
    timtower likes this.
  5. Offline

    Veilbreaker

    Thank @pie_flavor but it is craftbukkit regardless that it's on spigots site, as they describe in this forum http://www.spigotmc.org/threads/bukkit-craftbukkit-spigot-1-8.36598/ if you would actually read about it. That and hence it being in the url "bukkit-craftbukkit".

    Also @pie_flavor , that didn't seem to work either, PistonBaseMaterial can't be resolved to type, so I tried changing it to Material.PISTON_BASE, but that can't be resolved to type either. Any other suggestions, please?
     
    Last edited by a moderator: Jun 5, 2015
  6. Offline

    pie_flavor

    @timtower please respond to this post. he is unconvinced by plebeian
     
  7. Offline

    timtower Administrator Administrator Moderator

    @Veilbreaker Then can call it craftbukkit but it isn't made by the bukkit team so an alternative.
     
Thread Status:
Not open for further replies.

Share This Page