Fixed (kind) ghost blocks when disguised as the ravager and fixed incorrect hit boxes for entity disguises

This commit is contained in:
Sollace 2020-10-10 19:13:53 +02:00
parent bc097775a6
commit 3400512b39

View file

@ -17,6 +17,7 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.FallingBlockEntity; import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.mob.AbstractSkeletonEntity; import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.LlamaEntity;
import net.minecraft.entity.passive.SnowGolemEntity; import net.minecraft.entity.passive.SnowGolemEntity;
@ -77,14 +78,16 @@ public class EntityBehaviour<T extends Entity> {
return Optional.empty(); return Optional.empty();
} }
float h = Math.max(0.001F, entity.getHeight() - 0.1F); EntityDimensions dims = entity.getDimensions(entity.getPose());
float w = Math.max(0.001F, entity.getWidth());
float h = Math.max(0.001F, dims.height);
float w = Math.max(0.001F, dims.width);
if (current.isPresent() && h == current.get().height && w == current.get().width) { if (current.isPresent() && h == current.get().height && w == current.get().width) {
return current; return current;
} }
return Optional.of(EntityDimensions.changing(h, w)); return Optional.of(EntityDimensions.changing(w, h));
} }
public void copyBaseAttributes(LivingEntity from, Entity to) { public void copyBaseAttributes(LivingEntity from, Entity to) {
@ -97,6 +100,18 @@ public class EntityBehaviour<T extends Entity> {
to.removed = from.removed; to.removed = from.removed;
to.setOnGround(from.isOnGround()); to.setOnGround(from.isOnGround());
if (!from.world.isClient) {
// player collision is not known on the server
boolean clip = to.noClip;
to.noClip = false;
Vec3d vel = from.getRotationVec(1);
to.move(MovementType.SELF, vel);
to.noClip = clip;
} else {
to.verticalCollision = from.verticalCollision;
to.horizontalCollision = from.horizontalCollision;
}
if (Disguise.isAxisAligned(to)) { if (Disguise.isAxisAligned(to)) {
double x = positionOffset.x + Math.floor(from.getX()) + 0.5; double x = positionOffset.x + Math.floor(from.getX()) + 0.5;
double y = positionOffset.y + Math.floor(from.getY()); double y = positionOffset.y + Math.floor(from.getY());
@ -153,8 +168,6 @@ public class EntityBehaviour<T extends Entity> {
to.prevYaw = from.prevYaw; to.prevYaw = from.prevYaw;
to.horizontalSpeed = from.horizontalSpeed; to.horizontalSpeed = from.horizontalSpeed;
to.prevHorizontalSpeed = from.prevHorizontalSpeed; to.prevHorizontalSpeed = from.prevHorizontalSpeed;
to.horizontalCollision = from.horizontalCollision;
to.verticalCollision = from.verticalCollision;
to.setOnGround(from.isOnGround()); to.setOnGround(from.isOnGround());
to.distanceTraveled = from.distanceTraveled; to.distanceTraveled = from.distanceTraveled;