@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
||||
@@ -50,6 +50,16 @@
|
||||
@@ -48,6 +48,14 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -8,16 +8,14 @@
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.entity.Vehicle;
|
||||
+import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||
+import org.bukkit.util.Vector;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityMinecartAbstract extends Entity {
|
||||
public abstract class EntityMinecartAbstract extends VehicleEntity {
|
||||
|
||||
private static final float LOWERED_PASSENGER_ATTACHMENT_Y = 0.0F;
|
||||
@@ -93,6 +103,17 @@
|
||||
@@ -88,6 +96,17 @@
|
||||
enummap.put(BlockPropertyTrackPosition.NORTH_EAST, Pair.of(baseblockposition2, baseblockposition1));
|
||||
});
|
||||
|
||||
@@ -35,43 +33,16 @@
|
||||
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.targetDeltaMovement = Vec3D.ZERO;
|
||||
@@ -222,6 +243,19 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start - fire VehicleDamageEvent
|
||||
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
+ org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
|
||||
+
|
||||
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ f = (float) event.getDamage();
|
||||
+ // CraftBukkit end
|
||||
this.setHurtDir(-this.getHurtDir());
|
||||
this.setHurtTime(10);
|
||||
this.markHurt();
|
||||
@@ -230,6 +264,15 @@
|
||||
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
|
||||
@@ -128,7 +147,7 @@
|
||||
object = new EntityMinecartRideable(worldserver, d0, d1, d2);
|
||||
}
|
||||
|
||||
if (flag || this.getDamage() > 40.0F) {
|
||||
+ // CraftBukkit start
|
||||
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
|
||||
+
|
||||
+ if (destroyEvent.isCancelled()) {
|
||||
+ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.ejectPassengers();
|
||||
if (flag && !this.hasCustomName()) {
|
||||
this.discard();
|
||||
@@ -291,6 +334,14 @@
|
||||
- Object object1 = object;
|
||||
+ EntityMinecartAbstract object1 = (EntityMinecartAbstract) object; // CraftBukkit- decompile error
|
||||
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, entityhuman).accept(object1);
|
||||
return (EntityMinecartAbstract) object1;
|
||||
@@ -267,6 +286,14 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -86,7 +57,7 @@
|
||||
if (this.getHurtTime() > 0) {
|
||||
this.setHurtTime(this.getHurtTime() - 1);
|
||||
}
|
||||
@@ -300,7 +351,7 @@
|
||||
@@ -276,7 +303,7 @@
|
||||
}
|
||||
|
||||
this.checkBelowWorld();
|
||||
@@ -95,7 +66,7 @@
|
||||
if (this.level().isClientSide) {
|
||||
if (this.lerpSteps > 0) {
|
||||
this.lerpPositionAndRotationStep(this.lerpSteps, this.lerpX, this.lerpY, this.lerpZ, this.lerpYRot, this.lerpXRot);
|
||||
@@ -358,6 +409,18 @@
|
||||
@@ -334,6 +361,18 @@
|
||||
}
|
||||
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
@@ -114,7 +85,7 @@
|
||||
if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this));
|
||||
|
||||
@@ -368,8 +431,26 @@
|
||||
@@ -344,8 +383,26 @@
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
|
||||
@@ -141,7 +112,7 @@
|
||||
entity.push(this);
|
||||
}
|
||||
}
|
||||
@@ -381,6 +462,14 @@
|
||||
@@ -357,6 +414,14 @@
|
||||
Entity entity1 = (Entity) iterator1.next();
|
||||
|
||||
if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
|
||||
@@ -156,7 +127,7 @@
|
||||
entity1.push(this);
|
||||
}
|
||||
}
|
||||
@@ -397,7 +486,7 @@
|
||||
@@ -373,7 +438,7 @@
|
||||
}
|
||||
|
||||
protected double getMaxSpeed() {
|
||||
@@ -165,7 +136,7 @@
|
||||
}
|
||||
|
||||
public void activateMinecart(int i, int j, int k, boolean flag) {}
|
||||
@@ -408,12 +497,16 @@
|
||||
@@ -384,12 +449,16 @@
|
||||
|
||||
this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0));
|
||||
if (this.onGround()) {
|
||||
@@ -184,7 +155,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -609,7 +702,7 @@
|
||||
@@ -585,7 +654,7 @@
|
||||
}
|
||||
|
||||
protected void applyNaturalSlowdown() {
|
||||
@@ -193,7 +164,7 @@
|
||||
Vec3D vec3d = this.getDeltaMovement();
|
||||
|
||||
vec3d = vec3d.multiply(d0, 0.0D, d0);
|
||||
@@ -748,6 +841,14 @@
|
||||
@@ -724,6 +793,14 @@
|
||||
if (!this.level().isClientSide) {
|
||||
if (!entity.noPhysics && !this.noPhysics) {
|
||||
if (!this.hasPassenger(entity)) {
|
||||
@@ -208,7 +179,7 @@
|
||||
double d0 = entity.getX() - this.getX();
|
||||
double d1 = entity.getZ() - this.getZ();
|
||||
double d2 = d0 * d0 + d1 * d1;
|
||||
@@ -945,4 +1046,26 @@
|
||||
@@ -898,4 +975,26 @@
|
||||
|
||||
private EnumMinecartType() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user