mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fixed crash when disguising as certain types of blocks
This commit is contained in:
parent
5c2e156392
commit
f14ab56d54
3 changed files with 14 additions and 16 deletions
|
@ -73,14 +73,14 @@ public class EntityBehaviour<T extends Entity> {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
float h = entity.getHeight() - 0.1F;
|
||||
float w = entity.getWidth();
|
||||
float h = Math.max(0.001F, entity.getHeight() - 0.1F);
|
||||
float w = Math.max(0.001F, entity.getWidth());
|
||||
|
||||
if (current.isPresent() && h == current.get().height && w == current.get().width) {
|
||||
return current;
|
||||
}
|
||||
|
||||
return Optional.of(EntityDimensions.changing(entity.getHeight() - 0.1F, entity.getWidth()));
|
||||
return Optional.of(EntityDimensions.changing(h, w));
|
||||
}
|
||||
|
||||
public void copyBaseAttributes(LivingEntity from, Entity to) {
|
||||
|
|
|
@ -24,27 +24,17 @@ import net.minecraft.state.property.Properties;
|
|||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Direction.Axis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
|
||||
public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
||||
|
||||
private static final Vec3d UP = Vec3d.of(Direction.UP.getVector());
|
||||
|
||||
// private static final Optional<EntityDimensions> FULL_BLOCK = Optional.of(EntityDimensions.changing(0.6F, 0.9F));
|
||||
private static final Optional<EntityDimensions> FULL_BLOCK = Optional.of(EntityDimensions.changing(0.6F, 0.9F));
|
||||
|
||||
@Override
|
||||
public Optional<EntityDimensions> getDimensions(FallingBlockEntity entity, Optional<EntityDimensions> current) {
|
||||
|
||||
VoxelShape shape = entity.getBlockState().getCollisionShape(entity.world, entity.getBlockPos());
|
||||
float height = (float)shape.getMax(Axis.Y);
|
||||
|
||||
if (!current.isPresent() || current.get().height != height) {
|
||||
return Optional.of(EntityDimensions.changing(0.6F, height));
|
||||
}
|
||||
|
||||
return current;
|
||||
return FULL_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Optional;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
||||
|
||||
import net.minecraft.entity.EntityDimensions;
|
||||
|
@ -48,9 +49,16 @@ public final class PlayerDimensions {
|
|||
flyingDimensions = EntityDimensions.changing(dimensions.width, dimensions.height / 2);
|
||||
}
|
||||
|
||||
return getPredicate()
|
||||
dimensions = getPredicate()
|
||||
.flatMap(e -> e.getTargetDimensions(pony))
|
||||
.orElseGet(() -> physics.isFlyingSurvival ? flyingDimensions : defaultDimensions);
|
||||
|
||||
if (dimensions.height < 0 || dimensions.width < 0) {
|
||||
Unicopia.LOGGER.warn("Dim out was negative! Restoring original");
|
||||
return defaultDimensions;
|
||||
}
|
||||
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
private float calculateTargetEyeHeight() {
|
||||
|
|
Loading…
Reference in a new issue