Correct some things about width/length of entities.

This might have caused lag and all sorts of problems with moving, such
as getting pulled back near cobweb or water. [Still fp in survivalfly
left.]
This commit is contained in:
asofold 2012-12-17 19:15:21 +01:00
parent 432c7607aa
commit c6a4cf2ab7
5 changed files with 25 additions and 14 deletions

View File

@ -46,15 +46,24 @@ public interface MCAccess {
public double getHeight(Entity entity);
/**
* Return maximum.
* Return some width.
* @param entity
* @return
*/
public double getWidthOrLength(Entity entity);
public double getWidth(Entity entity);
/**
* NMS Block static.
* @param id
* @return
*/
public AlmostBoolean isBlockSolid(int id);
/**
* NMS Block static..
* @param id
* @return
*/
public AlmostBoolean isBlockLiquid(int id);
/**
@ -93,6 +102,11 @@ public interface MCAccess {
public void dealFallDamage(Player player, int damage);
/**
* This may well be removed, if possible to check with Bukkit.
* @param damaged
* @return
*/
public boolean isComplexPart(Entity damaged);
/**

View File

@ -54,7 +54,7 @@ public class MCAccessCB2511 implements MCAccess {
@Override
public double getHeight(final Entity entity) {
final net.minecraft.server.Entity mcEntity = ((CraftEntity) entity).getHandle();
final double entityHeight = Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b);
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b));
if (entity instanceof LivingEntity) {
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
} else return entityHeight;
@ -86,9 +86,8 @@ public class MCAccessCB2511 implements MCAccess {
}
@Override
public double getWidthOrLength(final Entity entity) {
final net.minecraft.server.Entity mcEntity = ((CraftEntity) entity).getHandle();
return Math.max(mcEntity.width, mcEntity.length);
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
}
@Override

View File

@ -53,7 +53,7 @@ public class MCAccessCB2512 implements MCAccess{
@Override
public double getHeight(final Entity entity) {
final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle();
final double entityHeight = Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b);
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.height, mcEntity.boundingBox.e - mcEntity.boundingBox.b));
if (entity instanceof LivingEntity) {
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
} else return entityHeight;
@ -85,9 +85,8 @@ public class MCAccessCB2512 implements MCAccess{
}
@Override
public double getWidthOrLength(final Entity entity) {
final net.minecraft.server.v1_4_5.Entity mcEntity = ((CraftEntity) entity).getHandle();
return Math.max(mcEntity.width, mcEntity.length);
public double getWidth(final Entity entity) {
return ((CraftEntity) entity).getHandle().width;
}
@Override

View File

@ -51,7 +51,7 @@ public class Direction extends Check {
return false;
// Find out how wide the entity is.
final double width = mcAccess.getWidthOrLength(damaged);
final double width = mcAccess.getWidth(damaged);
// entity.height is broken and will always be 0, therefore. Calculate height instead based on boundingBox.
final double height = mcAccess.getHeight(damaged);

View File

@ -526,9 +526,8 @@ public class PlayerLocation {
// maxY = y + entityPlayer.boundingBox.e + dY;
// maxZ = z + entityPlayer.boundingBox.f + dZ;
// // TODO: inset, outset ?
this.width = mcAccess.getWidthOrLength(player);
this.width = mcAccess.getWidth(player);
final double dxz = this.width / 2;
// final double dX = (entityPlayer.boundingBox.d - entityPlayer.boundingBox.a) / 2D;
// final double dY = entityPlayer.boundingBox.e - entityPlayer.boundingBox.b;
// final double dZ = (entityPlayer.boundingBox.f - entityPlayer.boundingBox.c) / 2D;