Material code

Discussion in 'Plugin Development' started by ciarian, Nov 5, 2011.

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

    ciarian

    i am trying to make a simple plugin that can make 3 block wide paths when you toggle it
    i have created the playerlistener and have entered this code.
    Code:
    package me.ciarian.plugins.pathmaker;
    
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.block.BlockFace;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerMoveEvent;
    
    /**
     *
     * @author ipad
     */
    public class PathmakerPlayerlistener extends PlayerListener{
    @Override
        public void onPlayerMove(PlayerMoveEvent event) {
              Player player = event.getPlayer();
              Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
    
              block.setType(Material.);
              

    my problem is i cant fighure ou how could i get it to place one block underneather u and 2 either side ??
     
  2. Offline

    Jogy34

    Code:
    Block pathBlocks;
    pathBlocks = world.getBlockAt(X, Y, Z);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X, Y, Z + 1);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X, Y, Z  - 1);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X + 1, Y, Z);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X - 1, Y, Z);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X + 1, Y, Z + 1);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X + 1, Y, Z - 1);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X - 1, Y, Z + 1);
    pathBlocks.setTypeId(1);
    pathBlocks = world.getBlockAt(X - 1, Y, Z - 1);
    pathBlocks.setTypeId(1);
    
    That should make a square around you of stone with the player in the center
     
  3. Offline

    Fallen_Advent

    @Jogy34 Could you use this in a command, like in this way

    Code:JAVA
    1.  
    2. pathBlocks = world.getBlockAt(X, Y, Z);
    3. pathBlocks.setTypeId([1]);
    4.  


    Where, [1] is the arguement like

    /<command> <material type>
     
  4. Offline

    Jogy34

    ya I was just giving an example with stone
     
  5. Offline

    Fallen_Advent

    @Jogy34 Cool this helps me out alot as well, Thank you for letting me know
     
  6. Offline

    Jogy34

Thread Status:
Not open for further replies.

Share This Page