Use the model's head position rather than the entities for determining if it's submerged

This commit is contained in:
Sollace 2018-07-27 00:17:23 +02:00
parent 028b86d749
commit b86403ae65

View file

@ -19,6 +19,7 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -113,7 +114,13 @@ public class Pony {
} }
public boolean isFullySubmerged(EntityLivingBase entity) { public boolean isFullySubmerged(EntityLivingBase entity) {
return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(entity.getPositionEyes(1))).getMaterial() == Material.WATER; return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(getVisualEyePosition(entity))).getMaterial() == Material.WATER;
}
protected Vec3d getVisualEyePosition(EntityLivingBase entity) {
PonySize size = entity.isChild() ? PonySize.FOAL : metadata.getSize();
return new Vec3d(entity.posX, entity.posY + (double)entity.getEyeHeight() * size.getScaleFactor(), entity.posZ);
} }
public boolean isWearingHeadgear(EntityLivingBase entity) { public boolean isWearingHeadgear(EntityLivingBase entity) {