#1181: Consolidate Location conversion code
By: Doc <nachito94@msn.com>
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/vehicle/EntityBoat.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/EntityBoat.java
|
||||
@@ -53,6 +53,15 @@
|
||||
@@ -53,6 +53,16 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
|
||||
+// 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 class EntityBoat extends Entity implements VariantHolder<EntityBoat.EnumBoatType> {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT);
|
||||
@@ -93,6 +102,14 @@
|
||||
@@ -93,6 +103,14 @@
|
||||
private float bubbleAngle;
|
||||
private float bubbleAngleO;
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
public EntityBoat(EntityTypes<? extends EntityBoat> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.paddlePositions = new float[2];
|
||||
@@ -162,6 +179,19 @@
|
||||
@@ -162,6 +180,19 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
return false;
|
||||
} else if (!this.level.isClientSide && !this.isRemoved()) {
|
||||
@@ -51,7 +52,7 @@
|
||||
this.setHurtDir(-this.getHurtDir());
|
||||
this.setHurtTime(10);
|
||||
this.setDamage(this.getDamage() + f * 10.0F);
|
||||
@@ -170,6 +200,15 @@
|
||||
@@ -170,6 +201,15 @@
|
||||
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
|
||||
|
||||
if (flag || this.getDamage() > 40.0F) {
|
||||
@@ -67,7 +68,7 @@
|
||||
if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
this.destroy(damagesource);
|
||||
}
|
||||
@@ -209,9 +248,29 @@
|
||||
@@ -209,9 +249,29 @@
|
||||
public void push(Entity entity) {
|
||||
if (entity instanceof EntityBoat) {
|
||||
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
|
||||
@@ -97,7 +98,7 @@
|
||||
super.push(entity);
|
||||
}
|
||||
|
||||
@@ -279,6 +338,7 @@
|
||||
@@ -279,6 +339,7 @@
|
||||
return this.getDirection().getClockWise();
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
this.oldStatus = this.status;
|
||||
@@ -319,6 +379,22 @@
|
||||
@@ -319,6 +380,22 @@
|
||||
this.setDeltaMovement(Vec3D.ZERO);
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@
|
||||
+ org.bukkit.Server server = this.level.getCraftServer();
|
||||
+ org.bukkit.World bworld = this.level.getWorld();
|
||||
+
|
||||
+ 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();
|
||||
+
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
|
||||
@@ -128,7 +129,7 @@
|
||||
this.tickBubbleColumn();
|
||||
|
||||
for (int i = 0; i <= 1; ++i) {
|
||||
@@ -830,6 +906,11 @@
|
||||
@@ -830,6 +907,11 @@
|
||||
|
||||
this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall());
|
||||
if (!this.level.isClientSide && !this.isRemoved()) {
|
||||
@@ -140,7 +141,7 @@
|
||||
this.kill();
|
||||
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
int i;
|
||||
@@ -843,6 +924,7 @@
|
||||
@@ -843,6 +925,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user