Minecarts Kills when they run over mobs or player

Discussion in 'Archived: Plugin Requests' started by Sandia, Mar 10, 2012.

  1. Offline

    Sandia

    Plugin category: mech

    Suggested name: Don't stand on the rails

    A bit about me: I holding a server upp and the bigest problem I have is that i can't dev plugins for my own server :p

    What I want: I'd like to have a plugin that kills all the mobs and the player that stand in the way and the minecart will keep going ​
    Ideas for commands: Mabey turn on and off

    Ideas for permissions: I don't know
    It should be compatible with pex

    When I'd like it by: I have a long time before i got the rail done.​

    Similar plugin requests: None.

    Devs who might be interested in this: I don't know​
     
  2. Offline

    Iron_Crystal

    I could do this. May take me a few days as I don't have a lot of time to code.
     
  3. Offline

    Sandia

    Thx for the fast answare I can w8 It's not so importent just now I need it when I am done with my bridge on 30k blocks long :p have 13k left
     
  4. Offline

    Royalgamer06

    lol, like it
     
  5. Offline

    TopGear93

    this isnt as easy as you think. This require alot of velocity math and figuring each and every direction of the cart. I know this for a fact becuase ive been trying to make a plugin like this. I would recommend you ask a highly experienced developer to make this.
     
  6. Offline

    Iron_Crystal

    Why is it so hard? You just use the VehicleEntityCollisionEvent?
     
  7. I'll give it a look
     
  8. Offline

    Scyntrus

    I'm pretty sure that this event will be called even when both a cart pushes a player and a player pushes a cart. If a player pushes a cart, he obviously shouldn't die. This is why you have to use vectors to make sure the cart is moving in the direction of the player, and possibly going fast enough.
     
  9. Offline

    Iron_Crystal

    I haven't worked on it since yesterday, but it did not seem like it was calling the event until a player was already in the cart. I'll have to do some more testing, but it looked like it was only being called when one was in the cart.

    Edit: It is definitely not calling the event when the player pushes the cart. I believe it requires a passenger to be in the cart. The only thing you have to be careful about is when an animal is in the cart...:D
     
  10. Offline

    Scyntrus

    Guess you're gonna just have to use VehicleMoveEvent and use getNearbyEntities. Sucks tho..
     
  11. Offline

    Iron_Crystal

    No. What I meant was that VehicleEntityCollisionEvent is what I want. All I have to do is get the entity that it collided with (event.getEntity) and kill it. I am also planning on sending the passenger a message if they run over something/someone.
     
  12. Offline

    TopGear93

    yea it detects the collision but if you dont set the cart to stay continuous it just goes the opposite way after impact.
     
  13. Offline

    Iron_Crystal

    That's true. I will need to fix that.
     
  14. Offline

    Codex Arcanum

    Seems to me you would need to:
    1. Is the vehicle a minecart?
    2. Is the minecart moving fast enough?
    3. If the entity is not a living entity then apply the minecart vector to it or destroy or something.
    4. If the entity is a living entity then get the entity's health.
    5. Do X damage to the entity.
    6. Is the entity dead now?
    7. If it is not, do nothing, if it is, then multiply the velocity vector by -1 to prevent the cart from reversing directions. You could also cancel the collision event if you wanted to.
     
  15. Offline

    Iron_Crystal

    1. Done
    2. It seems like the person wanted the minecart to kill them any time, not just at top speed
    3. Done
    4. Figuring out
    5. Seemed like they wanted it to kill them, not hurt them
    6. N/A
    7. N/A
     
  16. Offline

    LycaonX

    Just wanted to post to say thumbs up. I hate people that stand on minecart tracks. Some people might think this is mean, but, you know, Darwinism is a great teaching method ;D
     
  17. Offline

    Sandia

    Yea i want so it kill's on any speed
     
  18. Offline

    Iron_Crystal

    Just as an update, the plugin is almost done.

    Done:

    Carts run over mobs and players, and kill them.
    Carts continue in the direction they are going.

    Not Done:

    Command

    Bugs:

    When a cart is going at a 45 degree angle downwards, the cart will reverse the direction upon collision. Otherwise the cart continues forward.

    The items on the track are not getting removed. This is actually not my fault, as it is a bug with Bukkit, so I can't do anything about this.

    Do you want me to upload the plugin now, and I'll update it as I fix things?

    Note: I think this is a fun plugin because I feel like a bowling ball knocking over mobs =)
     
  19. Offline

    Sandia

    Yea you can uppload it if you wan't
     
  20. Offline

    Iron_Crystal

  21. Offline

    Sandia

    Thx alot it working very good

    When i goin the direction f:1 the minecart turn around but at the dirretion f: 3 it working

    it's kill the mob but the cart change diretion

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

    Iron_Crystal

    I don't understand. What direction are you going in? I said it still turns around when going down hill. Other than that it seemed to work.
     
  23. Offline

    Father Of Time

    I don't understand why this is so complicated, shouldn't you be able to identify the mob, see if its a living entity, and if the Entity inside the cart is an instance of player do:

    1) Kill the entity that triggered the VehicleEntityCollisionEvent
    2) cancel the VehicleEntityCollisionEvent.

    The collision occurs, you take special action (killing what you ran over) then just cancel the event so it was as if it never collided with anything (hence, keeps traveling happy along it's way).

    Sometimes things sound more simplified then they are, but all the talk of velocity comparisons seems entirely overkill for something this simple.

    Has someone tried something this simple to see if it works?
     
  24. Offline

    Sandia

    if you click on F3 in minecraft you will se there it will stand a F:1-4 and if you did turn around the diretion f:1

    The number is like
    • 0 = South
    • 1 = West
    • 2 = North
    • 3 = East
     
  25. Offline

    Iron_Crystal

    I tried that, but sometimes the minecart still stops. I don't know why, but I figured a way to do it.

    Sandia

    Are you saying that when its going South the minecarts turn around?

    Edit: I found the problem. I told it to teleport the entity 2 blocks in a direction. (x-2 or something). What happens is the entity is getting pushed forward, but it is getting pushed in the way of the cart, so its the item which is stopping the cart, not the entity. Thats why its stopping and not reversing directions. I will either put a check so that it always teleports the mob to the side of the tracks, or wait until they fix the problem with the VehicleEntityCollisionEvent not firing when it runs into items.
     
  26. Offline

    Sandia

    No when it going east it turn around when it hit a mob
     
  27. Offline

    Father Of Time

    Hmm, even though the entity is "dead" it still takes it a few seconds to fall over then disapear, maybe that small window from when it's killed to when it's deleted creates a small window where the cart can still impact the falling corpse.

    Just for experimentation sake, have you thought of knocking back the mob in the direction the cart is traveling right before killing it, then canceling the event? So its as if the cart nailed the mob, sent it flying, and while in mid air it dies...

    If you ask me this is worth trying because:
    1) it drastically simplifies things
    2) it would add an "impact" effect, sending the mob flying (which is funny)
    3) it moves the mob entity out of the way of the cart before the cart attempts to move, so even if it's not fully dead it won't block/reflect the cart.

    Again, I am completely speculating, but what I have suggested would take only seconds to implement, and if it works would make life a great deal easier...

    Just food for thought, good luck with what ever path you take!
     
  28. Offline

    Sandia

    sorry it was f:1 west i mean. I did say f:3
     
  29. Offline

    Iron_Crystal

    I actually did what you suggested, but I cancelled the event before hitting the mob, so that may be the problem.
     
  30. Offline

    Father Of Time

    This sounds like a paradox...

    Can you explain this better, because from my perspective this is a logical impossibility. The event is triggered by hitting the mob, so you can't cancel it before hitting the mob because you must first hit the mob for the event to ever be trigger to be canceled.

    1) collide event
    2) get hit mob
    3) get direction cart facing
    4) apply velocity to hit mob
    5) kill hit mob
    6) cancel event

    are you doing it in this order, if so I don't see how what you are saying above can be true?

    hmm, after thought... This all occurs in one tick, so I think what you need to do is put a timer between when you apply the velocity and when you kill it. Apply the velocity, start a 1 second timer, and at the end of that timer kill the creature. Doing it this way will give it plenty of time to acelerate from the cart impact and move out of the way, then die... I think the way we had it before it just died the exact same second we applied the velocity, aka falling right where it stood anyways.

    Just some ideas to try, good luck!
     

Share This Page