Setting block at location at BlockPlaceEvent

Discussion in 'Plugin Development' started by yewtree8, Dec 16, 2014.

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

    yewtree8

    So I need a block to be moved from where it was placed, up a block, so like the block starts to hover, how would I go about doing this?

    For example:

    Code:
    CI.Crate;
    Is my block I want to move, and I know it will be returned when you retrieve the placed block, so in the following method:

    Code:
    @EventHandler
    public void onCratePlace(BlockPlaceEvent event){
                    final Player player = event.getPlayer();
    
    }

    How would I move the placed block up by one, or left, or right, or down?

    Thanks in advance

    - Mat :)
     
  2. Offline

    SuperOriginal

  3. Offline

    yewtree8

  4. Offline

    SuperOriginal

    You supply those methods with the x,y, and z values.
    If you want to move it left or right, change the x and z, but leave the y at 0
     
  5. Offline

    yewtree8

    I'm trying

    Code:
    event.getBlockPlaced().getLocation().setY(event.getBlockPlaced().getLocation()+1);
    But it's returning the error

    Code:
    "The operator + is undefined for the argument type(s) Location, double"
    @SuperOriginal
     
  6. Offline

    SuperOriginal

    Did you even read the links I showed you? add and subtract are methods in the Location class.... You don't use operators
     
  7. Offline

    yewtree8

    @SuperOriginal Oh, sorry, didn't realize they were links /: But thankyou for your time anyways.
     
    SuperOriginal likes this.
Thread Status:
Not open for further replies.

Share This Page