[UNSOLVED] Oh dear, a g-g-ghost!!

Discussion in 'Plugin Development' started by HappyPikachu, Jan 28, 2012.

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

    HappyPikachu

    Hi, I've developed and published a plugin called SimpleCarts.

    I'd like to implement the ability for a player-filled Minecart to pass through an entity without having to remove it or push it aside... sort of like a ghost. Is this even remotely possible?
     
  2. Offline

    Aetherspawn

    Cancel the event when it collides with a player. I don't know the event (Vehicle physics event?) but its probably not hard to find.
     
  3. Offline

    HappyPikachu

    There isn't any vehicle physics event, as far as I know. I just tried the following to no avail:

    Code:
    @EventHandler
    public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
        if (event.getVehicle().getPassenger() instanceof Player & event.getVehicle() instanceof Minecart) {
              event.setCollisionCancelled(true);
        }
    }
    Yes, the event handler is set up properly. I tried the common event.setCancelled(true) as well.

    Any other ideas?
     
  4. Offline

    Sir Savary

    Remove the entity than replace it where it was. If it's a player, teleport them away then back perhaps.
     
  5. Offline

    hammale

    Maybe if u just make the velocity like 1 million it will just glitch thru them!
     
    Chipmunk9998 and Stone_Tigris like this.
  6. Offline

    bergerkiller

    HappyPikachu welcome in my world where there is no event to stop the collision :)

    Collisions also take place in the move function of the native entity, and no event that cancels it there. I had to copy and paste the function to insert the collision exemption manually.

    TrainCarts: NativeMinecartMember: move function
     
  7. Offline

    HappyPikachu

    That's pretty much what I've been doing, minus replacing the entity. Mobs and animals get downright removed and players get kicked when enabled in the config.

    ...lol. I'd rather not do that.

    Rofl, so this takes control of entities before they can collide? That's really useful - I wasn't thinking outside of ignoring the collision altogether. Any ideas on how to pass through the entity after (not) colliding with it?

    One thought that occurred to me is that I could perhaps remove the entity, send a packet to the client showing a fake of that entity, and then after moving away, place the actual entity back. Ofc, that isn't really passing through it, and it wouldn't work for players. :(
     
  8. Offline

    bergerkiller

    HappyPikachu you can untrack the entity, move it past the obstacle, and track it again. Use the EntityTracker.
    Code:
    ((WorldServer) world).tracker.untrackEntity(entity);
    But if you go this road, it will be very hard to get right. Maybe someone needs to make a pull request to craftbukkit to include entity collisions in the entity move function. Problem is that the move function uses bounding boxes when colliding, and no real entity is used. This makes an entity event very hard to do.

    (I solved it by obtaining the entity from the bounding box, but doing that for every entity makes the server tick rate suffer)
     
    HappyPikachu likes this.
  9. Offline

    HappyPikachu

    bergerkiller I can see how that'd be difficult, but I'm willing to give it a shot. How would I cast the vehicle?
     
  10. Offline

    bergerkiller

    HappyPikachu use this to get the native entity:
     
  11. Offline

    HappyPikachu

    Whoops. I was trying to untrack the vehicle, not the entity. I fail.

    I'll mess around with this and post results.
     
  12. Offline

    HappyPikachu

    bergerkiller your suggestion is the best so far, allowing the cart to pass through an entity by untracking it. Still, I'm hoping to find a solution that keeps the entity visible to the player. I'll certainly settle for this if I nothing else comes up, but the quest continues!

    Looking for ideas on how to make this happen. Anyone?
     
  13. Offline

    hammale

    well you could play with the packets to temporarly make the player invisible...thats what i do in Spyer2 using the spout packet handler...i think it should let the cart pass thru the player...though, ive never tested it. u can check my github for da code :D
     
  14. Offline

    HappyPikachu

    Thanks, I'll give it a shot!

    EDIT: Still taking ideas on how to achieve this without Spout.
     
  15. Offline

    hammale

    well anything spout does you can do w/ out it but it just requires a bit of work :D
     
  16. Offline

    slayr288

    hammale
    Not true. Spout includes a client, allowing client-side modifications.
     
  17. Offline

    yawkat

    You could try removing the hitbox of the minecart. I had the same problem with arrows and "spectating" players that could block them and solved it by setting the hitbox of spectating players to an empty one (null might work too, not sure).
     
  18. Offline

    LucasEmanuel

Thread Status:
Not open for further replies.

Share This Page