Collide-Event?

Discussion in 'Plugin Development' started by Uniclaw, Oct 19, 2012.

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

    Uniclaw

    Hi!

    anyone has a Idea how i can check a Collide Event? MoveEvent is not that what i need, example: if i have a block that the player can walk trough, and i cancel the move event - the player "freeze" - But i would set blocks that a player can walk trough to blocks where the player can not walk trough...

    greet

    Anyone :( ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  2. Offline

    Uniclaw

    Anyone has a Idea :( ?
     
  3. Offline

    Courier

    You can't (nicely) make the player move through a solid block. Movement is first calculated client side, and the client won't try to move through a solid block.
     
  4. Offline

    Uniclaw

    No, inversed ;) i would make that the player can't move trough unsolid[/] blocks ;) example: i construct a bridge with unsolig blocks, and if the player walk on the bridge, he can walk like if it is a woddenplank :)
     
  5. Offline

    gamerguy14

    Try this maybe:

    Code:
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        if (event.getTo().getBlock().getType().equals(Material.Water) {//Could be any block
            event.setCancelled(true);
        }
    }
    If that doesn't work then maybe this will:
    Code:
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        if (event.getTo().getBlock().getType().equals(Material.Water) {//Could be any block
            event.setTo(new Location(event.getTo().getX(), event.getFrom().getY(), event.getTo().getX());
        }
    }
    This will only work when travelling in a straight line though. Maybe taking the largest y would work best.
     
  6. Offline

    Courier

    You can't do that nicely either. The client will think the player is falling, so it will not let them move forward very fast, and the player will constantly be falling and popping back up (like when there is a chunk error).
     
  7. Offline

    Hoolean

    You can sort of walk through solid blocks with the Player.sendBlockChange() method, although it is not ideal but is very efficient!

    As for making non-solid blocks solid, this can also sort-of be done with fake packets like above.
     
  8. Offline

    nathanaelps

    Are there any technical blocks which are invisible but solid? Kind of like Block 36, except that Block 36 isn't solid. Maybe SethBling used something like this in a recent spawner experiment, creating a bridge that extended as the player walked down it?
    Or you could tinker with the server-side texture pack, and (as long as somebody accepted it) you could re-texture another block to be invisible...
     
Thread Status:
Not open for further replies.

Share This Page