9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 01:49:30 +00:00

fix(bukkit): 修复Shulker 交互实体高度计算方法

This commit is contained in:
jhqwqmc
2025-04-02 16:07:18 +08:00
parent aacf82d523
commit 1279597a1a

View File

@@ -44,11 +44,23 @@ public class ShulkerHitBox extends AbstractHitBox {
if (this.interactionEntity) {
// make it a litter bigger
InteractionEntityData.Height.addEntityDataIfNotDefaultValue(getPhysicalPeek(peek * 0.01F) * scale + 1.01f, cachedInteractionValues);
InteractionEntityData.Height.addEntityDataIfNotDefaultValue((float) (getHeight(peek, scale, direction) + 0.01f), cachedInteractionValues);
InteractionEntityData.Width.addEntityDataIfNotDefaultValue(scale + 0.005f, cachedInteractionValues);
InteractionEntityData.Responsive.addEntityDataIfNotDefaultValue(interactive, cachedInteractionValues);
}
}
private static double getHeight(byte inPeek, float scale, Direction direction) {
float peek = getPhysicalPeek(inPeek * 0.01F);
double y1 = 0.0;
double y2 = scale;
double dy = (double) direction.stepY() * peek * (double) scale;
if (dy > 0) {
y2 += dy;
} else if (dy < 0) {
y1 += dy;
}
return y2 - y1;
}
@Override
public Optional<Collider> optionalCollider() {