[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


    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


    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


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

    public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
        if (event.getVehicle().getPassenger() instanceof Player & event.getVehicle() instanceof Minecart) {
    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


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


    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


    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


    HappyPikachu you can untrack the entity, move it past the obstacle, and track it again. Use the EntityTracker.
    ((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


    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


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


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

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


    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


    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


    Thanks, I'll give it a shot!

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


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


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


    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


Thread Status:
Not open for further replies.

Share This Page