#1181: Consolidate Location conversion code

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2023-04-19 19:59:19 +10:00
parent 2ffb1d2479
commit b99d3df2d8
43 changed files with 424 additions and 316 deletions

View File

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
@@ -47,6 +47,15 @@
@@ -47,6 +47,16 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+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;
@@ -16,7 +17,7 @@
public abstract class EntityMinecartAbstract extends Entity {
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityMinecartAbstract.class, DataWatcherRegistry.INT);
@@ -89,6 +98,17 @@
@@ -89,6 +99,17 @@
private double lyd;
private double lzd;
@@ -34,7 +35,7 @@
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.blocksBuilding = true;
@@ -215,6 +235,19 @@
@@ -215,6 +236,19 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
@@ -54,7 +55,7 @@
this.setHurtDir(-this.getHurtDir());
this.setHurtTime(10);
this.markHurt();
@@ -223,6 +256,15 @@
@@ -223,6 +257,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
@@ -70,7 +71,7 @@
this.ejectPassengers();
if (flag && !this.hasCustomName()) {
this.discard();
@@ -284,6 +326,14 @@
@@ -284,6 +327,14 @@
@Override
public void tick() {
@@ -85,7 +86,7 @@
if (this.getHurtTime() > 0) {
this.setHurtTime(this.getHurtTime() - 1);
}
@@ -293,7 +343,7 @@
@@ -293,7 +344,7 @@
}
this.checkOutOfWorld();
@@ -94,14 +95,14 @@
double d0;
if (this.level.isClientSide) {
@@ -359,6 +409,18 @@
@@ -359,6 +410,18 @@
}
this.setRot(this.getYRot(), this.getXRot());
+ // CraftBukkit start
+ org.bukkit.World bworld = this.level.getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
@@ -113,7 +114,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));
@@ -367,8 +429,26 @@
@@ -367,8 +430,26 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
@@ -140,7 +141,7 @@
entity.push(this);
}
}
@@ -380,6 +460,14 @@
@@ -380,6 +461,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
@@ -155,7 +156,7 @@
entity1.push(this);
}
}
@@ -396,7 +484,7 @@
@@ -396,7 +485,7 @@
}
protected double getMaxSpeed() {
@@ -164,7 +165,7 @@
}
public void activateMinecart(int i, int j, int k, boolean flag) {}
@@ -407,12 +495,16 @@
@@ -407,12 +496,16 @@
this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0));
if (this.onGround) {
@@ -183,7 +184,7 @@
}
}
@@ -603,7 +695,7 @@
@@ -603,7 +696,7 @@
}
protected void applyNaturalSlowdown() {
@@ -192,7 +193,7 @@
Vec3D vec3d = this.getDeltaMovement();
vec3d = vec3d.multiply(d0, 0.0D, d0);
@@ -742,6 +834,14 @@
@@ -742,6 +835,14 @@
if (!this.level.isClientSide) {
if (!entity.noPhysics && !this.noPhysics) {
if (!this.hasPassenger(entity)) {
@@ -207,7 +208,7 @@
double d0 = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ();
double d2 = d0 * d0 + d1 * d1;
@@ -916,4 +1016,26 @@
@@ -916,4 +1017,26 @@
private EnumMinecartType() {}
}