[SPIGOT-5793] Minecart.setDamage() not working Created: 20/Jun/20  Updated: 23/Jun/20

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: djytw Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File minecart_test.jar    
Version: git-Spigot-a99063f-8ea9b13 (MC: 1.15.2)
Guidelines Read: Yes

 Description   

Calling Minecart.setDamage(40.0) doesn't kill the minecart as it said in javadoc.

(Also tried numbers over 40, not work either.)

Instead, the minecart's damage value is set to 40, which means after calling this, if you attack the minecart immediately, it can be killed with only one attack by hand.

 code used:
public void on(VehicleCreateEvent event) {
  if (event.getVehicle() instanceof Minecart) {
    System.out.println("minecart!");
   ((Minecart)event.getVehicle()).setDamage(40.0); // also tried 41.0
 }
}



 Comments   
Comment by djytw [ 23/Jun/20 ]

No, that's just for test.

Minecart has it's own EntityMinecartAbstract#damageEntity() in NMS, maybe we can have another method damage() like Damageable, or just add some check and kill the minecart when setDamage over 40?

Comment by Anmol Brar [ 23/Jun/20 ]

Are you attempting to stop the mine cart from spawning?

Comment by djytw [ 21/Jun/20 ]

minecart_test.jar

the plugin I used to test

Comment by djytw [ 21/Jun/20 ]

Thanks for your help!

But still not working. I called setDamage(100.0) in the tick after creation and it doesn't kill it.

After 20 ticks, getDamage() of this minecart has a result of 81.0, which seems right but the minecart is still there. 

Also tried setDamage after 20 ticks or so, still the same.

Comment by Black Hole [ 21/Jun/20 ]

Please try to schedule the damage in the tick after the vehicle was created.

Generated at Tue Dec 16 23:42:02 UTC 2025 using Jira 10.3.15#10030015-sha1:909cc43d292ca09e774c1a243d9819be3f2628cd.